Browse Source

Added writeToFile for the Professor Data

remotes/origin/fdai7780
fdai7600 11 months ago
parent
commit
1211419687
  1. 15
      src/main/java/org/example/Professor.java

15
src/main/java/org/example/Professor.java

@ -1,4 +1,13 @@
package org.example;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
/**
* Represents a professor in the system.
* This class holds the details of a professor including their ID, name, and role.
@ -101,4 +110,10 @@ public class Professor {
", role='" + role + '\'' +
'}';
}
public void writeToFile() throws IOException {
try (BufferedWriter writer = new BufferedWriter(new FileWriter("professorData.txt", true))) {
writer.write(this.toString());
writer.newLine();
}
}
}
Loading…
Cancel
Save