Hi
Following on from this Q of mine: http://stackoverflow.com/questions/754184/whats-the-best-way-to-make-this-java-program
I was recommended to store a list in Lecturer class and Course class. So I did, and it looks something like this:
public class Lecturer
{
private String id;
private String name;
List<Course> courses = new ArrayList<Course>(); // a list to hold the courses
public Lecturer(String idIn, String nameIn) // arguments of the constructor
{
id = idIn;
name = nameIn;
}
}
Same thing for the Course class except it has Lecturer list. But what I dont get is what does placing a list there exactly do? cos I dont know where to put the methods of the ArrayList such as adding and removing lecturers from it?
Can someone explain the purpose of this?
I use another method which is basically placing the arraylists and its methods in two seperate classes for the lecturer and course, and then I simply add into the Course and Lecturer class as an attribute eg:
public class Lecturer
{
private String id;
private String name;
private CourseList courses; // COurseList is the class with the arraylist and methods
public Lecturer(String idIn, String nameIn) // arguments of the constructor
{
id = idIn;
name = nameIn;
courses = new CourseList();
}
}
I hope i'm making sense, cos ive been stuck on one thing for the last 2 weeks which no seems to understand.
Thank you