diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index cda9fe5ace..75f48f8dea 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -318,7 +318,7 @@ Command: `required` Response: Module requirements for major selected by user -## Add lessons in the Weekly Timetable +## Modify lessons in the Weekly Timetable User Input: `timetable modify` @@ -339,10 +339,46 @@ The following sequence diagram details the process of the 'timetable modify loop - `saveTimetable`: Saves the current timetable to storage. - `printTimetable`: Returns a formatted timetable display to the command-line interface. +## Show Weekly Timetable Feature + +User Input: `timetable show` + +The following sequence diagram shows how the timetable show feature works: +![TimetableShowFeature_Seq.png](diagrams%2FTimetableShowFeature_Seq.png) + +The following sequence diagram shows how the printTimetable operation works: +![PrintTimetable_Seq.png](diagrams%2FPrintTimetable_Seq.png) + +When the user's command is determined to be `timetable show`, the program implements the following operations: +### Function List (when timetableCommandWord == "SHOW") + +- `getCurrentSemesterModulesWeekly()`: Returns the ArrayList of ModuleWeekly for the current semester +- `showTimetable(ArrayList currentSemModulesWeekly)`: Calls the printTimetable function +- `printTimetable(ArrayList currentSemModulesWeekly)`: Prints the Weekly Timetable to the console +- `createDailyEvents(ArrayList \ncurrentSemesterModules)`: Converts the ArrayList to a +List of ArrayList for different days +- `sortByTime(ArrayList currentDayEvents)`: Sorts Events in currentDayEvents by start time, duration, then +module code, in ascending order +- `printTimetableHeader()`: Display timetable header +- `printlnHorizontalLine()`: Display horizontal line +- `printCurrentDayEvents(ArrayList currentDayEvents, day)`: Display the day's events + +### Design considerations +Aspect: How timetable is printed: + +#### Current implementation: One row per day +- Pros: Each table cell can be wider allowing each event to be printed in 1 line +- Cons: The user needs to read the time for each event to understand when they are free. + +#### Previous implementation: One row per hour, one column per day +- Pros: The user can see when they are free by day and hour easily +- Cons: The console must be wide enough for it to be usable and aesthetic. Each table cell for an event was only about +11 characters wide. + ## Search Command -The required command is implemented to give users the ability to search for modules based on their titles. +The search command is implemented to give users the ability to search for modules based on their titles. - `searchCommand(keywords)': Searches NUSModsAPI for modules containing specified keywords in the title. - `listAllModules()`: Returns all modules for parsing and identifying those containing a specified keyword. diff --git a/docs/diagrams/PrintTimetable.puml b/docs/diagrams/PrintTimetable.puml new file mode 100644 index 0000000000..3b306a7414 --- /dev/null +++ b/docs/diagrams/PrintTimetable.puml @@ -0,0 +1,102 @@ +@startuml +'https://plantuml.com/sequence-diagram + +'autonumber +'autoactivate on + + +actor Student + +participant ":TimetableView" as TV + +participant "currentDayEvents\n:ArrayList" as CDE #white + +participant "moduleService\nController\n:ModuleService\nController" as MSC #white + +box "Model" #LightBlue +participant "student:\nStudent" as S #white +participant "timetable:\nTimetable" as T #white +end box + +activate S + +opt timetableCommandWord == "SHOW" + 'timetable.getCurrentSemesterModulesWeekly() + S -> T: getCurrent\nSemester\nModulesWeekly() + activate T + T --> S: currentSem\nModulesWeekly + deactivate T + + S -> MSC: showTimetable\n(currentSem\nModulesWeekly) + activate MSC + + + MSC -> TV: printTimetable(currentSemesterModuleWeekly); + activate TV + + 'createDailyEvents(currentSemesterModules) + TV -> TV: createDailyEvents(ArrayList \ncurrentSemesterModules) + activate TV + note left + createDailyEvents converts + the ArrayList + to a List of ArrayList + for different days + end note + TV --> TV: List> weeklyTimetableByDay + deactivate TV + + + loop currentDayEvents + TV -> TV: sortByTime(ArrayList currentDayEvents) + activate TV + note left + sortByTime sorts Events + in currentDayEvents by + start time, duration, + then module code, in + ascending order + end note + TV --> TV: ArrayList currentDayEvents (sorted) + deactivate TV + end + + TV -> TV: printTimetableHeader() + activate TV + TV --> Student: display Timetable Header + TV --> TV + deactivate TV + + loop day + TV -> TV: printlnHorizontalLine() + activate TV + TV --> Student: display Horizontal Line + TV --> TV + deactivate TV + + TV -> CDE: weeklyTimetableByDay.get(day) + CDE --> TV: ArrayList currentDayEvents + + TV -> TV: printCurrentDayEvents(ArrayList \ncurrentDayEvents, day) + activate TV + TV --> Student: display the day's events + TV --> TV: + deactivate TV + end + + TV -> TV: printlnHorizontalLine() + activate TV + TV --> Student: display Horizontal Line + TV --> TV + deactivate TV + + + TV --> MSC + destroy TV + MSC --> S + deactivate MSC +end + + + +@enduml \ No newline at end of file diff --git a/docs/diagrams/PrintTimetable_Seq.png b/docs/diagrams/PrintTimetable_Seq.png new file mode 100644 index 0000000000..4b1a601fe8 Binary files /dev/null and b/docs/diagrams/PrintTimetable_Seq.png differ diff --git a/docs/team/janelleenqi.md b/docs/team/janelleenqi.md index e8606cc952..a5becf98fe 100644 --- a/docs/team/janelleenqi.md +++ b/docs/team/janelleenqi.md @@ -26,35 +26,43 @@ Highlights: Lessons are displayed by time and day and does not show days that do Credits: nil -#### 2. Modules Left Feature +#### 2. Save Timetable Feature -Feature: Added the ability to view modules left. +Feature: Saves the weekly timetable of the user throughout the program. -What it does: Allows the user to retrieve a list of modules that is in their schedule but have not been marked as -completed. +What it does: Updates the save file for the weekly timetable of the user when the user uses any features that changes +the timetable (timetable modify, recommend, shift, delete, clear). -Justification: This feature gives clarity to the user as they are able to easily view what modules they have yet to complete. +Justification: This feature allows the user to store their timetable data, so that they can built upon the same +timetable across multiple sessions. -Highlights: nil +Highlights: The timetable needed to be updated when modules were deleted, to remove those modules from the timetable. -Credits: nil +#### 3. Modules Left Feature + +Feature: Added the ability to view modules left. + +What it does: Allows the user to retrieve a list of modules that required for their major but have not been marked as +completed. + +Justification: This feature gives clarity to the user as they are able to easily view what modules they have yet to +complete for graduation. -#### 3. Modules Required Feature +#### 4. Modules Required Feature Feature: Added the ability to view modules required. What it does: Provides students with easy access to the requirements of their major, and be aware of Common Curriculum Requirements. -Justification: - -Highlights: nil - -Credits: nil +Justification: Gives students an easy access to a list of modules (and their names) they are required to take to +graduate. ### Classes Implemented #### 1. Event (and its child classes Lecture, Tutorial, Lab) +Purpose: Allow information on a lesson to be store concisely for convenience, as well as methods for comparison +between different events (for printing in order), printing and saving. #### 2. ModuleList Purpose: Provides multiple methods to use an ArrayList of Module, for easy retrieval of data (eg. ArrayList of module @@ -72,6 +80,21 @@ provided by user, ensuring optimal readability and good user experience. #### 1. Refactor Code Justification: Improved abstraction, separation of concerns and made it easier for testing -Highlights: Required an in-depth understanding of code to ensure that I am not breaking features implemented by my -teammates. +Highlights: Required an in-depth understanding of code to ensure that no features were affected. + +#### 2. Project Management + +My contribution: Created the Labels and Milestones, and a majority of Story/Task-base Issues within the Github Tracker. +Justification: Allowed my team to be clearer on what we need to accomplish, to ensure productivity. + +#### 3. Documentation +##### User Guide: +Added documentation for the features left and required +Updated documentation for the features timetable show, timetable modify, help, bye. + +##### Developer Guide: +Added implementation details of the features left, required, timetable show. + +#### 4. Fixed Bugs +- `Bye`: was case sensitive, needed to input twice to exit diff --git a/src/main/java/seedu/duke/controllers/MainController.java b/src/main/java/seedu/duke/controllers/MainController.java index 21dc550cfa..d35dd9e4e6 100644 --- a/src/main/java/seedu/duke/controllers/MainController.java +++ b/src/main/java/seedu/duke/controllers/MainController.java @@ -221,6 +221,4 @@ public void handleUserInputTillExitCommand() { - - } diff --git a/src/main/java/seedu/duke/controllers/ModuleMethodsController.java b/src/main/java/seedu/duke/controllers/ModuleMethodsController.java index 3052eb2e06..d844cdf48c 100644 --- a/src/main/java/seedu/duke/controllers/ModuleMethodsController.java +++ b/src/main/java/seedu/duke/controllers/ModuleMethodsController.java @@ -85,9 +85,17 @@ public static void computePace(String[] arguments, int completedModuleCredits, S + "Recommended Pace: " + creditsPerSem + "MCs per sem until graduation"); } + //@@author janelleenqi + /** + * Displays the list of remaining module codes. + * + * This method takes an ArrayList of module codes and prints them to the console + * after displaying a header message. + * + * @param moduleCodesLeft An ArrayList of Strings representing the remaining module codes. + * It should not be null. + */ public static void showModulesLeft(ArrayList moduleCodesLeft) { - //add parser.IsInputVal - //boolean validInput = Parser.isValidInputForCommand(commandWord, arguments); displayMessage("Modules Left: "); printModuleStringArray(moduleCodesLeft); } @@ -243,28 +251,48 @@ public static void executeClearScheduleCommand(Student student){ } + /** + * Completes the specified module for the given student. + * + * This method attempts to mark the specified module as completed for the given student. + * It checks if the module is already completed, and if so, displays an error message + * and exits the method. If the module is not found in the student's schedule planner, + * a message is displayed. If the prerequisites for the module are not met, an error + * message is displayed, and the prerequisites are shown. + * + * @param student The student for whom the module is to be completed. Must not be null. + * @param moduleCode The code of the module to be completed. Must not be null. + * @throws MissingModuleException If the module does not exist in the student's schedule planner. + * @throws FailPrereqException If the prerequisites for the module are not met. + * Displays an error message and shows the prerequisites. + * @throws RuntimeException If an unexpected InvalidPrereqException occurs (should not happen). + */ public static void completeModule(Student student, String moduleCode) { try { Module module = student.getModuleFromSchedule(moduleCode); - //if module is already completed, exit + + // if module is already completed, exit if (module.getCompletionStatus()) { UserError.displayModuleAlreadyCompleted(module.getModuleCode()); return; } student.completeModuleSchedule(moduleCode); - try{ + // update save file + try { saveSchedule(student); - }catch (IOException ignored){ - //we ignore first as GitHub actions cant save schedule on the directory + } catch (IOException ignored){ + // GitHub actions cannot save schedule on the directory } } catch (MissingModuleException e) { + // module not does exist in schedule planner displayMessage(e.getMessage()); } catch (InvalidObjectException e) { assert false; } catch (FailPrereqException e) { + // prerequisites are not met displayMessage("Prerequisites not completed for " + moduleCode); showPrereq(moduleCode, student.getMajor()); } catch (InvalidPrereqException e) { @@ -272,6 +300,14 @@ public static void completeModule(Student student, String moduleCode) { } } + /** + * Prints the required modules for a student based on their major. + * + * This method calls the printRequiredModules function in MajorRequirementsView to print required modules for + * the specified major. + * + * @param major The major of the student that will be used to print the required modules. + */ public static void getRequiredModulesForStudent(String major) { printRequiredModules(major); } diff --git a/src/main/java/seedu/duke/controllers/ModuleServiceController.java b/src/main/java/seedu/duke/controllers/ModuleServiceController.java index a9079c0921..9931f0b2ef 100644 --- a/src/main/java/seedu/duke/controllers/ModuleServiceController.java +++ b/src/main/java/seedu/duke/controllers/ModuleServiceController.java @@ -129,11 +129,19 @@ public static boolean isConfirmedToClearSchedule() { return userInput.equals("Y"); } + //@@author janelleenqi /** - * Modifies the timetable for the specified student based on user input. + * Modifies the timetable for the given student based on user commands. * - * @param student The student object. - * @throws InvalidModifyArgumentException If an invalid argument is provided. + * This method allows the user to modify the timetable for the current semester + * by processing user commands. It enters a loop to continuously accept commands + * until the user decides to exit. The modified timetable is saved after each + * successful modification. If the timetable view is available, it is printed. + * If the timetable view is unavailable, a simple guide is printed to inform the user. + * + * @param student The student for whom the timetable is to be modified. + * Must not be null. + * @throws InvalidModifyArgumentException If an invalid argument is provided during modification. */ public void modifyTimetable(Student student) throws InvalidModifyArgumentException { Timetable timetable = student.getTimetable(); @@ -172,7 +180,7 @@ public void modifyTimetable(Student student) throws InvalidModifyArgumentExcepti try { saveTimetable(student); } catch (IOException ignored){ - //we ignore first as GitHub actions cant save timetable on the directory + // GitHub actions cannott save timetable on the directory } if (timetable.timetableViewIsAvailable()) { printTimetable(currentSemModulesWeekly); @@ -187,7 +195,16 @@ public void modifyTimetable(Student student) throws InvalidModifyArgumentExcepti } } - + //@@author janelleenqi + /** + * Displays the timetable for the current semester based on the provided module weekly data. + * + * This method displays the timetable for the current semester using the ArrayList of ModuleWeekly objects to the + * user. + * + * @param currentSemesterModuleWeekly The list of ModuleWeekly objects with information about + * the timetable for the current semester + */ public void showTimetable(ArrayList currentSemesterModuleWeekly) { printTimetable(currentSemesterModuleWeekly); } diff --git a/src/main/java/seedu/duke/controllers/TimetableModifyController.java b/src/main/java/seedu/duke/controllers/TimetableModifyController.java deleted file mode 100644 index f83fbf9210..0000000000 --- a/src/main/java/seedu/duke/controllers/TimetableModifyController.java +++ /dev/null @@ -1,96 +0,0 @@ -package seedu.duke.controllers; - -import java.io.IOException; -import java.util.ArrayList; - -import seedu.duke.models.schema.ModuleWeekly; -import seedu.duke.models.schema.Student; -import seedu.duke.models.schema.Timetable; -import seedu.duke.models.schema.TimetableUserCommand; - -import seedu.duke.utils.exceptions.InvalidTimetableUserCommandException; -import seedu.duke.utils.exceptions.InvalidModifyArgumentException; -import seedu.duke.utils.exceptions.TimetableUnavailableException; -import seedu.duke.views.TimetableView; -import seedu.duke.views.Ui; - -import static seedu.duke.models.schema.Storage.saveTimetable; -import static seedu.duke.utils.TimetableParser.isExitModify; -import static seedu.duke.views.TimetableUserGuideView.println; -import static seedu.duke.views.TimetableUserGuideView.printCurrentSemModules; -import static seedu.duke.views.TimetableUserGuideView.printTTModifyDetailedLessonGuide; -import static seedu.duke.views.TimetableUserGuideView.printTTModifySimpleLessonGuide; - -public class TimetableModifyController { - - /** - * Modifies the timetable for the specified student based on user input. - * - * @param student The student object. - * @throws InvalidModifyArgumentException If an invalid argument is provided. - */ - public void modifyTimetable(Student student) throws InvalidModifyArgumentException { - Timetable timetable = student.getTimetable(); - ArrayList currentSemModulesWeekly = timetable.getCurrentSemesterModulesWeekly(); - //verify accepted timetableuser command - /* - System.out.println("List of modules in current semester: "); - if (currentSemModulesWeekly.isEmpty()) { - System.out.println("There are no modules in your current semester. " + - "Please add in modules, or generate using the 'recommend' command."); - return; - } - for (ModuleWeekly moduleWeekly : currentSemModulesWeekly) { - System.out.println(moduleWeekly.getModuleCode()); - } - System.out.println(); - - */ - - try { - printCurrentSemModules(currentSemModulesWeekly); - } catch (TimetableUnavailableException e) { - println(e.getMessage()); - } - - printTTModifyDetailedLessonGuide("Entered Timetable Modify Mode"); - - Ui ui = new Ui(); - - boolean inTimetableModifyMode = true; - while (inTimetableModifyMode) { - try { - String userInput = ui.getUserCommand("Input timetable modify command here: "); - - TimetableUserCommand currentTimetableCommand = new TimetableUserCommand(student, - currentSemModulesWeekly, userInput); - - - String[] arguments = currentTimetableCommand.getArguments(); - - //if exit - if (isExitModify(arguments)) { - inTimetableModifyMode = false; - println("Exited Timetable Modify Mode"); - continue; - } - - currentTimetableCommand.processTimetableCommand(currentSemModulesWeekly); - try { - saveTimetable(student); - } catch (IOException ignored){ - //we ignore first as GitHub actions cant save timetable on the directory - } - if (timetable.timetableViewIsAvailable()) { - TimetableView.printTimetable(currentSemModulesWeekly); - } else { - printTTModifySimpleLessonGuide("Timetable view is unavailable as modules in your " + - "current semester have no lessons yet."); - } - - } catch (InvalidTimetableUserCommandException e) { - println(e.getMessage()); - } - } - } -} diff --git a/src/main/java/seedu/duke/models/schema/Command.java b/src/main/java/seedu/duke/models/schema/Command.java index 61d14401d6..2aa6843434 100644 --- a/src/main/java/seedu/duke/models/schema/Command.java +++ b/src/main/java/seedu/duke/models/schema/Command.java @@ -1,32 +1,71 @@ package seedu.duke.models.schema; +/** + * Represents a command with its associated information such as command name, arguments, and description. + * The class provides methods to retrieve details of the command and to generate a formatted string + * for displaying the command's information. + */ public class Command { - private static final int justifyLength = 30; + private static final int JUSTIFY_LENGTH = 30; private final String commandName; private final String description; private final String arguments; + + //@@author janelleenqi + /** + * Constructs a Command object with the specified command name and description. + * + * @param commandName The name of the command. Must not be null. + * @param description The description of the command. Must not be null. + */ public Command(String commandName, String description) { this.commandName = commandName; this.description = description; this.arguments = ""; } + + /** + * Constructs a Command object with the specified command name, arguments, and description. + * + * @param commandName The name of the command. Must not be null. + * @param arguments The arguments of the command. Must not be null. + * @param description The description of the command. Must not be null. + */ public Command(String commandName, String arguments, String description) { this.commandName = commandName; this.arguments = arguments; this.description = description; } + //@@author janelleenqi + /** + * Gets the name of the command. + * + * @return The command name. + */ public String getCommandName() { return commandName; } + //@@author janelleenqi + /** + * Gets the description of the command. + * + * @return The command description. + */ public String getDescription() { return description; } + //@@author janelleenqi + /** + * Generates a formatted string representation of the command for display purposes. + * + * @return The formatted string containing the command name, arguments, and description. + */ @Override public String toString() { - int rightPadding = justifyLength - commandName.length() - arguments.length(); + int rightPadding = JUSTIFY_LENGTH - commandName.length() - arguments.length(); return commandName + " " + arguments + " ".repeat(rightPadding) + description; } } diff --git a/src/main/java/seedu/duke/models/schema/CommandManager.java b/src/main/java/seedu/duke/models/schema/CommandManager.java index d461a69bf8..20e7df85a3 100644 --- a/src/main/java/seedu/duke/models/schema/CommandManager.java +++ b/src/main/java/seedu/duke/models/schema/CommandManager.java @@ -58,7 +58,6 @@ private void addCurrentCommands() { * @param command The command to retrieve the description for. * @return The description of the command, or "Command not recognized" if the command is not in the HashMap. */ - public String getDescription(String commandName) { for (Command command : commandArrayList) { if (commandName.equals(command.getCommandName())) { @@ -70,7 +69,6 @@ public String getDescription(String commandName) { } - /** * Retrieves a list of all available commands. * diff --git a/src/main/java/seedu/duke/models/schema/Event.java b/src/main/java/seedu/duke/models/schema/Event.java index ca502d7a06..4dd7f45c23 100644 --- a/src/main/java/seedu/duke/models/schema/Event.java +++ b/src/main/java/seedu/duke/models/schema/Event.java @@ -1,8 +1,12 @@ package seedu.duke.models.schema; -import java.util.ArrayList; import java.util.List; +//@@author janelleenqi +/** + * Represents a scheduled event, with details like the day, start time, + * duration, module code, and utility methods for time calculations and comparisons. + */ public class Event { private static final List days = List.of("monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"); @@ -11,6 +15,14 @@ public class Event { private int duration; private String moduleCode; + /** + * Constructs an Event object with the specified day, start time, duration, and module code. + * + * @param day The day of the event. Must not be null. + * @param startTime The start time of the event. + * @param duration The duration of the event. + * @param moduleCode The module code associated with the event. Must not be null. + */ public Event(String day, int startTime, int duration, String moduleCode) { this.day = day; this.startTime = startTime; @@ -18,25 +30,29 @@ public Event(String day, int startTime, int duration, String moduleCode) { this.moduleCode = moduleCode; } - public ArrayList getByHour() { - ArrayList eventByHour = new ArrayList<>(); - int eventDurationLeft = getDuration(); - while (eventDurationLeft > 0) { - String eventTimeData = getStartTime() + " " + (getStartTime() + 1); - eventByHour.add(eventTimeData); - eventDurationLeft -= 1; - } - return eventByHour; - } - + /** + * Gets the start time of the event. + * + * @return The start time. + */ public int getStartTime() { return startTime; } + /** + * Gets the duration of the event. + * + * @return The duration. + */ public int getDuration() { return duration; } + /** + * Gets the day of the event as an integer index (0 for Monday, 1 for Tuesday, etc.). + * + * @return The index of the day. + */ public int getDayInt() { String lowercaseDay = day.toLowerCase(); if (!days.contains(lowercaseDay)) { @@ -46,14 +62,29 @@ public int getDayInt() { return days.indexOf(lowercaseDay); } + /** + * Gets the day of the event. + * + * @return The day. + */ public String getDay() { return day; } + /** + * Gets the event type (empty string for general events). + * + * @return The event type. + */ public String getEventType() { return ""; } + /** + * Gets the module code associated with the event. + * + * @return The module code. + */ public String getModuleCode() { return moduleCode; } @@ -107,6 +138,12 @@ private static String getTime(int timePeriod) { } } + /** + * Checks if two events are equal by comparing their day, start time, duration, and module code. + * + * @param event The event to compare with. + * @return true if the events are equal, false otherwise. + */ public boolean equals(Event event) { if (this.getDayInt() != event.getDayInt()) { return false; @@ -127,6 +164,13 @@ public boolean equals(Event event) { return true; } + /** + * Checks if the current event is earlier than another event based on start time, duration, + * and module code. + * + * @param event The event to compare with. + * @return true if the current event is earlier, false otherwise. + */ public boolean isEarlierThan(Event event) { // compare startTime if (this.startTime < event.getStartTime()) { @@ -168,12 +212,22 @@ public boolean isEarlierThan(Event event) { return false; // no swap in bubble sort } + /** + * Generates a string representation of the event, which is the module code. + * + * @return The string representation of the event. + */ @Override public String toString() { return moduleCode; } + /** + * Generates a string representation of the event for saving purposes, which is the module code. + * + * @return The string representation of the event for saving. + */ public String toSave() { return moduleCode; } diff --git a/src/main/java/seedu/duke/models/schema/Lab.java b/src/main/java/seedu/duke/models/schema/Lab.java index 4c6d6ae107..1760b12dfd 100644 --- a/src/main/java/seedu/duke/models/schema/Lab.java +++ b/src/main/java/seedu/duke/models/schema/Lab.java @@ -1,32 +1,41 @@ package seedu.duke.models.schema; -import java.util.ArrayList; - +//@@author janelleenqi +/** + * Represents a Lab that extends the Event class. + */ public class Lab extends Event{ + private static final String EVENT_TYPE = "Lab"; + + /** + * Constructs a Lab object with the specified day, start time, duration, and module code. + * + * @param day The day of the lab session. Must not be null. + * @param startTime The start time of the lab session. + * @param duration The duration of the lab session. + * @param moduleCode The module code associated with the lab session. Must not be null. + */ public Lab(String day, int startTime, int duration, String moduleCode) { super(day, startTime, duration, moduleCode); } - @Override - public ArrayList getByHour () { - ArrayList tutorialByHour = new ArrayList<>(); - - int eventDurationLeft = getDuration(); - while (eventDurationLeft > 0) { - String tutorialTimeData = "T " + getStartTime() + " " + (getStartTime() + 1); - tutorialByHour.add(tutorialTimeData); - eventDurationLeft -= 1; - } - - return tutorialByHour; - } - + /** + * Gets the type of the event, which is "Lab". + * + * @return The event type. + */ @Override public String getEventType() { - return "Lab"; + return EVENT_TYPE; } + /** + * Checks if this Lab object is equal to another Event object by comparing their common attributes. + * + * @param event The event to compare with. + * @return true if the events are equal, false otherwise. + */ @Override public boolean equals(Event event) { boolean isSameEvent = super.equals(event); @@ -42,11 +51,22 @@ public boolean equals(Event event) { return true; } + /** + * Generates a string representation of this Lab, including module code, event type, and time range. + * + * @return The string representation of this Lab. + */ @Override public String toString() { return super.toString() + " " + getEventType() + " " + getTime(getStartTime(), getDuration()); } + /** + * Generates a string representation of this Lab for saving purposes, including module code, + * event type, start time, duration, and day. + * + * @return The string representation of this Lab for saving. + */ @Override public String toSave() { return super.toSave() + " " + getEventType() + " " + getStartTime() + " " + getDuration() + " " + getDay(); diff --git a/src/main/java/seedu/duke/models/schema/Lecture.java b/src/main/java/seedu/duke/models/schema/Lecture.java index c52c9f5f22..48d78982ba 100644 --- a/src/main/java/seedu/duke/models/schema/Lecture.java +++ b/src/main/java/seedu/duke/models/schema/Lecture.java @@ -1,32 +1,41 @@ package seedu.duke.models.schema; -import java.util.ArrayList; - +//@@author janelleenqi +/** + * Represents a Lecture that extends the Event class. + */ public class Lecture extends Event{ + private static final String EVENT_TYPE = "Lecture"; + + /** + * Constructs a Lecture object with the specified day, start time, duration, and module code. + * + * @param day The day of the lab session. Must not be null. + * @param startTime The start time of the lab session. + * @param duration The duration of the lab session. + * @param moduleCode The module code associated with the lab session. Must not be null. + */ public Lecture(String day, int startTime, int duration, String moduleCode) { super(day, startTime, duration, moduleCode); } - @Override - public ArrayList getByHour () { - ArrayList tutorialByHour = new ArrayList<>(); - - int eventDurationLeft = getDuration(); - while (eventDurationLeft > 0) { - String tutorialTimeData = "T " + getStartTime() + " " + (getStartTime() + 1); - tutorialByHour.add(tutorialTimeData); - eventDurationLeft -= 1; - } - - return tutorialByHour; - } - + /** + * Gets the type of the event, which is "Lecture". + * + * @return The event type. + */ @Override public String getEventType() { - return "Lecture"; + return EVENT_TYPE; } + /** + * Checks if this Lecture object is equal to another Event object by comparing their common attributes. + * + * @param event The event to compare with. + * @return true if the events are equal, false otherwise. + */ @Override public boolean equals(Event event) { boolean isSameEvent = super.equals(event); @@ -42,11 +51,22 @@ public boolean equals(Event event) { return true; } + /** + * Generates a string representation of this Lecture, including module code, event type, and time range. + * + * @return The string representation of this Lecture. + */ @Override public String toString() { return super.toString() + " " + getEventType() + " " + getTime(getStartTime(), getDuration()); } + /** + * Generates a string representation of this Lecture for saving purposes, including module code, + * event type, start time, duration, and day. + * + * @return The string representation of this Lecture for saving. + */ @Override public String toSave() { return super.toSave() + " " + getEventType() + " " + getStartTime() + " " + getDuration() + " " + getDay(); diff --git a/src/main/java/seedu/duke/models/schema/Module.java b/src/main/java/seedu/duke/models/schema/Module.java index bdedfbe171..b404d9b17c 100644 --- a/src/main/java/seedu/duke/models/schema/Module.java +++ b/src/main/java/seedu/duke/models/schema/Module.java @@ -83,15 +83,25 @@ public String getModuleCode() { return this.moduleCode; } + //@@author janelleenqi + /** + * Checks if this module is equal to another module by comparing their module codes. + * + * @param module The module to compare with. + * @return true if the modules have the same module code, false otherwise. + */ public boolean equals(Module module) { return this.moduleCode.equals(module.moduleCode); } - + //@@author janelleenqi + /** + * Generates a string representation of this module, which is its module code. + * + * @return The string representation of this module. + */ @Override public String toString() { return this.moduleCode; } - - } diff --git a/src/main/java/seedu/duke/models/schema/ModuleList.java b/src/main/java/seedu/duke/models/schema/ModuleList.java index 7f7ceac51f..58164809ca 100644 --- a/src/main/java/seedu/duke/models/schema/ModuleList.java +++ b/src/main/java/seedu/duke/models/schema/ModuleList.java @@ -4,10 +4,10 @@ import java.util.ArrayList; import java.util.HashMap; -import static seedu.duke.views.ModuleInfoView.printModuleArray; - +//@@author janelleenqi /** * The ModuleList class represents a list of modules and provides various methods for managing modules. + * It includes functionality for adding, deleting, and retrieving modules from the list. */ public class ModuleList { private ArrayList mainModuleList; @@ -24,7 +24,6 @@ public ModuleList() { * * @param moduleCodes A space-separated string of module codes. */ - public ModuleList(String moduleCodes) { this(); if (moduleCodes == null || moduleCodes.isEmpty()) { @@ -82,15 +81,6 @@ public ArrayList getCompletedModuleCodes(){ return completedModuleCodes; } - public ModuleList newModuleListOfCompleted(){ - ModuleList newModuleList = new ModuleList(); - for (Module module: mainModuleList){ - if (module.getCompletionStatus()) { - newModuleList.addModule(module); - } - } - return newModuleList; - } /** * Creates and returns a new HashMap containing completed modules from the main module list, indexed by module code. @@ -144,10 +134,6 @@ public void deleteModule (Module module) { /** * Deletes a module from the main module list by its module code. * - * This method attempts to retrieve the module with the specified module code and then deletes - * it from the main module list if found. If the module does not exist or if an exception is - * thrown during the process, the method returns without making any changes to the ModuleList. - * * @param moduleCode The module code of the module to be deleted. */ public void deleteModuleByCode (String moduleCode) { @@ -159,6 +145,12 @@ public void deleteModuleByCode (String moduleCode) { } } + /** + * Checks if a module exists in the main module list. + * + * @param module The module to check for existence. + * @return true if the module exists, false otherwise. + */ public boolean exists(Module module) { if (mainModuleList == null) { return false; @@ -177,8 +169,8 @@ public boolean exists(Module module) { /** * Checks if a module with the specified module code exists in the main module list. * - * @param moduleCodeA The module code to check for in the main module list. - * @return true if a module with the specified module code exists, false otherwise. + * @param moduleCodeA The module code to check for existence. + * @return true if the module with the specified code exists, false otherwise. * @throws InvalidObjectException If the main module list is null or the provided module code is null. */ public boolean existsByCode(String moduleCodeA) throws InvalidObjectException { @@ -214,22 +206,16 @@ public Module getModule(String moduleCode) throws InvalidObjectException { throw new InvalidObjectException("Module does not exist, please add it in your schedule."); } - public Module getModule(Module module) throws InvalidObjectException { - for (Module currentModule: mainModuleList) { - if (currentModule.equals(module)) { - return currentModule; - } - } - throw new InvalidObjectException("Module does not exist."); - } + /** + * Gets the size of the main module list. + * + * @return The number of modules in the list. + */ public int size() { return mainModuleList.size(); } - public int getIndex(Module module) { - return mainModuleList.indexOf(module); - } /** * Finds the index of a module in the main module list by its module code. @@ -262,8 +248,4 @@ public int getIndexByString(String moduleCode) { public Module getModuleByIndex(int index) { return this.mainModuleList.get(index); } - - public void printMainModuleList(){ - printModuleArray(mainModuleList); - } } diff --git a/src/main/java/seedu/duke/models/schema/ModuleWeekly.java b/src/main/java/seedu/duke/models/schema/ModuleWeekly.java index 39bc2bcd13..34fff88796 100644 --- a/src/main/java/seedu/duke/models/schema/ModuleWeekly.java +++ b/src/main/java/seedu/duke/models/schema/ModuleWeekly.java @@ -64,7 +64,13 @@ public void setDay(String day) { this.day = day; } - + //@@author janelleenqi + /** + * Checks if a specific event exists in this ModuleWeekly. + * + * @param newEvent The event to check for existence. + * @return true if the event exists, false otherwise. + */ public boolean exists(Event newEvent) { for (Event existingEvent : lessons) { if (newEvent.equals(existingEvent)) { @@ -74,10 +80,21 @@ public boolean exists(Event newEvent) { return false; } + /** + * Checks if there are any lessons in the weekly schedule. + * + * @return true if there are lessons, false otherwise. + */ public boolean haveLessons() { return !lessons.isEmpty(); } + /** + * Checks if an event can be added to the timetable and adds it if possible. + * + * @param event The event to add. + * @return true if the event can be added, false otherwise. + */ public boolean canAddToTimetable(Event event) { if (this.exists(event)) { UserError.displayLessonAlreadyAdded(event); @@ -86,6 +103,13 @@ public boolean canAddToTimetable(Event event) { return true; } + /** + * Adds a lecture to the weekly timetable. + * + * @param day The day of the lecture. + * @param time The time of the lecture. + * @param duration The duration of the lecture. + */ public void addLecture(String day, int time, int duration) { Event newLecture = new Lecture(day, time, duration, moduleCode); if (canAddToTimetable(newLecture)) { @@ -93,6 +117,13 @@ public void addLecture(String day, int time, int duration) { } } + /** + * Adds a tutorial to the weekly timetable. + * + * @param day The day of the tutorial. + * @param time The time of the tutorial. + * @param duration The duration of the tutorial. + */ public void addTutorial(String day, int time, int duration) { Event newTutorial = new Tutorial(day, time, duration, moduleCode); if (canAddToTimetable(newTutorial)) { @@ -100,6 +131,13 @@ public void addTutorial(String day, int time, int duration) { } } + /** + * Adds a lab to the weekly timetable. + * + * @param day The day of the tutorial. + * @param time The time of the tutorial. + * @param duration The duration of the tutorial. + */ public void addLab(String day, int time, int duration) { Event newLab = new Lab(day, time, duration, moduleCode); if (canAddToTimetable(newLab)) { @@ -108,16 +146,21 @@ public void addLab(String day, int time, int duration) { } + /** + * Clears all lessons from the weekly timetable. + */ public void clearLessons() { lessons.clear(); } + /** + * Gets the ArrayList of events representing the weekly timetable. + * + * @return The ArrayList of events. + */ public ArrayList getWeeklyTimetable() { return lessons; } - - - } diff --git a/src/main/java/seedu/duke/models/schema/Schedule.java b/src/main/java/seedu/duke/models/schema/Schedule.java index df0fdd84c4..a232293d7e 100644 --- a/src/main/java/seedu/duke/models/schema/Schedule.java +++ b/src/main/java/seedu/duke/models/schema/Schedule.java @@ -78,6 +78,11 @@ public static int getMaximumSemesters() { return MAXIMUM_SEMESTERS; } + /** + * Retrieves the ModuleList for modules planned in the schedule. + * + * @return The ModuleList containing the planned modules. + */ public ModuleList getModulesPlanned() { return modulesPlanned; } @@ -398,10 +403,20 @@ private void shiftModuleEarlier(String module, int targetSem, int indexToAdd, in + module); } + //@@author janelleenqi + /** + * Retrieves a specific module from the planned modules based on its module code. + * + * @param moduleCode The module code of the module to retrieve. + * @return The Module object with the specified module code. + * @throws InvalidObjectException If the module with the given code is not found. + */ public Module getModule(String moduleCode) throws InvalidObjectException { return modulesPlanned.getModule(moduleCode); } + //@@author + /** * Completes the given module, checking prerequisites if applicable. * @author ryanlohyr diff --git a/src/main/java/seedu/duke/models/schema/Storage.java b/src/main/java/seedu/duke/models/schema/Storage.java index c816a29508..121c7cce4d 100644 --- a/src/main/java/seedu/duke/models/schema/Storage.java +++ b/src/main/java/seedu/duke/models/schema/Storage.java @@ -252,6 +252,16 @@ public ArrayList loadStudentDetails() throws MissingFileException, Corru } } + //@@author janelleenqi + /** + * Loads timetable user commands from the timetable.txt save file and processes them to update the student's + * timetable. + * + * @param student The student whose timetable is being updated. + * @return An ArrayList of TimetableUserCommand objects representing the loaded commands. + * @throws MissingFileException If the timetable file is missing. + * @throws CorruptedFileException If the timetable file is corrupted or contains invalid commands. + */ public ArrayList loadTimetable(Student student) throws MissingFileException, CorruptedFileException { @@ -297,6 +307,14 @@ public ArrayList loadTimetable(Student student) } + //@@author janelleenqi + /** + * Adds events to the student's timetable based on the provided timetable user commands. + * + * @param timetableUserCommands An ArrayList of TimetableUserCommand objects representing the commands to process. + * @param student The student whose timetable is being updated. + * @throws CorruptedFileException If the provided timetable user commands are corrupted or contain invalid commands. + */ public void addEventsToStudentTimetable(ArrayList timetableUserCommands, Student student) throws CorruptedFileException { ArrayList currentSemModulesWeekly = student.getTimetable().getCurrentSemesterModulesWeekly(); @@ -311,6 +329,8 @@ public void addEventsToStudentTimetable(ArrayList timetabl } } + //@@author + public void saveStudentDetails (Student student) throws IOException { String studentDetailsFilePath = userDirectory + "/data/studentDetails.txt"; diff --git a/src/main/java/seedu/duke/models/schema/Student.java b/src/main/java/seedu/duke/models/schema/Student.java index d1645bbd23..c1453c3e67 100644 --- a/src/main/java/seedu/duke/models/schema/Student.java +++ b/src/main/java/seedu/duke/models/schema/Student.java @@ -19,15 +19,12 @@ import static seedu.duke.utils.errors.HttpError.displaySocketError; import static seedu.duke.views.CommandLineView.displaySuccessfulCompleteMessage; import static seedu.duke.views.TimetableUserGuideView.addOrRecommendGuide; -//import static seedu.duke.views.TimetableUserGuideView.addOrRecommendGuide; -//import static seedu.duke.views.UserGuideView.timetableModifySuccessful; /** * The Student class represents a student with a name, major, and module schedule. */ public class Student { - private static boolean intitialise; private static int counter; private String name; private String major; @@ -37,7 +34,7 @@ public class Student { private ArrayList majorModuleCodes; private ModuleList currentSemesterModules; private Timetable timetable; - //private ArrayList currentSemesterModulesWeekly; + /** * Constructs a student with a name, major, and module schedule. @@ -239,6 +236,13 @@ public void clearAllModulesFromSchedule() { } //@@author janelleenqi + /** + * Retrieves a module from the schedule planner based on its module code. + * + * @param moduleCode The module code of the module to retrieve. + * @return The Module object with the specified module code. + * @throws MissingModuleException If the module with the given code is not found in the schedule. + */ public Module getModuleFromSchedule(String moduleCode) throws MissingModuleException { try { return schedule.getModule(moduleCode); @@ -248,11 +252,9 @@ public Module getModuleFromSchedule(String moduleCode) throws MissingModuleExcep } } - public boolean completionStatusModuleSchedule(Module module) { - return module.getCompletionStatus(); - } - //@@author + + public String getYear() { return year; } @@ -262,15 +264,11 @@ public void setYear(String year) { } - + //@@author janelleenqi /** - * Retrieves the module codes that are left to be completed in the major's curriculum. - *

- * This method compares the list of major module codes with the list of completed module codes - * in the current schedule. It returns a list of module codes that are still left to be completed - * as per the major's curriculum. + * Retrieves the module codes of the modules that are left to be completed based on the major's requirements. * - * @return An ArrayList of Strings representing module codes that are left to be completed. + * @return An ArrayList of module codes representing the modules that are left to be completed. */ public ArrayList getModuleCodesLeft() { ArrayList moduleCodesLeft = new ArrayList(); @@ -284,18 +282,33 @@ public ArrayList getModuleCodesLeft() { return moduleCodesLeft; } + /** + * Retrieves the module codes associated with the major's requirements. + * + * @return An ArrayList of module codes representing the major's module requirements. + */ public ArrayList getMajorModuleCodes() { return majorModuleCodes; } + /** + * Retrieves the list of modules that are planned for a specific purpose or context. + * + * @return The ModuleList containing the planned modules. + */ public ModuleList getModulesPlanned() { return schedule.getModulesPlanned(); } + /** + * Prints the schedule, displaying the main module list. + */ public void printSchedule() { this.schedule.printMainModuleList(); } + //@@author + /** * Sets the current semester modules for the student based on their year and semester. * diff --git a/src/main/java/seedu/duke/models/schema/Timetable.java b/src/main/java/seedu/duke/models/schema/Timetable.java index 742d032426..2122446379 100644 --- a/src/main/java/seedu/duke/models/schema/Timetable.java +++ b/src/main/java/seedu/duke/models/schema/Timetable.java @@ -23,10 +23,16 @@ public void removeFromCurrentSemesterModulesWeekly(ModuleWeekly module) { currentSemesterModulesWeekly.remove(module); } + //@@author janelleenqi + /** + * Removes all ModuleWeekly from the current semester's weekly schedule. + */ public void removeAll() { currentSemesterModulesWeekly = new ArrayList<>(); } + //@@author + public ArrayList getCurrentSemesterModulesWeekly() { return currentSemesterModulesWeekly; } @@ -48,9 +54,13 @@ public void printCurrentSemesterModulesWeekly(Student student) { } } - - - + //@@author janelleenqi + /** + * Checks if there are any lessons in the current semester's weekly schedule, indicating the availability + * of a timetable view. + * + * @return true if there are lessons present, indicating timetable view can be printed, else otherwise. + */ public boolean timetableViewIsAvailable() { for (ModuleWeekly moduleWeekly : currentSemesterModulesWeekly) { if (moduleWeekly.haveLessons()) { @@ -60,6 +70,7 @@ public boolean timetableViewIsAvailable() { return false; } + //@@author /** @@ -134,6 +145,11 @@ public void lessonsController(String lessonType, int indexOfModule, int time, in } + /** + * Retrieves the timetable associated with the current user or context. + * + * @return The Timetable object representing the timetable. + */ public Timetable getTimetable() { return timetable; } diff --git a/src/main/java/seedu/duke/models/schema/TimetableUserCommand.java b/src/main/java/seedu/duke/models/schema/TimetableUserCommand.java index 4c2926fdb8..a6cfb567c7 100644 --- a/src/main/java/seedu/duke/models/schema/TimetableUserCommand.java +++ b/src/main/java/seedu/duke/models/schema/TimetableUserCommand.java @@ -14,7 +14,11 @@ import static seedu.duke.utils.TimetableParser.parseDuration; import static seedu.duke.utils.TimetableParser.parseDay; - +//@@author janelleenqi +/** + * The TimetableUserCommand class represents a user command related to the timetable and provides methods to process + * and validate the user input. + */ public class TimetableUserCommand { private static final String ERROR_INVALID_NUMBER_OF_ARGUMENTS = "Invalid Number of Arguments"; @@ -24,15 +28,20 @@ public class TimetableUserCommand { private static final int NUMBER_OF_ARGUMENTS_LESSON = 5; private static final String DELIMITER = " "; - //private final String userTimetableInput; - //private final String commandWord; - private Student student; private ArrayList currentSemesterModulesWeekly; private String[] arguments; - //private final boolean isValid; + /** + * Constructs a TimetableUserCommand object with the specified student, current semester modules weekly, + * and user timetable input. + * + * @param student The student associated with the command. + * @param currentSemesterModulesWeekly The list of current semester modules weekly. + * @param userTimetableInput The user input related to the timetable command. + * @throws InvalidTimetableUserCommandException If there is an issue with the user command. + */ public TimetableUserCommand(Student student, ArrayList currentSemesterModulesWeekly, String userTimetableInput) throws InvalidTimetableUserCommandException { @@ -92,7 +101,12 @@ private void clearNullArguments() throws InvalidTimetableUserCommandException { } - + /** + * Processes the timetable command, lessons clear and lessons modification. + * + * @param currentSemesterModulesWeekly The list of current semester modules weekly. + * @throws InvalidTimetableUserCommandException If there is an issue with the user command. + */ public void processTimetableCommand(ArrayList currentSemesterModulesWeekly) throws InvalidTimetableUserCommandException { @@ -111,6 +125,12 @@ public void processTimetableCommand(ArrayList currentSemesterModul processTimetableCommandLesson(currentSemesterModulesWeekly); } + /** + * Processes the timetable command related to lessons modification. + * + * @param currentSemesterModulesWeekly The list of current semester modules weekly. + * @throws InvalidTimetableUserCommandException If there is an issue with the user command. + */ public void processTimetableCommandLesson(ArrayList currentSemesterModulesWeekly) throws InvalidTimetableUserCommandException { @@ -147,7 +167,11 @@ public void processTimetableCommandLesson(ArrayList currentSemeste } } - + /** + * Retrieves the arguments of the timetable user command. + * + * @return The array of arguments. + */ public String[] getArguments() { return arguments; } diff --git a/src/main/java/seedu/duke/models/schema/Tutorial.java b/src/main/java/seedu/duke/models/schema/Tutorial.java index ed63a06107..fac9aacc40 100644 --- a/src/main/java/seedu/duke/models/schema/Tutorial.java +++ b/src/main/java/seedu/duke/models/schema/Tutorial.java @@ -1,33 +1,40 @@ package seedu.duke.models.schema; -import java.util.ArrayList; - +//@@author janelleenqi +/** + * Represents a Tutorial that extends the Event class. + */ public class Tutorial extends Event { + private static final String EVENT_TYPE = "Tutorial"; + /** + * Constructs a Tutorial object with the specified day, start time, duration, and module code. + * + * @param day The day of the lab session. Must not be null. + * @param startTime The start time of the lab session. + * @param duration The duration of the lab session. + * @param moduleCode The module code associated with the lab session. Must not be null. + */ public Tutorial(String day, int startTime, int duration, String moduleCode) { super(day, startTime, duration, moduleCode); } - @Override - public ArrayList getByHour () { - ArrayList tutorialByHour = new ArrayList<>(); - - int eventDurationLeft = getDuration(); - while (eventDurationLeft > 0) { - String tutorialTimeData = "T " + getStartTime() + " " + (getStartTime() + 1); - tutorialByHour.add(tutorialTimeData); - eventDurationLeft -= 1; - } - - return tutorialByHour; - } - - + /** + * Gets the type of the event, which is "Tutorial". + * + * @return The event type. + */ @Override public String getEventType() { - return "Tutorial"; + return EVENT_TYPE; } + /** + * Checks if this Tutorial object is equal to another Event object by comparing their common attributes. + * + * @param event The event to compare with. + * @return true if the events are equal, false otherwise. + */ @Override public boolean equals(Event event) { boolean isSameEvent = super.equals(event); @@ -43,11 +50,22 @@ public boolean equals(Event event) { return true; } + /** + * Generates a string representation of this Tutorial, including module code, event type, and time range. + * + * @return The string representation of this Tutorial. + */ @Override public String toString() { return super.toString() + " " + getEventType() + " " + getTime(getStartTime(), getDuration()); } + /** + * Generates a string representation of this Tutorial for saving purposes, including module code, + * event type, start time, duration, and day. + * + * @return The string representation of this Tutorial for saving. + */ @Override public String toSave() { return super.toSave() + " " + getEventType() + " " + getStartTime() + " " + getDuration() + " " + getDay(); diff --git a/src/main/java/seedu/duke/models/schema/UserCommand.java b/src/main/java/seedu/duke/models/schema/UserCommand.java index 89139694c8..47bfe8c3fa 100644 --- a/src/main/java/seedu/duke/models/schema/UserCommand.java +++ b/src/main/java/seedu/duke/models/schema/UserCommand.java @@ -19,8 +19,13 @@ import static seedu.duke.controllers.ModuleMethodsController.completeModule; import static seedu.duke.controllers.ModuleMethodsController.getRequiredModulesForStudent; +/** + * The UserCommand class represents a command entered by the user and provides methods to process and execute the + * command. + */ public class UserCommand implements UserCommandWord { + //@@author janelleenqi private final String userInput; private final String commandWord; private final String[] arguments; @@ -28,6 +33,11 @@ public class UserCommand implements UserCommandWord { private CommandManager commandManager; + /** + * Constructs a UserCommand object with the specified user input and validates it. + * + * @param userInput The user input representing the command. + */ public UserCommand(String userInput) { this.userInput = userInput.trim(); commandWord = parseCommand(userInput); @@ -58,6 +68,11 @@ public UserCommand() { isValid = false; } + /** + * Checks if the UserCommand is valid. + * + * @return true if the command is valid, false otherwise. + */ public boolean isValid() { return isValid; } @@ -79,6 +94,11 @@ public boolean equals(Object obj) { return super.equals(obj); } + /** + * Checks if the command is an close program command. + * + * @return true if the command is an exit command, false otherwise. + */ public boolean isBye() { if (commandWord == null) { return false; @@ -91,6 +111,13 @@ public boolean isBye() { return this.commandWord.equalsIgnoreCase(UserCommandWord.EXIT_COMMAND); } + //@@author + + /** + * Processes and executes the user command based on the command word. + * + * @param student The student object to perform operations on. + */ public void processCommand(Student student) { switch (commandWord) { case UserCommandWord.LEFT_COMMAND: { diff --git a/src/main/java/seedu/duke/utils/TimetableParser.java b/src/main/java/seedu/duke/utils/TimetableParser.java index d4df7c0073..18ec58cd08 100644 --- a/src/main/java/seedu/duke/utils/TimetableParser.java +++ b/src/main/java/seedu/duke/utils/TimetableParser.java @@ -14,7 +14,6 @@ import static seedu.duke.utils.Parser.isDayValid; public class TimetableParser { - private static final String ERROR_MODULE_DOES_NOT_EXIST = " does not exist in your schedule."; private static final String ERROR_INVALID_LESSON_TYPE = "Invalid Lesson Type. Lesson Types available: Lecture, " + "Tutorial, Lab. "; @@ -141,6 +140,7 @@ public static boolean isModifyValid(String[] arguments, ArrayList return false; } + //@@author janelleenqi /** * Checks if a module with a given module code exists in the current semester modules. * @author @rohitcube diff --git a/src/main/java/seedu/duke/utils/exceptions/InvalidTimetableUserCommandException.java b/src/main/java/seedu/duke/utils/exceptions/InvalidTimetableUserCommandException.java index 4639b5a911..dace326f37 100644 --- a/src/main/java/seedu/duke/utils/exceptions/InvalidTimetableUserCommandException.java +++ b/src/main/java/seedu/duke/utils/exceptions/InvalidTimetableUserCommandException.java @@ -1,6 +1,16 @@ package seedu.duke.utils.exceptions; +//@@author janelleenqi +/** + * This exception is thrown to indicate that a timetable user command is invalid. + * It may occur due to invalid user input for timetable, missing information, etc. + */ public class InvalidTimetableUserCommandException extends Exception { + /** + * Constructs a new `InvalidTimetableUserCommandException` with the specified detail message. + * + * @param message the detail message (which is saved for later retrieval by the `getMessage()` method) + */ public InvalidTimetableUserCommandException(String message) { super(message + "\nPlease enter in the format: [moduleCode] [lessonType] [startTime] [duration] [day]\n " + "If you wish to clear lessons for a module, enter: [moduleCode] clear\n If you with " + diff --git a/src/main/java/seedu/duke/utils/exceptions/TimetableUnavailableException.java b/src/main/java/seedu/duke/utils/exceptions/TimetableUnavailableException.java index c7eb684d6f..0846101556 100644 --- a/src/main/java/seedu/duke/utils/exceptions/TimetableUnavailableException.java +++ b/src/main/java/seedu/duke/utils/exceptions/TimetableUnavailableException.java @@ -1,9 +1,10 @@ package seedu.duke.utils.exceptions; +//@@author janelleenqi +/** + * This exception is thrown to indicate that the timetable view is unavailable. + */ public class TimetableUnavailableException extends Exception { - public TimetableUnavailableException() { - super(); - } public TimetableUnavailableException(String message) { super(message); diff --git a/src/main/java/seedu/duke/views/MajorRequirementsView.java b/src/main/java/seedu/duke/views/MajorRequirementsView.java index 90ef42062c..5268159af8 100644 --- a/src/main/java/seedu/duke/views/MajorRequirementsView.java +++ b/src/main/java/seedu/duke/views/MajorRequirementsView.java @@ -1,5 +1,6 @@ package seedu.duke.views; +//@@author janelleenqi /** * The MajorRequirementsView class provides methods to print the required modules for specific majors. */ diff --git a/src/main/java/seedu/duke/views/SemesterPlannerView.java b/src/main/java/seedu/duke/views/SemesterPlannerView.java index 93b8c6c030..658eee8892 100644 --- a/src/main/java/seedu/duke/views/SemesterPlannerView.java +++ b/src/main/java/seedu/duke/views/SemesterPlannerView.java @@ -5,6 +5,9 @@ import seedu.duke.models.schema.Schedule; +/** + * The SemesterPlannerView class provides methods to display and print the semester planner. + */ public class SemesterPlannerView { private static void print(String output) { System.out.print(output); @@ -14,6 +17,11 @@ private static void println() { System.out.println(); } + /** + * Displays the schedule based on the provided schedule object. + * + * @param schedule The Schedule object containing the semester planner information. + */ public static void displaySchedule (Schedule schedule){ int[] modulesPerSem = schedule.getModulesPerSem(); ModuleList modulesPlanned = schedule.getModulesPlanned(); @@ -35,6 +43,12 @@ public static void displaySchedule (Schedule schedule){ } } + /** + * Prints the semester planner based on the provided modulesPerSem and modulesPlanned. + * + * @param modulesPerSem The array representing the number of modules per semester. + * @param modulesPlanned The ModuleList containing the planned modules. + */ public static void printSemesterPlanner(int[] modulesPerSem, ModuleList modulesPlanned) { int moduleCounter = 0; int maxModulesPerColumn = 5; @@ -54,6 +68,13 @@ public static void printSemesterPlanner(int[] modulesPerSem, ModuleList modulesP } } + //@@author janelleenqi + /** + * Retrieves the completion status indicator for a module, 'O' for completed, 'X' for not completed. + * + * @param module The Module object for which to determine the completion status. + * @return The completion status indicator ('O' or 'X'). + */ private static String getCompletionStatusForPrinting(Module module) { if (module.getCompletionStatus()) { return "O"; diff --git a/src/main/java/seedu/duke/views/TimetableUserGuideView.java b/src/main/java/seedu/duke/views/TimetableUserGuideView.java index 2049ca8189..81fad06a85 100644 --- a/src/main/java/seedu/duke/views/TimetableUserGuideView.java +++ b/src/main/java/seedu/duke/views/TimetableUserGuideView.java @@ -5,6 +5,10 @@ import java.util.ArrayList; +//@@author janelleenqi +/** + * The TimetableUserGuideView class provides methods to display user guides for the timetable-related commands. + */ public class TimetableUserGuideView { private static final int justifyLength = 12; @@ -38,7 +42,12 @@ private static void printToJustify(String string, int number) { print(String.format("%-" + number + "s", string)); } - + /** + * Prints the list of modules in the current semester. + * + * @param currentSemModulesWeekly The list of modules in the current semester. + * @throws TimetableUnavailableException If there are no modules in the current semester. + */ public static void printCurrentSemModules(ArrayList currentSemModulesWeekly) throws TimetableUnavailableException { println("List of modules in current semester: "); @@ -65,22 +74,44 @@ private static String getTimetableModifyGuide() { return "Modify your lectures/tutorials/labs in timetable using this format: timetable modify"; } + /** + * Generates a guide for adding or recommending modules. + * + * @param specificContext The specific context for the guide. + * @param semester The semester for which to add modules. + * @return The guide for adding or recommending modules. + */ public static String addOrRecommendGuide(String specificContext, int semester) { return (specificContext + "\n" + "Add modules using this format: add [module code] " + semester + "\n" + "Alternatively, get the recommended schedule for your major: recommend"); } + /** + * Prints the guide for adding or recommending modules. + * + * @param specificContext The specific context for the guide. + */ public static void printAddRecommendGuide(String specificContext) { print(specificContext); println("Add modules to your current semester or get the recommended schedule for your major first."); } + /** + * Prints the guide for modifying the timetable. + * + * @param specificContext The specific context for the guide. + */ public static void printTimetableModifyGuide(String specificContext) { println(specificContext); println("Enter Timetable Modify Mode to add lessons: timetable modify"); } + /** + * Prints a simple guide for modifying lessons in the timetable. + * + * @param specificContext The specific context for the guide. + */ public static void printTTModifySimpleLessonGuide(String specificContext) { println(specificContext); println("To add a lesson for a module, enter: [moduleCode] [lessonType] [startTime] [duration] [day]\n" + @@ -88,6 +119,11 @@ public static void printTTModifySimpleLessonGuide(String specificContext) { "To exit Timetable Modify Mode, enter: EXIT"); } + /** + * Prints a detailed guide for modifying lessons in the timetable. + * + * @param specificContext The specific context for the guide. + */ public static void printTTModifyDetailedLessonGuide(String specificContext) { println(specificContext); println("To add a lesson to a module: [moduleCode] [lessonType] [startTime] [duration] [day]"); @@ -112,16 +148,4 @@ public static void printTTModifyDetailedLessonGuide(String specificContext) { println("To exit timetable modify: exit"); } - - public static void timetableModifySuccessful() { - println("Your timetable has been successfully modified!"); - println("Continue to " + getTimetableShowGuide().toLowerCase()); - println("Continue to " + getTimetableModifyGuide().toLowerCase()); - } - - public static void timetableModeIncorrectUserInput() { - println("Invalid user input in Timetable-Modify-Mode."); - println("Continue to " + getTimetableShowGuide().toLowerCase()); - println("Continue to " + getTimetableModifyGuide().toLowerCase()); - } } diff --git a/src/main/java/seedu/duke/views/TimetableView.java b/src/main/java/seedu/duke/views/TimetableView.java index 892b001e00..3f880e63fc 100644 --- a/src/main/java/seedu/duke/views/TimetableView.java +++ b/src/main/java/seedu/duke/views/TimetableView.java @@ -9,6 +9,7 @@ import static seedu.duke.views.TimetableUserGuideView.printTimetableModifyGuide; import static seedu.duke.views.TimetableUserGuideView.printAddRecommendGuide; +//@@author janelleenqi public class TimetableView { private static final int dayColumnWidth = 10; private static final int eventColumnWidth = 45; diff --git a/src/main/java/seedu/duke/models/logic/CompletePreqs.java b/unused/CompletePreqs.java similarity index 100% rename from src/main/java/seedu/duke/models/logic/CompletePreqs.java rename to unused/CompletePreqs.java diff --git a/unused/WeeklyScheduleView.java b/unused/WeeklyScheduleView.java index 7c9673962e..24c3608e3f 100644 --- a/unused/WeeklyScheduleView.java +++ b/unused/WeeklyScheduleView.java @@ -236,3 +236,59 @@ private static void makeFileReadOnly(String filePath) { } + +/* +public ArrayList getByHour() { + ArrayList eventByHour = new ArrayList<>(); + int eventDurationLeft = getDuration(); + while (eventDurationLeft > 0) { + String eventTimeData = getStartTime() + " " + (getStartTime() + 1); + eventByHour.add(eventTimeData); + eventDurationLeft -= 1; + } + return eventByHour; +} + +@Override +public ArrayList getByHour () { + ArrayList tutorialByHour = new ArrayList<>(); + + int eventDurationLeft = getDuration(); + while (eventDurationLeft > 0) { + String tutorialTimeData = "T " + getStartTime() + " " + (getStartTime() + 1); + tutorialByHour.add(tutorialTimeData); + eventDurationLeft -= 1; + } + + return tutorialByHour; +} + +@Override +public ArrayList getByHour () { + ArrayList tutorialByHour = new ArrayList<>(); + + int eventDurationLeft = getDuration(); + while (eventDurationLeft > 0) { + String tutorialTimeData = "T " + getStartTime() + " " + (getStartTime() + 1); + tutorialByHour.add(tutorialTimeData); + eventDurationLeft -= 1; + } + + return tutorialByHour; +} + + +@Override +public ArrayList getByHour () { + ArrayList tutorialByHour = new ArrayList<>(); + + int eventDurationLeft = getDuration(); + while (eventDurationLeft > 0) { + String tutorialTimeData = "T " + getStartTime() + " " + (getStartTime() + 1); + tutorialByHour.add(tutorialTimeData); + eventDurationLeft -= 1; + } + + return tutorialByHour; +} +*/