• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Help completing these requirements

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 42003
911
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
If you are using a rototiller, you are doing it wrong. Even on this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic