|
|
@ -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); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |