From 1211419687f7264722dd6ba080cd01092951e7ea Mon Sep 17 00:00:00 2001 From: fdai7600 Date: Wed, 7 Feb 2024 14:47:36 +0100 Subject: [PATCH 1/2] Added writeToFile for the Professor Data --- src/main/java/org/example/Professor.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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(); + } + } } From 9f68b87804bc806583110001e708257b9e70650d Mon Sep 17 00:00:00 2001 From: fdai7600 Date: Wed, 7 Feb 2024 14:58:42 +0100 Subject: [PATCH 2/2] Added ProfessorTest Class --- src/test/java/org/example/ProfessorTest.java | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 src/test/java/org/example/ProfessorTest.java diff --git a/src/test/java/org/example/ProfessorTest.java b/src/test/java/org/example/ProfessorTest.java new file mode 100644 index 0000000..ab52603 --- /dev/null +++ b/src/test/java/org/example/ProfessorTest.java @@ -0,0 +1,4 @@ +package org.example; + +public class ProfessorTest { +}