• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help completing these requirements  RSS feed

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need help on completing the following requirements I mainly need help on the first 3 requirements I don't know if my attempt is correct :

1.Each Course object maintains a list of the students on that course and the lecturer who
has been assigned to teach that course.

2.The Course object has behaviour that allow the adding and removing of students from
the course, assigning a teacher, getting a list of the currently assigned students, and the
currently assigned teacher.

3.Teachers are modelled as Lecturer objects. As a lecturer may teach more than one
course there is an association between Course and Lecturer. The taughtBy relationship
shows that a Course only has a single teacher, but that a lecturer may teach several
Courses.

4.Each Lecturer object also maintains a list of the Courses that it teaches.

5.There is a similar relationship between Course and Student. A course is attended by
zero or more Students, and a Student may attend multiple courses.

6.both Student and Lecture classes implement the Person interface.
item


Here is my code so far:
 
author & internet detective
Marshal
Posts: 37518
554
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jason,
Let's start with requirement #1:

Each Course object

You have a Course object. Good.

maintains a list of the students on that course

You do have a list in the Course object. But it doesn't have a clear name. Your list implies it is a list of courses. But a course doesn't have a list of courses. It should have a list of students.

and the lecturer who has been assigned to teach that course.

You have a lecturer class. You still need an instance variable of that type in your Course class.
 
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:It should have a list of students.

And futhermore, a List of Students should be a List<Student>, not a List<String>. A String is NOT a Student, and you should generally try to avoid them - unless of course, they actually hold a piece of text.

And another little tip for you: You're generally far better off using a generalized type than a specific one, particularly for things like Lists. ie:

  private List<Student> students = new ArrayList<Student>();

It's called "programming to the interface"; and it's a very good habit to get into.

HIH

Winston
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!