Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
(class)
<<Java Class>>
Course

(variables)
students: List
teacher: Lecturer

(methods)
addStudent(student: Student)
assignTeacher(teacher: Lecturer)
getNumberofStudents(): void
getTeacher(): Lecturer
removeStudent(student: Student): void


Java
import java.awt.List;
import java.util.ArrayList;
 
interface Person{
public String getName();
}
 

class Course{
  ArrayList students = new ArrayList();

  public addStudent(student: Student){

  }

  void getNumberOfStudents(){

  }
}
Posted
Updated 17-Jan-15 4:01am
v3
Comments
Sergey Alexandrovich Kryukov 16-Jan-15 16:37pm    
Sorry, this is not really a question. This is the request disguised as question: "please write code for me based on this pseudo-code". It won't work this way here. You need to do your job. If you show what have you tried so far and explain your problems, if you face any, we will gladly try to help you.
—SA
Member 11380784 16-Jan-15 17:00pm    
Ok I have started on it:

import java.awt.List;
import java.util.ArrayList;

interface Person{
public String getName();
}


class Course{
ArrayList<string> students = new ArrayList<string>();

public addStudent(student: Student){

}

void getNumberOfStudents(){

}
}
Sergey Alexandrovich Kryukov 16-Jan-15 17:14pm    
Look, why putting any code in comments? It's not readable. Use "Improve question" with proper "pre" formatting tag.
—SA

Go to http://docs.oracle.com/javase/tutorial/index.html[^] and work through the tutorials in the section headed Trails Covering the Basics. That should help you get started.
 
Share this answer
 
Java
import java.awt.List;
import java.util.ArrayList;
 
public interface Person{ // make it a public. Is an interface demanded?
  public String getName();
}
 

public class Course{ // also public 
  private ArrayList students = new ArrayList(); // this is private!

  public addStudent(student: Student){

  }

  public void getNumberOfStudents(){ // public method

  }
}


visibillity seems not to be clear to you. Please read on that issue.

Is the interface demanded? This homework normally comes without interfaces.
The member variable teacher is missing on the object course.

Where is the controlling class (the one with the main method) ?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900