Skip to content

Commit

Permalink
Add JavaDoc for GUI classes
Browse files Browse the repository at this point in the history
  • Loading branch information
peppapighs committed Aug 31, 2022
1 parent f176a36 commit 6d4c3a6
Show file tree
Hide file tree
Showing 18 changed files with 86 additions and 34 deletions.
2 changes: 1 addition & 1 deletion data/tasks.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
T | 0 | peppapig
T | 0 | do your mom
10 changes: 10 additions & 0 deletions src/main/java/duke/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,21 @@

import java.io.IOException;

/**
* GUI application entry point
*
* @author Pontakorn Prasertsuk
*/
public class Main extends Application {
private static final String FILE_PATH = "data/tasks.txt";

private final Duke duke = new Duke(FILE_PATH);

/**
* Starts the GUI application
*
* @param stage JavaFX stage
*/
@Override
public void start(Stage stage) {
try {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/duke/command/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public AddCommand(Task task) {
* Executes the AddCommand.
*
* @param taskList the task list to be added to
* @param ui the user interface to be used
* @param storage the storage to be used
* @param ui the user interface to be used
* @param storage the storage to be used
* @return output to be shown
* @throws DukeException if an error occurs
*/
Expand All @@ -40,8 +40,8 @@ public String execute(TaskList taskList, Ui ui, Storage storage) throws DukeExce
ui.showOutput("Total tasks: " + taskList.getTaskList().size());
storage.save(taskList.getTaskList());

return "Task has been added!: " + task.toString() + "\n" + "Total tasks: " + taskList.getTaskList()
.size();
return "Task has been added!: " + task.toString() + "\n" + "Total tasks: "
+ taskList.getTaskList().size();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/duke/command/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public abstract class Command {
* Executes the Command
*
* @param taskList the task list to be mutated
* @param ui the user interface to be used
* @param storage the storage to be used
* @param ui the user interface to be used
* @param storage the storage to be used
* @return output to be shown
* @throws DukeException if an error occurs
*/
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/duke/command/DeleteCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public DeleteCommand(int index) {
* Executes the DeleteCommand
*
* @param taskList the task list to be mutated
* @param ui the user interface to be used
* @param storage the storage to be used
* @param ui the user interface to be used
* @param storage the storage to be used
* @return output to be shown
* @throws DukeException if an error occurs
*/
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/duke/command/ExitCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public class ExitCommand extends Command {
* Executes the ExitCommand
*
* @param taskList not being used
* @param ui the user interface to be used
* @param storage not being used
* @param ui the user interface to be used
* @param storage not being used
* @return output to be shown
* @throws DukeException if an error occurs
*/
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/duke/command/FindCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public FindCommand(String keyword) {
* Executes the FindCommand
*
* @param taskList the task list to be searched
* @param ui the user interface to be used
* @param storage not being used
* @param ui the user interface to be used
* @param storage not being used
* @return output to be shown
* @throws DukeException if an error occurs
*/
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/duke/command/ListCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public class ListCommand extends Command {
* Executes the ListCommand
*
* @param taskList the task list to be shown
* @param ui the user interface to be used
* @param storage not being used
* @param ui the user interface to be used
* @param storage not being used
* @return output to be shown
* @throws DukeException if an error occurs
*/
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/duke/command/MarkCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public MarkCommand(int index) {
* Executes the MarkCommand
*
* @param taskList the task list to be mutated
* @param ui the user interface to be used
* @param storage the storage to be used
* @param ui the user interface to be used
* @param storage the storage to be used
* @return output to be shown
* @throws DukeException if an error occurs
*/
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/duke/command/UnmarkCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public UnmarkCommand(int index) {
* Executes the UnmarkCommand
*
* @param taskList the task list to be mutated
* @param ui the user interface to be used
* @param storage the storage to be used
* @param ui the user interface to be used
* @param storage the storage to be used
* @return output to be shown
* @throws DukeException if an error occurs
*/
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/duke/controller/DialogBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,23 @@
import java.io.IOException;
import java.util.Collections;

/**
* Controller for the dialog box
*
* @author Pontakorn Prasertsuk
*/
public class DialogBox extends HBox {
@FXML
private Label dialog;
@FXML
private ImageView displayPicture;

/**
* Constructs a new DialogBox instance
*
* @param text the text to be displayed
* @param img the image of the dialog's owner
*/
private DialogBox(String text, Image img) {
try {
FXMLLoader fxmlLoader =
Expand All @@ -45,10 +56,24 @@ private void flip() {
setAlignment(Pos.TOP_LEFT);
}

/**
* Creates a new DialogBox instance for user
*
* @param text the text to be displayed
* @param img the image of the user
* @return the new DialogBox instance
*/
public static DialogBox getUserDialog(String text, Image img) {
return new DialogBox(text, img);
}

/**
* Creates a new DialogBox instance for bot
*
* @param text the text to be displayed
* @param img the image of the bot
* @return the new DialogBox instance
*/
public static DialogBox getDukeDialog(String text, Image img) {
var db = new DialogBox(text, img);
db.flip();
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/duke/controller/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.VBox;

/**
* Controller for the main window
*
* @author Pontakorn Prasertsuk
*/
public class MainWindow extends AnchorPane {
@FXML
private ScrollPane scrollPane;
Expand All @@ -21,11 +26,24 @@ public class MainWindow extends AnchorPane {
private Image userImage = new Image(this.getClass().getResourceAsStream("/images/user.png"));
private Image dukeImage = new Image(this.getClass().getResourceAsStream("/images/robot.png"));

/**
* Initializes the main window on rendered by the JavaFX application
*/
@FXML
public void initialize() {
scrollPane.vvalueProperty().bind(dialogContainer.heightProperty());
dialogContainer.getChildren()
.add(DialogBox.getDukeDialog("Hello from\n" + "______ _ \n"
+ "| ___ \\ | | \n" + "| |_/ / ___ | |__ \n"
+ "| ___ \\/ _ \\| '_ \\ \n" + "| |_/ / (_) | |_) |\n"
+ "\\____/ \\___/|_.__/ \n" + "What can I do for you?", dukeImage));
}

/**
* Sets the Duke instance for the application
*
* @param duke the Duke instance
*/
public void setDuke(Duke duke) {
this.duke = duke;
}
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/duke/task/Deadline.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public class Deadline extends Task {
/**
* Constructs a new Deadline instance
*
* @param title the name of the task
* @param title the name of the task
* @param status whether the task is completed or not
* @param date the deadline of the task
* @param date the deadline of the task
*/
public Deadline(String title, boolean status, String date) throws DateTimeParseException {
super(title, status);
Expand All @@ -33,9 +33,8 @@ public Deadline(String title, boolean status, String date) throws DateTimeParseE
*/
@Override
public String encode() {
return (SYMBOL + " | " + (this.status ?
"1" :
"0") + " | " + this.title + " | " + this.date);
return (SYMBOL + " | " + (this.status ? "1" : "0") + " | " + this.title + " | "
+ this.date);
}

@Override
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/duke/task/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public class Event extends Task {
/**
* Constructs a new Event instance
*
* @param title the name of the task
* @param title the name of the task
* @param status whether the task is completed or not
* @param date the date where the event occurs
* @param date the date where the event occurs
*/
public Event(String title, boolean status, String date) throws DateTimeParseException {
super(title, status);
Expand All @@ -33,9 +33,8 @@ public Event(String title, boolean status, String date) throws DateTimeParseExce
*/
@Override
public String encode() {
return (SYMBOL + " | " + (this.status ?
"1" :
"0") + " | " + this.title + " | " + this.date);
return (SYMBOL + " | " + (this.status ? "1" : "0") + " | " + this.title + " | "
+ this.date);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/duke/task/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public abstract class Task {
/**
* Constructs a new Task instance
*
* @param title the name of the task
* @param title the name of the task
* @param status whether the task is completed or not
*/
Task(String title, boolean status) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/duke/task/TaskList.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public TaskList delete(int index) throws DukeException {
/**
* Marks a task with status
*
* @param index the index of the task to be marked
* @param index the index of the task to be marked
* @param status the status of the task to be marked
* @return the task list after marking the task
* @throws DukeException if an error occurs
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/duke/task/Todo.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class Todo extends Task {
/**
* Constructs a new Todo instance
*
* @param title the name of the task
* @param title the name of the task
* @param status whether the task is completed or not
*/
public Todo(String title, boolean status) {
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/duke/ui/Ui.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
*/
public class Ui {

private static final String LOGO =
"______ _ \n" + "| ___ \\ | | \n" + "| |_/ / ___ | |__ \n" + "| ___ \\/ _ \\| '_ \\ \n" + "| |_/ / (_) | |_) |\n" + "\\____/ \\___/|_.__/ \n";
private static final String LOGO = "______ _ \n" + "| ___ \\ | | \n"
+ "| |_/ / ___ | |__ \n" + "| ___ \\/ _ \\| '_ \\ \n" + "| |_/ / (_) | |_) |\n"
+ "\\____/ \\___/|_.__/ \n";

/**
* Shows the logo of the application
Expand Down

0 comments on commit 6d4c3a6

Please sign in to comment.