Skip to content

Commit

Permalink
Merge branch 'branch-A-MoreTesting' into branch-A-BetterGui
Browse files Browse the repository at this point in the history
  • Loading branch information
HarishB99 committed Feb 21, 2025
2 parents 4f6d54f + 1f25439 commit a6fe9e8
Show file tree
Hide file tree
Showing 48 changed files with 933 additions and 237 deletions.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ repositories {

dependencies {
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.10.0'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.10.0'
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.10.0'

String javaFxVersion = '17.0.7'
Expand All @@ -27,6 +28,8 @@ dependencies {
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'linux'

implementation group: 'org.mockito', name: 'mockito-core', version: '5.15.2'
}

test {
Expand Down
62 changes: 57 additions & 5 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# Bhaymax User Guide

// Update the title above to match the actual product name

// Product screenshot goes here

// Product intro goes here

## Adding deadlines
## Greeting the chatbot (Optional)

Greets the chatbot. (And the chatbot greets you back!)

Format: `hello` __or__ `hi`

## Adding To-Do Items: `todo`

// Describe the action and its outcome.

Expand All @@ -24,7 +28,55 @@ expected output

// Feature details

## Adding Deadline Items: `deadline`

## Adding Events: `event`

## Listing all tasks and events: `list`

## Filtering list of tasks and events by date: `filter`

## Search for tasks with description matching keywords: `search`

## Marking a task as completed: `mark`

## Marking a task as _incomplete_: `unmark`

## Deleting a task: `delete`

## Clear the chat area: `clear`

Clears the chat (box) area.

Format: `clear`

## Exiting the program: `bye` or `exit`

Exits the program.

Format: `bye` __or__ `exit`

## Editing the data file

The data file is automatically created when a task is added to the program.
It is saved at `[JAR file location]/data/tasks.txt`.
Tasks are stored in the following format:

## Feature XYZ
`TASK_TYPE | TASK_COMPLETION_STATUS | TASK_DESCRIPTION |
[DUE_BY_DATE or START_DATE] | [END_DATE]`

// Feature details
- `TASK_TYPE`: The type of task. It can take one of three
values:
- `T` - Represents a to-do item
- `D` - Represents a deadline item
- `E` - Represents an event
- `TASK_COMPLETION_STATUS`: Indicates whether the task has been marked as completed. It can take one of two values:
- `1` - Indicates the task has been marked as completed
- `0` - Indicates the task has been marked as incomplete
- `TASK_DESCRIPTION`: A brief description about the task.
- `DUE_BY_DATE` (Required for deadline items): The date and time the deadline item is due by. Specified in the format `dd/MM/yyyy HH:mm`.
- E.g., You need to submit a report on March 2nd, 2025, at 11:59 pm. You will input this deadline as follows:
- `deadline submit report /by 02/03/2025 23:59`
- Note that the time is in _24-hour format_.
- `START_DATE` (Required by events): The date and time at which the event starts.
- `END_DATE` (Required by events): The date and time at which the event ends.
2 changes: 2 additions & 0 deletions src/main/java/bhaymax/command/ClearCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* Represents a {@code clear} command
*/
public class ClearCommand extends Command {
public static final String COMMAND_FORMAT = "clear";

@Override
public void execute(TaskList taskList, MainWindow mainWindowController, Storage storage) {
mainWindowController.clearChat(true);
Expand Down
21 changes: 17 additions & 4 deletions src/main/java/bhaymax/command/DeadlineCommand.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
package bhaymax.command;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;

import bhaymax.controller.MainWindow;
import bhaymax.exception.TaskAlreadyExistsException;
import bhaymax.exception.command.AttemptToCreateDuplicateTaskException;
import bhaymax.exception.command.InvalidCommandFormatException;
import bhaymax.exception.command.InvalidDateTimeFormatInCommandException;
import bhaymax.exception.file.FileWriteException;
import bhaymax.parser.Parser;
import bhaymax.storage.Storage;
import bhaymax.task.TaskList;
import bhaymax.task.timesensitive.Deadline;
Expand All @@ -13,13 +19,15 @@
* Represents a {@code deadline} command
*/
public class DeadlineCommand extends Command {
public static final String COMMAND_FORMAT = "deadline {description} /by " + Deadline.DUE_DATE_INPUT_FORMAT;

private static final String RESPONSE_FORMAT = "Noted. Adding: " + System.lineSeparator()
+ " %s" + System.lineSeparator()
+ "to your list of deadlines." + System.lineSeparator()
+ "You now have %d task%s to complete.";

private final String taskDescription;
private final String deadline;
private final LocalDateTime deadline;

/**
* Constructor for {@code DeadlineCommand}
Expand All @@ -28,9 +36,14 @@ public class DeadlineCommand extends Command {
* @param deadline the date and time the deadline will be due by, as a {@code String}
* @see bhaymax.parser.Parser#DATETIME_INPUT_FORMAT
*/
public DeadlineCommand(String taskDescription, String deadline) {
this.taskDescription = taskDescription;
this.deadline = deadline;
public DeadlineCommand(String taskDescription, String deadline) throws InvalidDateTimeFormatInCommandException {
try {
this.taskDescription = taskDescription;
this.deadline = LocalDateTime.parse(
deadline, DateTimeFormatter.ofPattern(Parser.DATETIME_INPUT_FORMAT));
} catch (DateTimeParseException e) {
throw new InvalidDateTimeFormatInCommandException();
}
}

@Override
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/bhaymax/command/DeleteCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
* Represents a {@code delete} command
*/
public class DeleteCommand extends Command {
public static final String COMMAND_FORMAT =
"delete {index number of task to be deleted - use 'list' to find the index}";

private static final String RESPONSE_FORMAT = "Noted. Removing: " + System.lineSeparator()
+ " %s" + System.lineSeparator()
+ "from your list of tasks." + System.lineSeparator();
Expand Down
30 changes: 24 additions & 6 deletions src/main/java/bhaymax/command/EventCommand.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
package bhaymax.command;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;

import bhaymax.controller.MainWindow;
import bhaymax.exception.TaskAlreadyExistsException;
import bhaymax.exception.command.AttemptToCreateDuplicateTaskException;
import bhaymax.exception.command.InvalidCommandFormatException;
import bhaymax.exception.command.InvalidDateTimeFormatInCommandException;
import bhaymax.exception.command.event.InvalidTimeRangeForEventException;
import bhaymax.exception.file.FileWriteException;
import bhaymax.parser.Parser;
import bhaymax.storage.Storage;
import bhaymax.task.TaskList;
import bhaymax.task.timesensitive.Event;
Expand All @@ -13,14 +20,17 @@
* Represents a {@code event} command
*/
public class EventCommand extends Command {
public static final String COMMAND_FORMAT = "event {description} /from " + Event.START_DATE_INPUT_FORMAT
+ " /to " + Event.END_DATE_INPUT_FORMAT;

private static final String RESPONSE_FORMAT = "Noted. Adding: " + System.lineSeparator()
+ " %s" + System.lineSeparator()
+ "to your list of events." + System.lineSeparator()
+ "You now have %d task%s to complete.";

private final String taskDescription;
private final String start;
private final String end;
private final LocalDateTime start;
private final LocalDateTime end;

/**
* Constructor for {@code EventCommand}
Expand All @@ -30,10 +40,18 @@ public class EventCommand extends Command {
* @param end the date and time at which the event will end, as a {@code String}
* @see bhaymax.parser.Parser#DATETIME_INPUT_FORMAT
*/
public EventCommand(String taskDescription, String start, String end) {
this.taskDescription = taskDescription;
this.start = start;
this.end = end;
public EventCommand(String taskDescription, String start, String end)
throws InvalidDateTimeFormatInCommandException, InvalidTimeRangeForEventException {
try {
this.taskDescription = taskDescription;
this.start = LocalDateTime.parse(start, DateTimeFormatter.ofPattern(Parser.DATETIME_INPUT_FORMAT));
this.end = LocalDateTime.parse(end, DateTimeFormatter.ofPattern(Parser.DATETIME_INPUT_FORMAT));
if (this.end.isBefore(this.start)) {
throw new InvalidTimeRangeForEventException();
}
} catch (DateTimeParseException e) {
throw new InvalidDateTimeFormatInCommandException();
}
}

@Override
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/bhaymax/command/ExitCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* Represents an {@code exit} command
*/
public class ExitCommand extends Command {
public static final String COMMAND_FORMAT = "bye / exit";

@Override
public void execute(TaskList taskList, MainWindow mainWindowController, Storage storage) {
mainWindowController.showFarewellDialogBox();
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/bhaymax/command/FilterCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@

import bhaymax.controller.MainWindow;
import bhaymax.exception.command.InvalidCommandFormatException;
import bhaymax.parser.Parser;
import bhaymax.storage.Storage;
import bhaymax.task.TaskList;

/**
* Represents a {@code filter} command
*/
public class FilterCommand extends Command {
public static final String COMMAND_FORMAT = "filter "
+ "{/on | /before | /after | /on_time | /before_time | /after_time} "
+ "{date (for /on | /before | /after): " + Parser.DATE_INPUT_FORMAT
+ " | date and time (for /on_time | /before_time | /after_time): " + Parser.DATETIME_INPUT_FORMAT + "}";

private final String dateTime;
private final FilterOption filterOption;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/bhaymax/command/FilterOption.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package bhaymax.command;

import bhaymax.exception.command.InvalidFilterOptionException;
import bhaymax.exception.command.filter.InvalidFilterOptionException;

/**
* Provides enumeration values representing the valid options that can be passed to the {@code filter} command
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/bhaymax/command/HelloCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* Represents a {@code hello} command
*/
public class HelloCommand extends Command {
public static final String COMMAND_FORMAT = "hello / hi";

@Override
public void execute(TaskList taskList, MainWindow mainWindowController, Storage storage) {
mainWindowController.showGreetingDialogBox();
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/bhaymax/command/ListCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* Represents a {@code list} command
*/
public class ListCommand extends Command {
public static final String COMMAND_FORMAT = "list";

@Override
public void execute(TaskList taskList, MainWindow mainWindowController, Storage storage) {
taskList.showTasks(mainWindowController);
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/bhaymax/command/MarkCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
* Represents a {@code mark} command
*/
public class MarkCommand extends Command {
public static final String COMMAND_FORMAT =
"mark {index number of task to be marked as completed - use 'list' to find the index}";

private static final String RESPONSE_FORMAT = "Congratulations on completing the task:" + System.lineSeparator()
+ " %s" + System.lineSeparator()
+ "I have marked it as complete.";
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/bhaymax/command/SearchCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* Represents a {@code search} command
*/
public class SearchCommand extends Command {
public static final String COMMAND_FORMAT = "search {search term or phrase}";

private final String searchTerm;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/bhaymax/command/TodoCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* Represents a {@code todo} command
*/
public class TodoCommand extends Command {
public static final String COMMAND_FORMAT = "todo {description}";

private static final String RESPONSE_FORMAT = "Noted. Adding: " + System.lineSeparator()
+ " %s" + System.lineSeparator()
+ "to your to-do list." + System.lineSeparator()
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/bhaymax/command/UnmarkCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
* Represents a {@code unmark} command
*/
public class UnmarkCommand extends Command {
public static final String COMMAND_FORMAT =
"unmark {index number of task to be marked as incomplete - use 'list' to find the index}";

private static final String RESPONSE_FORMAT = "Noted. Marking:" + System.lineSeparator()
+ " %s" + System.lineSeparator()
+ "as incomplete.";
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/bhaymax/controller/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ private void handleUserInput() {
if (input.isEmpty()) {
return;
}
this.dialogContainer.getChildren().addAll(this.getUserDialog(input));
this.dialogContainer.getChildren().addAll(this.getUserDialog(this.userInput.getText()));
try {
Command command = Parser.parse(input, this.tasks);
command.execute(this.tasks, this, this.storage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,4 @@ public class TaskAlreadyExistsException extends RuntimeException {
public TaskAlreadyExistsException() {
super(TaskAlreadyExistsException.ERROR_MESSAGE);
}

public TaskAlreadyExistsException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package bhaymax.exception.command;

import bhaymax.parser.Parser;

/**
* Thrown when a date provided by the user is not of valid format
*/
public class InvalidDateFormatInCommandException extends InvalidCommandFormatException {
public static final String ERROR_MESSAGE = "I don't recognise the format of the date you provided.";
public static final String ERROR_MESSAGE_FORMAT = "I don't recognise the format of the date you provided. "
+ "Format of date should be '%s'.";

public InvalidDateFormatInCommandException() {
super(InvalidDateFormatInCommandException.ERROR_MESSAGE);
super(String.format(InvalidDateFormatInCommandException.ERROR_MESSAGE_FORMAT, Parser.DATE_INPUT_FORMAT));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package bhaymax.exception.command;

import bhaymax.parser.Parser;

/**
* Thrown when a date and time provided by the user is not of valid format
*/
public class InvalidDateTimeFormatInCommandException extends InvalidCommandFormatException {
public static final String ERROR_MESSAGE_FORMAT = "I don't recognise the format of the date and time you provided. "
+ "Format of date should be '%s'.";

/**
* Default constructor for {@code InvalidDateTimeFormatInCommandException}
*/
public InvalidDateTimeFormatInCommandException() {
super(String.format(
InvalidDateTimeFormatInCommandException.ERROR_MESSAGE_FORMAT, Parser.DATETIME_INPUT_FORMAT));
}
}

This file was deleted.

Loading

0 comments on commit a6fe9e8

Please sign in to comment.