Skip to content

Commit

Permalink
Fix checkstyle error
Browse files Browse the repository at this point in the history
  • Loading branch information
NereusWB922 committed Sep 12, 2023
1 parent 44ed218 commit 8dff373
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/main/java/corgi/Corgi.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class Corgi {
private Stack<Pair<State, Command>> history;

/**
* Constructs new Corgi chatbot with an empty task list,
* Constructs new Corgi chatbot with an empty task list,
* a text renderer, a storage and a history stack.
*/
public Corgi() {
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/corgi/State.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public final class State {

/**
* Construct new state object with given task list, storage and text renderer.
*
*
* @param tasks The given task list.
* @param storage The given storage.
* @param renderer The given text renderer.
Expand All @@ -31,7 +31,7 @@ public State(

/**
* Getter for task list.
*
*
* @return The task list.
*/
public TaskList getTaskList() {
Expand All @@ -40,7 +40,7 @@ public TaskList getTaskList() {

/**
* Getter for storage.
*
*
* @return The storage.
*/
public Storage<Task> getStorage() {
Expand All @@ -49,7 +49,7 @@ public Storage<Task> getStorage() {

/**
* Getter for text renderer.
*
*
* @return The text renderer.
*/
public TextRenderer getTextRenderer() {
Expand All @@ -58,7 +58,7 @@ public TextRenderer getTextRenderer() {

/**
* Add target task to the task list.
*
*
* @param task The target task.
* @return New state with the updated task list.
*/
Expand All @@ -72,7 +72,7 @@ public State addTask(Task task) {

/**
* Remove task at the target index in the task list.
*
*
* @param index The target index.
* @return New state with the updated task list.
* @throws TaskListIndexOutOfBoundsException
Expand All @@ -87,14 +87,14 @@ public State removeTask(int index) throws TaskListIndexOutOfBoundsException {

/**
* Mark task at the target index to a given status.
*
*
* @param index The target index.
* @param status The expected status.
* @return New state with the updated task list.
* @throws TaskListIndexOutOfBoundsException
* @throws TaskStatusException
*/
public State markTask(int index, boolean status)
public State markTask(int index, boolean status)
throws TaskListIndexOutOfBoundsException, TaskStatusException {
TaskList newTaskList = this.tasks.mark(index, status);

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/corgi/commands/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public Command(boolean isExit) {

/**
* Executes the command, performing its intended action on the provided task list,
* text renderer, and storage. Returns new state and string message
* text renderer, and storage. Returns new state and string message
*
* @param currState The current state of the application.
* @param history The history stack to store the states.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/corgi/commands/FindTasksOnDateCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ public Pair<State, String> execute(State currState, Stack<Pair<State, Command>>

String outputDate = this.target.format(Task.DATE_OUTPUT_FORMATTER);

String returnMsg = tasksOnDate.isEmpty()
String returnMsg = tasksOnDate.isEmpty()
? currTextRenderer.showNoTaskOnDate(outputDate)
: currTextRenderer.showTasksOnDate(outputDate, tasksOnDate.toString());

return new Pair<>(currState, returnMsg);
}
}
2 changes: 1 addition & 1 deletion src/main/java/corgi/commands/MarkTaskCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public Pair<State, String> execute(State currState, Stack<Pair<State, Command>>
String returnMsg = (status)
? renderer.showTaskDone(list.getTaskInfo(this.index))
: renderer.showTaskUndone(list.getTaskInfo(this.index));

return new Pair<>(newState, returnMsg);
} catch (TaskListIndexOutOfBoundsException e) {
throw new CommandExecutionException("Invalid index provided!");
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/corgi/commands/UndoCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import corgi.ui.TextRenderer;
import javafx.util.Pair;

/**
* Represents a command to undo previous command action.
*/
public class UndoCommand extends Command {
/**
* Initializes a new UndoCommand instance.
Expand All @@ -15,16 +18,16 @@ public UndoCommand() {
}

/**
* Executes the command by reverting the previous action based on the provided
* Executes the command by reverting the previous action based on the provided
* history stack and updating the task list accordingly.
*
* @param currState The current state of the application.
* @param history The history stack to store the states.
* @return A pair containing the new state and a string message indicating the result of the command execution.
*/
@Override
public Pair<State, String> execute(State currState, Stack<Pair<State, Command>> history)
throws CommandExecutionException {
public Pair<State, String> execute(State currState, Stack<Pair<State, Command>> history)
throws CommandExecutionException {
if (history.isEmpty()) {
throw new CommandExecutionException("Nothing to undo!");
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/corgi/tasks/Deadline.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ public Deadline(boolean status, String desc, LocalDate by) {
}

@Override
public Deadline markAsDone() throws TaskStatusException{
public Deadline markAsDone() throws TaskStatusException {
if (status) {
throw new TaskStatusException("The task is already marked as done.");
}
return new Deadline(true, desc, by);
}

@Override
public Deadline markAsNotDone() throws TaskStatusException{
public Deadline markAsNotDone() throws TaskStatusException {
if (!status) {
throw new TaskStatusException("The task is already marked as not done.");
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/corgi/tasks/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public Event(String desc, LocalDate from, LocalDate to) {
this.to = to;
}


/**
* Initializes a new event task with the given status, description, start date, and end date.
*
Expand All @@ -38,23 +38,23 @@ public Event(boolean status, String desc, LocalDate from, LocalDate to) {
this.from = from;
this.to = to;
}

@Override
public Event markAsDone() throws TaskStatusException{
public Event markAsDone() throws TaskStatusException {
if (status) {
throw new TaskStatusException("The task is already marked as done.");
}
return new Event(true, desc, from, to);
}

@Override
public Event markAsNotDone() throws TaskStatusException{
public Event markAsNotDone() throws TaskStatusException {
if (!status) {
throw new TaskStatusException("The task is already marked as not done.");
}
return new Event(false, desc, from, to);
}

/**
* Checks if the event task is happening on the specified target date.
*
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/corgi/tasks/TaskList.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public TaskList add(Task t) {
* without the removed task.
*
* @param index The index of the task to be removed.
* @throws TaskListIndexOutOfBoundsException If the index is invalid.
* @return A new TaskList with the specified task removed.
* @throws TaskListIndexOutOfBoundsException If the index is invalid.
*/
public TaskList remove(int index) throws TaskListIndexOutOfBoundsException {
if (!isValidIndex(index)) {
Expand All @@ -65,9 +65,9 @@ public TaskList remove(int index) throws TaskListIndexOutOfBoundsException {
*
* @param index The index of the task to be marked.
* @param status The new status of the task.
* @return A new TaskList with the specified task's status updated.
* @throws TaskListIndexOutOfBoundsException If the index is invalid.
* @throws TaskStatusException If the task was already marked with the given status.
* @return A new TaskList with the specified task's status updated.
*/
public TaskList mark(int index, boolean status) throws TaskListIndexOutOfBoundsException, TaskStatusException {
if (!isValidIndex(index)) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/corgi/tasks/ToDo.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ public ToDo(boolean status, String desc) {
}

@Override
public ToDo markAsDone() throws TaskStatusException{
public ToDo markAsDone() throws TaskStatusException {
if (status) {
throw new TaskStatusException("The task is already marked as done.");
}
return new ToDo(true, desc);
}

@Override
public ToDo markAsNotDone() throws TaskStatusException{
public ToDo markAsNotDone() throws TaskStatusException {
if (!status) {
throw new TaskStatusException("The task is already marked as not done.");
}
Expand Down

0 comments on commit 8dff373

Please sign in to comment.