I'm almost done with my assignement
I've created 2 class and I have one format method in student class
the file look like this (there are about 25 lines)
courseNum
courseName
courseSemester
studentID,studentProgram,studentGpa
studentID,studentProgram,studentGpa
the output should look like this
courseNum
courseName
courseSemester
studentID--studentProgram--studentGpa
studentID--studentProgram--studentGpa
I'm still not sure if my code are correct but I want to know how can I return ArrayList
private List<Student> createStudent(String fileName) {
String[] data = FileUtils.readIntoArray(fileName);
List<Student> res = new ArrayList();
List<Course> a = new ArrayList();
for (int i = 0; i < data.length; i++) {
String line = data[i];
String num = data[0];
String name = data[1];
String semester = data[3];
String[] p = line.split(",");
int id = Integer.parseInt(p[4]);
String program = p[5];
double gpa = Double.parseDouble(p[6]);
List<Student> s = (List<Student>) new Student(id, program, gpa);
List<Course> c = (List<Course>) new Course(num, name, semester, s);
res [i] = c;
}
return res;
}