diff --git a/src/main/java/org/example/Student.java b/src/main/java/org/example/Student.java index 9708eb9..1f2f009 100644 --- a/src/main/java/org/example/Student.java +++ b/src/main/java/org/example/Student.java @@ -1,4 +1,9 @@ package org.example; + +import java.io.BufferedWriter; +import java.io.FileWriter; +import java.io.IOException; + /** * Represents an student user in the system. */ @@ -61,4 +66,14 @@ public class Student { System.out.println("Role: " + getRole()); } + + public void writeToFile(Student student, String filename) throws IOException { + try(BufferedWriter writer = new BufferedWriter(new FileWriter(filename))){ + String attributes = student.getName() + "\n" + student.getId() + "\n" + student.getRole(); + writer.write(attributes); + } + + } + + }