diff --git a/src/main/java/org/example/Professor.java b/src/main/java/org/example/Professor.java index 10b1079..5388030 100644 --- a/src/main/java/org/example/Professor.java +++ b/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(); + } + } }