|
@ -105,14 +105,16 @@ public class Course { |
|
|
/** |
|
|
/** |
|
|
* Writes the information of the course to a file. |
|
|
* Writes the information of the course to a file. |
|
|
* |
|
|
* |
|
|
* @param filename The name of the file to write to. |
|
|
|
|
|
|
|
|
* @param courseName The name of the course. |
|
|
|
|
|
* @param courseCode The code of the course. |
|
|
|
|
|
* @param courseCredit The credit value of the course. |
|
|
|
|
|
* @param filename The name of the file to write to. |
|
|
*/ |
|
|
*/ |
|
|
public void writeToFile(String filename) { |
|
|
|
|
|
try (PrintWriter writer = new PrintWriter(new FileWriter(filename))) { |
|
|
|
|
|
|
|
|
public void writeToFile(String courseName, String courseCode, int courseCredit, String filename) { |
|
|
|
|
|
try (PrintWriter writer = new PrintWriter(new FileWriter(filename, true))) { |
|
|
writer.println(courseName); |
|
|
writer.println(courseName); |
|
|
writer.println(courseCode); |
|
|
writer.println(courseCode); |
|
|
writer.println(courseCredit); |
|
|
writer.println(courseCredit); |
|
|
// Add any other fields you want to save |
|
|
|
|
|
} catch (IOException e) { |
|
|
} catch (IOException e) { |
|
|
e.printStackTrace(); |
|
|
e.printStackTrace(); |
|
|
} |
|
|
} |
|
|