Read in students file. For each student ID create a Student object. Set that objects name to the name in the file after the student ID. Add the Student object to the map with the student ID as the key. Read in courses file. For each student ID, lookup the Student object from the map. Read the credit hour line in the file. Read the grade line in the file. Create a Course object using the credit hour and grade. Add that Course object to the Student object's collection of courses.
Here is my code which reads in the information from the file:
FileReader freader = new FileReader(nameFile);
BufferedReader Breader = new BufferedReader(freader);
boolean end = Breader.ready();
do {
next = Breader.readLine();
sNumber = Integer.parseInt(next);
formatSNumber = String.format("%03d", sNumber);
//Assignment the formatted number to my HashMap
sName = Breader.readLine();
//Assignment the name to my HashMap
end = Breader.ready();
} while(end);
I am completely lost on how to do this.
I know how to create a student object:
Student student1 = new Student();
However, I need each name, "student1", to be different depending upon the information read in.
For example, if I read "001" and "Julie Jones", I want my student object to be
Student student1 = new Student();
And then the next one to be
Student student2 = new Student();
For Student studenti = new Student();, where i = the number of student IDs read in from the file.
Breader? This class is not part of the standard JDK.StudentBECAUSE every time that your loop iterates it re-declares the Student object and the code re-initialises the values that will be stored in the Student Object. These objects can within the loop be added to anArrayList