Skip to content

Commit

Permalink
Fix styling issues brought up by checkstyle
Browse files Browse the repository at this point in the history
  • Loading branch information
billyhoce committed Feb 18, 2024
1 parent 6e84527 commit d0bf77f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
8 changes: 8 additions & 0 deletions src/main/java/duke/core/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public class MainWindow extends AnchorPane {
private final Image userImage = new Image(this.getClass().getResourceAsStream("/images/DaUser.png"));
private final Image dukeImage = new Image(this.getClass().getResourceAsStream("/images/DaDuke.png"));

/**
* Initialises the MainWindow controller, which hosts the MeanDuke application
*/
@FXML
public void initialize() {
this.scrollPane.vvalueProperty().bind(this.dialogContainer.heightProperty());
Expand All @@ -47,6 +50,11 @@ private void handleUserInput() {
this.userInput.clear();
}

/**
* Tells this controller to display a message from MeanDuke
*
* @param message To be displayed
*/
public void showMessage(String message) {
this.dialogContainer.getChildren().addAll(
DialogBox.getDukeDialog(message, this.dukeImage)
Expand Down
15 changes: 14 additions & 1 deletion src/main/java/duke/core/MeanDuke.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,30 @@ public class MeanDuke {
//Creates an empty task list
private static TaskList taskList = new TaskList();

/**
* Initialises the MeanDuke chatbot
*
* @param controller The controller that will be controlling the graphical outputs of the chatbot
* @return String containing the introductory message of the chatbot
*/
public static String initialise(MainWindow controller) {
taskList = Storage.load(controller);
return "What do you want this time?";
}

/**
* Gets a response from MeanDuke given an input by the user
*
* @param input The string input by the user
* @param controller The controller controlling the graphical outputs of the chatbot
* @return String containing the response from MeanDuke
*/
public static String getResponse(String input, MainWindow controller) {
try {
Command cmd = Parser.parseUserInput(input, taskList);
String ret = cmd.execute();
Storage.save(taskList, controller);
if (cmd.isExitCommand()){
if (cmd.isExitCommand()) {
javafx.application.Platform.exit();
}
return ret;
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/duke/core/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
import duke.commands.DeleteCommand;
import duke.commands.ExitCommand;
import duke.commands.FindCommand;
import duke.exceptions.InvalidCommandException;
import duke.commands.ListCommand;
import duke.commands.MarkCommand;
import duke.commands.UnmarkCommand;
import duke.exceptions.InvalidCommandException;
import duke.tasks.TaskList;

/**
Expand Down Expand Up @@ -113,7 +113,8 @@ protected static AddCommand parseAdd(String inputWithoutAdd, TaskList taskList)
}
}

private static AddEventCommand parseAddEvent(TaskList taskList, String[] typeAndRemaining) throws InvalidCommandException {
private static AddEventCommand parseAddEvent(TaskList taskList, String[] typeAndRemaining)
throws InvalidCommandException {
try {
String[] descAndRemaining = typeAndRemaining[1].split("/from", 2);
String[] fromAndTo = descAndRemaining[1].split("/to", 2);
Expand All @@ -140,7 +141,8 @@ private static AddEventCommand parseAddEvent(TaskList taskList, String[] typeAnd
}
}

private static AddDeadlineCommand parseAddDeadline(TaskList taskList, String[] typeAndRemaining) throws InvalidCommandException {
private static AddDeadlineCommand parseAddDeadline(TaskList taskList, String[] typeAndRemaining)
throws InvalidCommandException {
try {
String[] descAndBy = typeAndRemaining[1].split("/by", 2);
String[] bydateAndBytime = descAndBy[1].strip().split(" ", 2);
Expand All @@ -155,7 +157,8 @@ private static AddDeadlineCommand parseAddDeadline(TaskList taskList, String[] t
}
}

private static AddTodoCommand parseAddTodo(TaskList taskList, String[] typeAndRemaining) throws InvalidCommandException {
private static AddTodoCommand parseAddTodo(TaskList taskList, String[] typeAndRemaining)
throws InvalidCommandException {
try {
String todoDesc = typeAndRemaining[1].strip();
return new AddTodoCommand(taskList, todoDesc);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/duke/core/Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.format.DateTimeParseException;
import java.util.NoSuchElementException;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.util.Scanner;

import duke.tasks.Deadline;
Expand Down

0 comments on commit d0bf77f

Please sign in to comment.