public class MainApp {
public static void main(String[] args) throws FileNotFoundException {
// DateTimeFormatter formatter= new DateTimeFormatterBuilder().appendPattern("YYYY-MM-dd").toFormatter();
List<Scoala> scoala = new ArrayList<>();
BufferedReader fisier = new BufferedReader(new FileReader("src/fisier.txt"));
try {
String linie;
String[] array;
while ((linie = fisier.readLine()) != null) {
array = linie.split(";");
String nume = array[0];
LocalDate data_n = LocalDate.parse(array[1]);//formatter);
float bani = Float.parseFloat(array[2]);
String tip = array[3];
if (tip.equals("elev")) {
float medie = Float.parseFloat(array[4]);
int nr_ob = Integer.parseInt(array[5]);
String clasa = array[6];
Statut statut;
switch (array[7].toLowerCase()) {
case "eminent":
statut = Statut.eminent;
break;
case "fruntas":
statut = Statut.fruntas;
break;
default:
statut = Statut.eminent;
break;
}
Elevi student = new Elevi(nume, data_n, bani, medie, nr_ob, clasa, statut);
scoala.add(student);
}else{
int grad=Integer.parseInt(array[4]);
String materie=array[5];
Profi profesor=new Profi(nume, data_n, bani, grad, materie);
scoala.add(profesor);
}
}
} catch (IOException ex) {
ex.printStackTrace();
}
for(Scoala s: scoala){
System.out.println(s);
}
}
}