Skip to content

Commit

Permalink
Resolve issues mentioned in PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
tjwjoe committed Sep 2, 2020
1 parent eb4a480 commit 456f71f
Show file tree
Hide file tree
Showing 23 changed files with 117 additions and 116 deletions.
50 changes: 22 additions & 28 deletions src/main/java/commands/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


/**
* Represents an instruction from a user to add a new task to the list
* Represents an instruction from a user to add a new task to the list.
*/
public class AddCommand extends Command {
private String text;
Expand All @@ -28,44 +28,38 @@ public AddCommand(String text) {
}

/**
* Executes the command to add the task to the list
* @param tasks The current TaskList
* @param ui The Ui object in use
* @param storage The Storage object in use
* @throws InvalidTaskException If the task name is empty
* @throws UnknownCmdException If an unknown command is entered
* @throws InvalidTimeException If the time for the task is invalid
* @throws BadDtFormatException If the format of the date and time entered does not match
* Executes the command to add the task to the list.
* @param tasks The current TaskList.
* @param ui The Ui object in use.
* @param storage The Storage object in use.
* @throws InvalidTaskException If the task name is empty.
* @throws UnknownCmdException If an unknown command is entered.
* @throws InvalidTimeException If the time for the task is invalid.
* @throws BadDtFormatException If the format of the date and time entered does not match.
*/
@Override
public void exec(TaskList tasks, Ui ui, Storage storage) throws InvalidTaskException, UnknownCmdException,
InvalidTimeException, BadDtFormatException {
String[] info = extractInfo(text);
if (info[0].equals("todo")) {
tasks.addItem(new Todo(info[1], false));
// ui.printAddTask(info[1]);
// ui.printListSize(tasks.size());
ui.setMessageAddTask(info[1], tasks.size());
ui.setMessageNewTask(info[1], tasks.size());
} else if (info[0].equals("deadline")) {
tasks.addItem(new Deadline(info[1], stringToTime(info[2]), false));
// ui.printAddTask(info[1]);
// ui.printListSize(tasks.size());
ui.setMessageAddTask(info[1], tasks.size());
ui.setMessageNewTask(info[1], tasks.size());
} else {
tasks.addItem(new Event(info[1], stringToTime(info[2]), false));
// ui.printAddTask(info[1]);
// ui.printListSize(tasks.size());
ui.setMessageAddTask(info[1], tasks.size());
ui.setMessageNewTask(info[1], tasks.size());
}
}

/**
* Breaks down and stores user input in a string array for easy access
* @param str String to be broken down
* @return A string array split according to the information categories
* @throws InvalidTaskException If task description is empty
* @throws UnknownCmdException If an unknown command is entered
* @throws InvalidTimeException If an invalid time is entered for a Deadline or Event task
* Breaks down and stores user input in a string array for easy access.
* @param str String to be broken down.
* @return A string array split according to the information categories.
* @throws InvalidTaskException If task description is empty.
* @throws UnknownCmdException If an unknown command is entered.
* @throws InvalidTimeException If an invalid time is entered for a Deadline or Event task.
*/

public String[] extractInfo(String str) throws InvalidTaskException, UnknownCmdException, InvalidTimeException {
Expand Down Expand Up @@ -129,10 +123,10 @@ public String[] extractInfo(String str) throws InvalidTaskException, UnknownCmdE
}

/**
* Converts a string into a LocalDateTime
* @param time The string to be parsed
* @return A LocalDateTime object
* @throws BadDtFormatException If an invalid string format is entered
* Converts a string into a LocalDateTime.
* @param time The string to be parsed.
* @return A LocalDateTime object.
* @throws BadDtFormatException If an invalid string format is entered.
*/
public LocalDateTime stringToTime(String time) throws BadDtFormatException {
try {
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/commands/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@


/**
* Represents a generic command entered by the user
* Represents a generic command entered by the user.
*/
public class Command {

/**
* Placeholder command to be overridden by subclasses
* @param tasks The current TaskList
* @param ui The Ui object in use
* @param storage The Storage object in use
* @throws DukeException If erroneous inputs are detected
* Placeholder command to be overridden by subclasses.
* @param tasks The current TaskList.
* @param ui The Ui object in use.
* @param storage The Storage object in use.
* @throws DukeException If erroneous inputs are detected.
*/
public void exec(TaskList tasks, Ui ui, Storage storage) throws DukeException {

Expand Down
22 changes: 11 additions & 11 deletions src/main/java/commands/DeleteCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import tasks.TaskList;

/**
* Represents an instruction from the user to delete a task from the list
* Represents an instruction from the user to delete a task from the list.
*/

public class DeleteCommand extends Command {
Expand All @@ -18,12 +18,12 @@ public DeleteCommand(int index) {
}

/**
* Executes the command to delete the task from the TaskList
* @param tasks The current TaskList
* @param ui The Ui object in use
* @param storage The Storage object in use
* @throws TaskNotFoundException If input task number is not found in the list
* @throws InvalidTaskNumberException If the user enters a non-integer argument
* Executes the command to delete the task from the TaskList.
* @param tasks The current TaskList.
* @param ui The Ui object in use.
* @param storage The Storage object in use.
* @throws TaskNotFoundException If input task number is not found in the list.
* @throws InvalidTaskNumberException If the user enters a non-integer argument.
*/
@Override
public void exec(TaskList tasks, Ui ui, Storage storage) throws TaskNotFoundException,
Expand All @@ -34,10 +34,10 @@ public void exec(TaskList tasks, Ui ui, Storage storage) throws TaskNotFoundExce
}

/**
* Deletes an input task from the list
* @param idx Index of the task indicated to be deleted
* @throws TaskNotFoundException If input task number is not found in the list
* @throws InvalidTaskNumberException If user enters a non-integer argument
* Deletes an input task from the list.
* @param idx Index of the task indicated to be deleted.
* @throws TaskNotFoundException If input task number is not found in the list.
* @throws InvalidTaskNumberException If user enters a non-integer argument.
*/
public void deleteTask(int idx, TaskList tasks) throws TaskNotFoundException, InvalidTaskNumberException {
try {
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/commands/DoneCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import tasks.TaskList;

/**
* Represents an instruction from the user to mark a task as done
* Represents an instruction from the user to mark a task as done.
*/

public class DoneCommand extends Command {
Expand All @@ -18,12 +18,12 @@ public DoneCommand(int index) {
}

/**
* Executes the command to mark the task as done
* @param tasks The current TaskList
* @param ui The Ui object in use
* @param storage The Storage object in use
* @throws TaskNotFoundException If input task number is not found in the list
* @throws InvalidTaskNumberException If the user enters a non-integer argument
* Executes the command to mark the task as done.
* @param tasks The current TaskList.
* @param ui The Ui object in use.
* @param storage The Storage object in use.
* @throws TaskNotFoundException If input task number is not found in the list.
* @throws InvalidTaskNumberException If the user enters a non-integer argument.
*/
@Override
public void exec(TaskList tasks, Ui ui, Storage storage) throws TaskNotFoundException,
Expand All @@ -34,10 +34,10 @@ public void exec(TaskList tasks, Ui ui, Storage storage) throws TaskNotFoundExce
}

/**
* Marks an input task as done
* @param idx Index of the task which the user wishes to mark as done
* @throws TaskNotFoundException If input task number is not found in the list
* @throws InvalidTaskNumberException If user enters a non-integer input
* Marks an input task as done.
* @param idx Index of the task which the user wishes to mark as done.
* @throws TaskNotFoundException If input task number is not found in the list.
* @throws InvalidTaskNumberException If user enters a non-integer input.
*/

public void doneTask(int idx, TaskList tasks) throws TaskNotFoundException, InvalidTaskNumberException {
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/commands/ExitCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
import tasks.TaskList;

/**
* Represents an instruction from the user to quit the bot
* Represents an instruction from the user to quit the bot.
*/
public class ExitCommand extends Command {

/**
* Prints the exit message and writes the current TaskList to the hard drive
* @param tasks The current TaskList
* @param ui The Ui object in use
* @param storage The Storage object in use
* @throws InvalidFileException If file to be written to cannot be found
* Prints the exit message and writes the current TaskList to the hard drive.
* @param tasks The current TaskList.
* @param ui The Ui object in use.
* @param storage The Storage object in use.
* @throws InvalidFileException If file to be written to cannot be found.
*/
@Override
public void exec(TaskList tasks, Ui ui, Storage storage) throws InvalidFileException {
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/commands/FindCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,23 @@
import tasks.Task;
import tasks.TaskList;

/**
* Represents an instruction from the user to find specific tasks matching the input keywords.
*/

public class FindCommand extends Command {
private String text;

public FindCommand(String text) {
this.text = text;
}

/**
* Executes the command to find the specific tasks matching the input keywords.
* @param tasks The current TaskList.
* @param ui The Ui object in use.
* @param storage The Storage object in use.
*/
@Override
public void exec(TaskList tasks, Ui ui, Storage storage) {
StringBuilder output = new StringBuilder();
Expand All @@ -23,7 +33,6 @@ public void exec(TaskList tasks, Ui ui, Storage storage) {
counter++;
}
}
// ui.printFindTask(output.toString(), counter - 1);
ui.setMessageFindTask(output.toString(), counter - 1);
}
}
9 changes: 4 additions & 5 deletions src/main/java/commands/HelpCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ public class HelpCommand extends Command {

/**
* Executes the command to print the help message.
* @param tasks The current TaskList
* @param ui The Ui object in use
* @param storage The Storage object in use
* @param tasks The current TaskList.
* @param ui The Ui object in use.
* @param storage The Storage object in use.
*/
@Override
public void exec(TaskList tasks, Ui ui, Storage storage) {
// ui.printHelp();
ui.setMessageHelp();
ui.setMessagePrintHelp();
}
}
13 changes: 6 additions & 7 deletions src/main/java/commands/ListCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@
import tasks.TaskList;

/**
* Represents a command from the user to print the current TaskList
* Represents a command from the user to print the current TaskList.
*/
public class ListCommand extends Command {

/**
* Executes the command to print the TaskList
* @param tasks The current TaskList
* @param ui The Ui object in use
* @param storage The Storage object in use
* Executes the command to print the TaskList.
* @param tasks The current TaskList.
* @param ui The Ui object in use.
* @param storage The Storage object in use.
*/
@Override
public void exec(TaskList tasks, Ui ui, Storage storage) {
// ui.printList(tasks);
ui.setMessageList(tasks);
ui.setMessagePrintList(tasks);
}
}
22 changes: 11 additions & 11 deletions src/main/java/commands/UndoneCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import tasks.TaskList;

/**
* Represents an instruction from the user to mark a task as not done
* Represents an instruction from the user to mark a task as not done.
*/

public class UndoneCommand extends Command {
Expand All @@ -18,12 +18,12 @@ public UndoneCommand(int index) {
}

/**
* Executes the command to mark the task as not done
* @param tasks The current TaskList
* @param ui The Ui object in use
* @param storage The Storage object in use
* @throws TaskNotFoundException If input task number is not found in the list
* @throws InvalidTaskNumberException If the user enters a non-integer argument
* Executes the command to mark the task as not done.
* @param tasks The current TaskList.
* @param ui The Ui object in use.
* @param storage The Storage object in use.
* @throws TaskNotFoundException If input task number is not found in the list.
* @throws InvalidTaskNumberException If the user enters a non-integer argument.
*/
@Override
public void exec(TaskList tasks, Ui ui, Storage storage) throws TaskNotFoundException,
Expand All @@ -33,10 +33,10 @@ public void exec(TaskList tasks, Ui ui, Storage storage) throws TaskNotFoundExce
}

/**
* Marks an input task as not done
* @param idx Index of the task which the user wishes to mark as not done
* @throws TaskNotFoundException If input task number is not found in the list
* @throws InvalidTaskNumberException If user enters a non-integer input
* Marks an input task as not done.
* @param idx Index of the task which the user wishes to mark as not done.
* @throws TaskNotFoundException If input task number is not found in the list.
* @throws InvalidTaskNumberException If user enters a non-integer input.
*/

public void undoneTask(int idx, TaskList tasks) throws TaskNotFoundException, InvalidTaskNumberException {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/duke/Duke.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Duke {
private Parser parser;

/**
* Attempts to read an existing stored data.txt file, and creates a new data.txt file if one is not found
* Attempts to read an existing stored data.txt file, and creates a new data.txt file if one is not found.
*/
public Duke() {
this.tasks = new TaskList();
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/duke/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


/**
* Handles parsing of inputs from the user and generates Command objects accordingly
* Handles parsing of inputs from the user and generates Command objects accordingly.
*/
public class Parser {

Expand All @@ -23,9 +23,9 @@ public boolean getQuit() {
}

/**
* Parses and makes sense of the user input
* @param input The user's input string
* @return A Command object corresponding to what the user has input
* Parses and makes sense of the user input.
* @param input The user's input string.
* @return A Command object corresponding to what the user has input.
*/
public Command parse(String input) {
if (input.equals("exit")) {
Expand Down

0 comments on commit 456f71f

Please sign in to comment.