diff --git a/src/main/java/org/example/Course.java b/src/main/java/org/example/Course.java index e32b098..b294177 100644 --- a/src/main/java/org/example/Course.java +++ b/src/main/java/org/example/Course.java @@ -1,4 +1,7 @@ package org.example; +import java.io.*; + + /** * The Course class represents a course in a curriculum. @@ -96,4 +99,16 @@ public class Course { System.out.println("Course Code: " + courseCode); System.out.println("Course Credits: " + courseCredit); } + + public void writeToFile(String filename) { + try (PrintWriter writer = new PrintWriter(new FileWriter(filename))) { + writer.println(courseName); + writer.println(courseCode); + writer.println(courseCredit); + // Add any other fields you want to save + } catch (IOException e) { + e.printStackTrace(); + } + } + }