The one by Campbell is much optimized indeed.. but your design also didn't had any problem.. the only problem area that
I can observe from your code is here :
you were using the same CollegeCourse object for all students...and then setting the values for the students..and every next value overrides the
previous one..as indeed those are instance values but also are the instances to the same reference (something you must know when using objects)
Regards
Prince
Chris Morris wrote:Being I am a beginner, I am sure the subject's explanation makes little to no sense. I hope that the code can explain the story better. I am certainly not looking for someone to do the code for me, just to maybe guide me in the right direction since I am absolutely lost at this point.
The exercise - not a homework assignment, do not worry - asks to create two classes; a CollegeCourse class and a Student Class. The CollegeCourse class is supposed to have data fields for a course ID, grade, and credit hours and then set and get methods for each. The Student class, which is where I believe I am messing up, contains a data field for a student ID and 5 CollegeCourse objects by using an array. This class requires set and get methods as well, although I am having trouble with the set and get methods for the object array. The third class, InputGrades, is the one that contains the main class and utilizes the first two classes. The third class is incomplete as of now because I have not figured out how to properly use the objects, especially the object array within the Student class.
Thank you in advance and feel free to offer any critiques, even if unrelated to topic (e.g. poor coding, etc.).