implement StudentLoader.java
This commit is contained in:
@@ -25,28 +25,26 @@ public class StudentLoader extends Thread {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
// TODO:
|
for(String line : lines){
|
||||||
|
|
||||||
/*
|
if( line == null || line.isBlank()) continue;
|
||||||
Example line:
|
|
||||||
|
|
||||||
1001,Aryan,Computer Science,3.7
|
try {
|
||||||
*/
|
|
||||||
|
|
||||||
for (String line : lines) {
|
String[] parts = line.split(",");
|
||||||
|
|
||||||
// TODO:
|
|
||||||
// split line
|
|
||||||
|
|
||||||
// TODO:
|
int id = Integer.parseInt(parts[0].trim());
|
||||||
// read values
|
String name = parts[1].trim();
|
||||||
|
String major = parts[2].trim();
|
||||||
|
double gpa = Double.parseDouble(parts[3].trim());
|
||||||
|
|
||||||
// TODO:
|
|
||||||
// create Student
|
|
||||||
|
|
||||||
// TODO:
|
students.add(new Student(id, name, major, gpa));
|
||||||
// add to students list
|
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("Error parsing line: " + line);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user