implement StudentLoader.java

This commit is contained in:
2026-05-25 21:20:30 +03:30
parent a7d2373bad
commit 6fc03bf1b0
+12 -14
View File
@@ -25,28 +25,26 @@ public class StudentLoader extends Thread {
@Override
public void run() {
// TODO:
for(String line : lines){
/*
Example line:
if( line == null || line.isBlank()) continue;
1001,Aryan,Computer Science,3.7
*/
try {
for (String line : lines) {
String[] parts = line.split(",");
// TODO:
// split line
// TODO:
// read values
int id = Integer.parseInt(parts[0].trim());
String name = parts[1].trim();
String major = parts[2].trim();
double gpa = Double.parseDouble(parts[3].trim());
// TODO:
// create Student
// TODO:
// add to students list
students.add(new Student(id, name, major, gpa));
} catch (Exception e) {
System.err.println("Error parsing line: " + line);
}
}
}