From 0377c71c525318bb01d4d9d2cbd46a17bcaa2d64 Mon Sep 17 00:00:00 2001 From: fdai7921 Date: Wed, 7 Feb 2024 14:38:18 +0100 Subject: [PATCH] refactoring: more clarity for output messages of Course add and delete functions --- src/main/java/org/example/Course.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/example/Course.java b/src/main/java/org/example/Course.java index 10cb36b..1714e77 100644 --- a/src/main/java/org/example/Course.java +++ b/src/main/java/org/example/Course.java @@ -203,7 +203,7 @@ public class Course { // Add the course using the provided data addCourse(courseName, courseCode, courseCredit, filename); - System.out.println("Added Course successfully!"); + System.out.println(courseName + " added successfully!"); } /** @@ -231,6 +231,8 @@ public class Course { int selection = scanner.nextInt(); + String toDeleteCourse = courses.get(selection-1).getCourseName(); + if (selection == 0) { return; // Return to the menu } else if (selection < 1 || selection > courses.size()) { @@ -251,7 +253,7 @@ public class Course { e.printStackTrace(); } - System.out.println("Course deleted successfully."); + System.out.println(toDeleteCourse + " deleted successfully."); return; } }