Johny Sougiospitos wrote:i believe that you never intended to help me...
Anyway it's my loss sinve i can't solve this exercise//and i am mad because teacher told us that this exercise will not take us more than 1 hour...and i am trying to solve it 5 days!
Carey Brown wrote:I'm not entirely sure how StudentsPerCourse is supposed to work but here's a stab.
Then in School you might have
Then to pick a Student to display all the courses they are enrolled in
Loop through all the students and display the List to the user as a numbered list and let the user choose the student number.
Then, using the student number get the Student reference. Using the Student reference loop through your studentsPerCourse and find all entries where 'student' matches your Student reference and then print the course associated with that.
This should work but this alone is at least an hour to implement and debug.
Carey Brown wrote:
This is exactly where I got stuck on your project. This requires a bit of un-thinking. What you need is a bi-directional relationship. That is: you have Students dependent on Courses while at the same time you have Courses dependent on Students. There can be a collection (e.g. list) of these relationships but the Student+Course combination must be unique in the collection. This is why I find even the name StudentPerCourse inappropriate because it implies some sort of directional dependency when it's actually a bi-directional dependency. You'll need to be able to go through this collection looking for all entries for a particular Student and do something useful with the corresponding Course (e.g. print it). Conversely, you'll also need to be able to go through the collection looking for all entries for a particular Course and do something useful with the corresponding Student.Johny Sougiospitos wrote:that's where i am confused and i do not know what to do
in Class StudentPerCourse i have that
and that i do not know how it is supposed to help me!
and what kind of method to create with what kind of loop
Johny Sougiospitos wrote:
Carey Brown wrote:
silly question...in a similar way i print the list of all students..
why should the user select one student??
and one thin i just thought...if in Class Courses i create a method addStudent (return Student) doesn't that work with Course1,course2 etc? i can use Course1.addStudent right?
Carey Brown wrote:
The scenario that I can think of is if you want to enroll one student in one class.
Same applies for selecting a Course. Display a numbered list of Courses and let the user choose one. If you wanted to get fancy I suppose you could let the user select multiples and return a list but I'd stick with the basics first.
Johny Sougiospitos wrote:i can use Course1.addStudent right?
Carey Brown wrote:
Johny Sougiospitos wrote:i can use Course1.addStudent right?
This is where I'd use ManageStudentCourseRelationship.
Ellipses means there's stuff that's been left out because it is either not important to the discussion or is left as an exercise to the developer.Johny Sougiospitos wrote:the "..." what's supposed to mean??
Yes, I'd pick a shorter name but I wanted to get the point across.Johny Sougiospitos wrote:the "manageStudentcourseRelationship" is the name of the method???Large name!!
Yes.you mean in the school Class -which is the main-- write that method?
This is just not an easy problem, no matter what your instructor says.i can see what you want to tell me but it seems i am not as good as you in the code writing..
and i think i should be write simpler code since i am beginner.
Actually, the name of a class.Johny Sougiospitos wrote:the "ManageStudentCourseRelationship" is the name of the method???Large name!!
Carey Brown wrote:This is just not an easy problem, no matter what your instructor says.
Carey Brown wrote:
Actually, the name of a class.Johny Sougiospitos wrote:the "ManageStudentCourseRelationship" is the name of the method???Large name!!
Johny Sougiospitos wrote:okay...my code is thatthis is the point i must create a method in Class Course -perhaps- to do the things i told you.. how should i use what you purpose??
Precisely, except in a more bi-directional dependent sort of way.Johny Sougiospitos wrote:
Carey Brown wrote:
Actually, the name of a class.Johny Sougiospitos wrote:the "ManageStudentCourseRelationship" is the name of the method???Large name!!
i got it..it's something like the middle class my teacher said "StudentPerCourse"
Johny Sougiospitos wrote:
Carey Brown wrote:This is just not an easy problem, no matter what your instructor says.
you believe that what i am thinking to do difficult/easy/stupid?
Carey Brown wrote:
This is too hard coded. Presumably your School class has a List<Course> courseList. You can write a generic method that allows a user to select one of the available Courses.
This will work when you add and delete courses.
Well, if you want to pre-fill courseList with hard-coded courses, that's fine, it's just that the code you write shouldn't be dependent on that.Johny Sougiospitos wrote:Teacher told us to have a list with courses and the user can only add othe courses not delete..
So if the user doesn't want to add a new course ,he/she must choose from the existing ones..
that's the reason i was thinking the "code" i wrote before
Carey Brown wrote:
Well, if you want to pre-fill courseList with hard-coded courses, that's fine, it's just that the code you write shouldn't be dependent on that.Johny Sougiospitos wrote:Teacher told us to have a list with courses and the user can only add othe courses not delete..
So if the user doesn't want to add a new course ,he/she must choose from the existing ones..
that's the reason i was thinking the "code" i wrote before
That's a pleasure I am sorry that your exercise didn't work out.Johny Sougiospitos wrote: thanks for all the help . . .
Campbell Ritchie wrote:
That's a pleasure I am sorry that your exercise didn't work out.Johny Sougiospitos wrote: thanks for all the help . . .
Although I only played a small part in this discussion, we really were trying to help. Giving you too much information or a complete solution wouldn'tt have helped you, so I think your allegation in your last post is unfair to those who have put a lot of effort into this discussion.
Liutauras Vilda wrote:I suggest you post full instructions you were given, and the code templates you were given without any of your additions. There is a chance you misunderstood, misinterpreted stuff.
Give guys to have a look so could give an opinion whether it is too hard.
Which course you are at once again? Which year?