diff --git a/src/main/java/AddCommand.java b/src/main/java/AddCommand.java index 0449f9c026..3d994b7211 100644 --- a/src/main/java/AddCommand.java +++ b/src/main/java/AddCommand.java @@ -2,9 +2,9 @@ import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; -/* - * Represents the Command for adding Tasks and its subclasses - * A subclass of Command +/** + * Represents the Command for adding Tasks and its subclasses. + * A subclass of Command. */ public class AddCommand extends Command { @@ -12,8 +12,8 @@ public class AddCommand extends Command { final String timePattern = "d MMMM yyyy, h:mma"; DateTimeFormatter dateTimeFormat = DateTimeFormatter.ofPattern(timePattern); - /* - * Constructor for AddCommand to set the Task command + /** + * Constructor for AddCommand to set the Task command. * @param taskCmd User input of what Task is being generated */ public AddCommand(String taskCmd) { @@ -21,7 +21,7 @@ public AddCommand(String taskCmd) { this.taskCmd = taskCmd; } - /* + /** * Overridden execute method from Command to add a Task object into the list of tasks. * The method will check the user input for a valid Command and adds the appropriate Task * accordingly. It will throw an exception if the user inputs are unrecognisable for the @@ -29,8 +29,7 @@ public AddCommand(String taskCmd) { * @param storage Storage object for saving purposes * @param tasks Contains the list of tasks * @param ui Holds Ui printing methods and user input field - * @throws DukeException If taskCmd and taskName is invalid and format of subsequent fields, - * such as /by, /at and dateTime, is wrong + * @throws DukeException If taskCmd and taskName is invalid and format of subsequent fields is wrong */ @Override public void execute(Storage storage, TaskList tasks, Ui ui) throws DukeException { diff --git a/src/main/java/Command.java b/src/main/java/Command.java index d634ca2ea1..5f7813bba5 100644 --- a/src/main/java/Command.java +++ b/src/main/java/Command.java @@ -1,21 +1,21 @@ -/* - * Represents the user input as a Command object +/** + * Represents the user input as a Command object. */ public abstract class Command { protected boolean hasExit; - /* - * Default Constructor to set hasExit boolean variable to false - * Will be set to true if ExitCommand is called + /** + * Default Constructor to set hasExit boolean variable to false. + * Will be set to true if ExitCommand is called. */ public Command() { hasExit = false; } - /* + /** * Abstract method for the sub-classes of Command to use. This method will execute - * differently based on the sub-class called + * differently based on the sub-class called. * @param storage Storage object for saving purposes * @param tasks Contains the list of tasks * @param ui Holds Ui printing methods and user input field @@ -23,8 +23,8 @@ public Command() { */ abstract void execute(Storage storage, TaskList tasks, Ui ui) throws DukeException; - /* - * Returns boolean variable hasExit for checking exit status + /** + * Returns boolean variable hasExit for checking exit status. * @return hasExit boolean variable */ public boolean isExit() { diff --git a/src/main/java/Deadline.java b/src/main/java/Deadline.java index 9030b23e34..a685c99fd4 100644 --- a/src/main/java/Deadline.java +++ b/src/main/java/Deadline.java @@ -1,13 +1,13 @@ -/* +/** * Represents a different type of Task called Deadline that holds an additional - * parameter for date and time - * A sub-class of Task + * parameter for date and time. + * A sub-class of Task. */ public class Deadline extends Task { protected String by; - /* - * Constructor to set the description of deadline and due date and time + /** + * Constructor to set the description of deadline and due date and time. * @param desc The description of the Deadline * @param by The due date and time of the Deadline */ @@ -16,8 +16,8 @@ public Deadline(String desc, String by) { this.by = by; } - /* - * Constructor with additional parameter to set its completion status + /** + * Constructor with additional parameter to set its completion status. * @param desc The description of the Deadline * @param by The due date and time of the Deadline * @param isDone The boolean variable to note if Deadline is completed @@ -27,9 +27,9 @@ public Deadline(String desc, String by, boolean isDone) { this.by = by; } - /* + /** * Overridden writeFormat method to specify that it is a Deadline - * when saving the data + * when saving the data. * @return Format for saving data */ @Override @@ -37,8 +37,8 @@ public String writeFormat() { return "D " + isDone + " " + description + "/" + by; } - /* - * Overridden toString method to print out Deadline object + /** + * Overridden toString method to print out Deadline object. * @return Printing format of Deadline */ @Override diff --git a/src/main/java/DeleteCommand.java b/src/main/java/DeleteCommand.java index cd9e886e2d..a861108c03 100644 --- a/src/main/java/DeleteCommand.java +++ b/src/main/java/DeleteCommand.java @@ -1,13 +1,13 @@ -/* - * Represents the Command for deleting Tasks for the list - * A sub-class of Command +/** + * Represents the Command for deleting Tasks for the list. + * A sub-class of Command. */ public class DeleteCommand extends Command { - /* + /** * Overridden execute method from Command to delete a Task object from the list of tasks. * The method will check the user input for a valid index and deletes the selected - * Task object from the list. It will throw an exception if the index is invalid + * Task object from the list. It will throw an exception if the index is invalid. * @param storage Storage object for saving purposes * @param tasks Contains the list of tasks * @param ui Holds Ui printing methods and user input field diff --git a/src/main/java/DoneCommand.java b/src/main/java/DoneCommand.java index 19eda30116..9c4379bdaa 100644 --- a/src/main/java/DoneCommand.java +++ b/src/main/java/DoneCommand.java @@ -1,14 +1,14 @@ -/* - * Represents the Command for setting Tasks as completed - * A sub-class of Command +/** + * Represents the Command for setting Tasks as completed. + * A sub-class of Command. */ public class DoneCommand extends Command { - /* + /** * Overridden execute method from Command to mark a Task object as completed. * The method will check the user input for a valid index and change the selected * Task object's isDone boolean variable to true. - * It will throw an exception if the index is invalid + * It will throw an exception if the index is invalid. * @param storage Storage object for saving purposes * @param tasks Contains the list of tasks * @param ui Holds Ui printing methods and user input field diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java index 101857d4c9..3f661715ca 100644 --- a/src/main/java/Duke.java +++ b/src/main/java/Duke.java @@ -1,5 +1,5 @@ -/* - * Main class responsible for running Duke Chatbot +/** + * Main class responsible for running Duke Chatbot. */ public class Duke { @@ -7,9 +7,9 @@ public class Duke { private TaskList taskList; private Ui ui; - /* - * Constructor of Duke class - * @param filepath The directory of the text file for populating task list + /** + * Constructor of Duke class. + * @param filePath The directory of the text file for populating task list */ public Duke(String filePath) { ui = new Ui(); @@ -22,8 +22,8 @@ public Duke(String filePath) { } } - /* - * Method to start up Duke Chatbot + /** + * Method to start up Duke Chatbot. */ public void run() { ui.showWelcome(); diff --git a/src/main/java/DukeException.java b/src/main/java/DukeException.java index 0aa6186bda..1fce16d48f 100644 --- a/src/main/java/DukeException.java +++ b/src/main/java/DukeException.java @@ -1,10 +1,10 @@ -/* - * Represents Exceptions from the Duke project +/** + * Represents Exceptions from the Duke project. */ public class DukeException extends Exception { - /* - * Constructor to print custom error messages + /** + * Constructor to print custom error messages. * @param error Error message */ public DukeException(String error) { diff --git a/src/main/java/Event.java b/src/main/java/Event.java index 5dc1e24b18..b9d1d32007 100644 --- a/src/main/java/Event.java +++ b/src/main/java/Event.java @@ -1,13 +1,13 @@ -/* +/** * Represents a different type of Task called Event that holds an - * additional parameter for the venue + * additional parameter for the venue. */ public class Event extends Task { protected String at; - /* - * Constructor to set the description of event and venue + /** + * Constructor to set the description of event and venue. * @param desc The description of the Event * @param at The venue of the Event */ @@ -16,8 +16,8 @@ public Event(String desc, String at) { this.at = at; } - /* - * Constructor with additional parameter to set its completion status + /** + * Constructor with additional parameter to set its completion status. * @param desc The description of the Event * @param at The venue of the Event * @param isDone The boolean variable to note if Event is completed @@ -27,9 +27,9 @@ public Event(String desc, String at, boolean isDone) { this.at = at; } - /* + /** * Overridden writeFormat method to specify that it is a Event - * when saving the data + * when saving the data. * @return Format for saving data */ @Override @@ -37,8 +37,8 @@ public String writeFormat() { return "E " + isDone + " " + description + "/" + at; } - /* - * Overridden toString method to print out Event object + /** + * Overridden toString method to print out Event object. * @return Printing format of Event */ @Override diff --git a/src/main/java/ExitCommand.java b/src/main/java/ExitCommand.java index ecd30bb003..a3f09c1421 100644 --- a/src/main/java/ExitCommand.java +++ b/src/main/java/ExitCommand.java @@ -1,13 +1,13 @@ -/* - * Represents the Command for exiting the Duke Chatbot - * A sub-class of Command +/** + * Represents the Command for exiting the Duke Chatbot. + * A sub-class of Command. */ public class ExitCommand extends Command { - /* + /** * Overridden execute method from Command to save the list data to the specified * text file. The method will set the hasExit boolean variable to true, call - * the saveData method from storage and display the Goodbye Message to the user + * the saveData method from storage and display the Goodbye Message to the user. * @param storage Storage object for saving purposes * @param tasks Contains the list of tasks * @param ui Holds Ui printing methods and user input field diff --git a/src/main/java/ListCommand.java b/src/main/java/ListCommand.java index 3b72a34851..7974c386fe 100644 --- a/src/main/java/ListCommand.java +++ b/src/main/java/ListCommand.java @@ -1,12 +1,12 @@ -/* - * Represents the Command for printing out all of the tasks in the list - * A sub-class of Command +/** + * Represents the Command for printing out all of the tasks in the list. + * A sub-class of Command. */ public class ListCommand extends Command { - /* + /** * Overridden execute method to print out all of the tasks inside the list - * using the method from TaskList + * using the method from TaskList. * @param storage Storage object for saving purposes * @param tasks Contains the list of tasks * @param ui Holds Ui printing methods and user input field diff --git a/src/main/java/Parser.java b/src/main/java/Parser.java index ccec4c6eae..1ee626b729 100644 --- a/src/main/java/Parser.java +++ b/src/main/java/Parser.java @@ -1,10 +1,10 @@ -/* - * Responsible for interpreting Commands +/** + * Responsible for interpreting Commands. */ public class Parser { - /* - * Checks user input for a Command and returns the associated Command class + /** + * Checks user input for a Command and returns the associated Command class. * @param userCmd The command from user input * @return Command object * @throws DukeException If user input is an invalid command diff --git a/src/main/java/Storage.java b/src/main/java/Storage.java index 9b9cefbc1c..04b5cc01a6 100644 --- a/src/main/java/Storage.java +++ b/src/main/java/Storage.java @@ -5,25 +5,25 @@ import java.io.FileWriter; import java.util.Scanner; -/* - * Represents the read and write of data into a text file +/** + * Represents the read and write of data into a text file. */ public class Storage { private String filePath; - /* + /** * Constructor to specify the file path of the text file used - * for saving and loading of Tasks for the list + * for saving and loading of Tasks for the list. * @param filePath directory of text file */ public Storage(String filePath) { this.filePath = filePath; } - /* + /** * Returns a ArrayList of Task type for Duke to use as an initial list. - * Data is obtained from a text file with a specific format + * Data is obtained from a text file with a specific format. * @return List of Tasks to be used * @throws DukeException When format is wrong and filePath is invalid */ @@ -64,11 +64,11 @@ public ArrayList loadData() throws DukeException { } } - /* + /** * Saves all of the Tasks inside the list into a text file for future usage. * It will throw an exception if the file path was not specified in storage upon initialisation. * However, an IOException is thrown instead of DukeException to be able - * to exit the program despite not saving + * to exit the program despite not saving. * @param list List of Tasks used in Duke */ public void saveData(ArrayList list) { diff --git a/src/main/java/Task.java b/src/main/java/Task.java index b146433fbd..3c11b0b403 100644 --- a/src/main/java/Task.java +++ b/src/main/java/Task.java @@ -1,12 +1,12 @@ -/* - * Represents the tasks the user enters into Duke +/** + * Represents the tasks the user enters into Duke. */ public class Task { protected String description; protected boolean isDone; - /* - * Constructor to set the description of the Task + /** + * Constructor to set the description of the Task. * @param desc The description of the Task */ public Task(String desc) { @@ -14,8 +14,8 @@ public Task(String desc) { this.isDone = false; } - /* - * Constructor to set the description of the Task and whether it is done + /** + * Constructor to set the description of the Task and whether it is done. * @param desc The description of the Task * @param isDone The boolean variable to note if Task is completed */ @@ -24,23 +24,23 @@ public Task(String desc, boolean isDone) { this.isDone = isDone; } - /* - * Returns a Tick or X symbol based on whether the Task is completed + /** + * Returns a Tick or X symbol based on whether the Task is completed. * @return The status icon of the Task object */ public String getStatusIcon() { return (isDone ? "\u2713" : "\u2718"); //return tick or X symbols } - /* - * Sets the boolean variable isDone to true, marking the Task as completed + /** + * Sets the boolean variable isDone to true, marking the Task as completed. */ public void markAsDone() { isDone = true; } - /* - * Returns the description of the Task with its status + /** + * Returns the description of the Task with its status. * @return Task description and status in the format of "[Status] description" */ public String getTask() { @@ -48,24 +48,24 @@ public String getTask() { return output; } - /* - * Returns the boolean variable isDone of the Task object + /** + * Returns the boolean variable isDone of the Task object. * @return status of task */ public boolean getIsDone() { return isDone; } - /* - * Returns the Task object in a String format for saving into a text file - * @returns description and status of Task for saving + /** + * Returns the Task object in a String format for saving into a text file. + * @return description and status of Task for saving */ public String writeFormat() { return "T " + isDone + " " + description; } - /* - * Overrides toString method for printing Task object, which includes Task type + /** + * Overrides toString method for printing Task object, which includes Task type. * @return display format of Task, "[T][Status] description" */ @Override diff --git a/src/main/java/TaskList.java b/src/main/java/TaskList.java index e3c8b80543..5a6fc04013 100644 --- a/src/main/java/TaskList.java +++ b/src/main/java/TaskList.java @@ -1,29 +1,29 @@ import java.util.ArrayList; -/* - * Represents the list of tasks that Duke holds +/** + * Represents the list of tasks that Duke holds. */ public class TaskList { private ArrayList list; - /* - * Default Constructor to generate an empty ArrayList of Task type + /** + * Default Constructor to generate an empty ArrayList of Task type. */ public TaskList() { list = new ArrayList<>(); } - /* - * Constructor to take in a populated ArrayList of Task type (i.e. from text file) + /** + * Constructor to take in a populated ArrayList of Task type (i.e. from text file). * @param list ArrayList of Task Type */ public TaskList(ArrayList list) { this.list = list; } - /* - * Adds a Task object into the list + /** + * Adds a Task object into the list. * @param task A Task object */ public void addTask(Task task) { @@ -32,8 +32,8 @@ public void addTask(Task task) { + "\nNow you have " + list.size() + " tasks in the list."); } - /* - * Deletes a Task from the list + /** + * Deletes a Task from the list. * @param deleteIndex Index of selected Task Object, 1-based index */ public void deleteTask(int deleteIndex) { @@ -42,8 +42,8 @@ public void deleteTask(int deleteIndex) { + "\nNow you have " + list.size() + " tasks in the list."); } - /* - * Returns selected Task object from list + /** + * Returns selected Task object from list. * @param taskIndex Index of selected Task object, 1-based index * @return Task object */ @@ -51,8 +51,8 @@ public Task getTask(int taskIndex) { return list.get(taskIndex - 1); } - /* - * Prints out the list of tasks that Duke holds + /** + * Prints out the list of tasks that Duke holds. */ public void showTaskList() { System.out.println("Here are the tasks in your list:"); @@ -61,8 +61,8 @@ public void showTaskList() { } } - /* - * Sets boolean variable isDone of selected Task object to true + /** + * Sets boolean variable isDone of selected Task object to true. * @param doneIndex Index of selected Task object, 1-based index */ public void setDoneTask(int doneIndex) { @@ -71,8 +71,8 @@ public void setDoneTask(int doneIndex) { + list.get(doneIndex - 1)); } - /* - * Returns the list of tasks that Duke holds as an object + /** + * Returns the list of tasks that Duke holds as an object. * @return ArrayList of Task type */ public ArrayList getTaskList() { diff --git a/src/main/java/Ui.java b/src/main/java/Ui.java index bd9d3ba0a6..83479f6e8a 100644 --- a/src/main/java/Ui.java +++ b/src/main/java/Ui.java @@ -1,22 +1,22 @@ import java.util.Scanner; -/* - * Represents the User Interface of Duke, including the user input fields +/** + * Represents the User Interface of Duke, including the user input fields. */ public class Ui { final String lineSpace = "_______________________________\n"; private Scanner sc; - /* - * Default Constructor to initialise Scanner object for user input + /** + * Default Constructor to initialise Scanner object for user input. */ public Ui() { sc = new Scanner(System.in); } - /* - * Prints out Welcome Message for the launch of Duke Chatbot + /** + * Prints out Welcome Message for the launch of Duke Chatbot. */ public void showWelcome() { final String logo = " ____ _ \n" @@ -28,31 +28,31 @@ public void showWelcome() { System.out.println("Hello from\n" + logo + startMessage); } - /* - * Prints Goodbye Message when user closes the Duke Chatbot + /** + * Prints Goodbye Message when user closes the Duke Chatbot. */ public void showGoodbye() { String endMessage = "Bye. Hope to see you again!"; System.out.println(endMessage); } - /* - * Prints a straight line for clarity purposes + /** + * Prints a straight line for clarity purposes. */ public void showLine() { System.out.print(lineSpace); } - /* - * Prints a specified error message + /** + * Prints a specified error message. * @param error Message of error */ public void showError(String error) { System.out.println(error); } - /* - * Reads the user input and returns a String + /** + * Reads the user input and returns a String. * @return User input */ public String readCommand() { @@ -60,18 +60,18 @@ public String readCommand() { return userCmd; } - /* - * Returns the description of Task specified in the user input - * Use only after reading the initial command input of the user + /** + * Returns the description of Task specified in the user input. + * Use only after reading the initial command input of the user. */ public String readDesc() { String desc = sc.nextLine(); return desc; } - /* - * Returns the index of the Task specified in the user input - * Use only after reading the initial command input of the user + /** + * Returns the index of the Task specified in the user input. + * Use only after reading the initial command input of the user. */ public int readIndex() { int index = sc.nextInt(); diff --git a/src/test/java/AddCommandTest.java b/src/test/java/AddCommandTest.java index 2f23f90185..e67924e29e 100644 --- a/src/test/java/AddCommandTest.java +++ b/src/test/java/AddCommandTest.java @@ -21,15 +21,15 @@ void init() { @ParameterizedTest @CsvSource({"todo, dance", "deadline, homework /by 01/09/2019 2359", "event, party /at NUS"}) - public void testExecute(String cmd, String task) { + void testExecute(String cmd, String task) { String input = task; InputStream in = new ByteArrayInputStream((input.getBytes())); System.setIn(in); ui = new Ui(); - try{ + try { AddCommand ac = new AddCommand(cmd); ac.execute(storage, taskList, ui); - }catch(DukeException e){ + } catch (DukeException e) { fail("failed to add item into list"); } } diff --git a/src/test/java/DeleteCommandTest.java b/src/test/java/DeleteCommandTest.java index cbbe9ef59b..4dccb39153 100644 --- a/src/test/java/DeleteCommandTest.java +++ b/src/test/java/DeleteCommandTest.java @@ -20,16 +20,16 @@ void init() { } @Test - void testExecute(){ + void testExecute() { String input = "1"; InputStream in = new ByteArrayInputStream((input.getBytes())); System.setIn(in); ui = new Ui(); - try{ + try { DeleteCommand dc = new DeleteCommand(); dc.execute(storage, taskList, ui); assertTrue(taskList.getTaskList().size() == 0); - }catch(DukeException e){ + } catch (DukeException e) { fail("failed to delete item in list"); } } diff --git a/src/test/java/DoneCommandTest.java b/src/test/java/DoneCommandTest.java index 39d8979257..6a035a7581 100644 --- a/src/test/java/DoneCommandTest.java +++ b/src/test/java/DoneCommandTest.java @@ -20,16 +20,16 @@ void init() { } @Test - void testExecute(){ + void testExecute() { String input = "1"; InputStream in = new ByteArrayInputStream((input.getBytes())); System.setIn(in); ui = new Ui(); - try{ + try { DoneCommand dc = new DoneCommand(); dc.execute(storage, taskList, ui); assertTrue(taskList.getTask(1).getIsDone()); - }catch(DukeException e){ + } catch (DukeException e) { fail("failed to change item in list to done"); } }