Skip to content
Open
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
d839859
Add Gradle support
May 24, 2020
784ada6
Implemented skeletal functionality to Duke, echos all, exits with bye
sherrpass Aug 19, 2021
3099a61
Add the ability to store whatever text entered by the user and displa…
sherrpass Aug 19, 2021
8225235
Add the ability to mark tasks as done.
sherrpass Aug 19, 2021
e4e2572
Add support for tracking three types of tasks: Todo, Event and Deadline
sherrpass Aug 19, 2021
dd8baab
semi-automate the testing of Duke
sherrpass Aug 19, 2021
406d820
Add errors such as incorrect inputs entered by the user
sherrpass Aug 19, 2021
7fb4963
Add Delete functionality
sherrpass Aug 19, 2021
9ff00d5
Tidy up code
sherrpass Aug 19, 2021
10fca14
Add Save to and Load from capabilities from hard disk
sherrpass Aug 26, 2021
d5c5c83
Add dates for deadlines and events, add new occuring function
sherrpass Aug 26, 2021
188b6ab
Merge branch 'branch-Level-7'
sherrpass Aug 26, 2021
2ed2893
Merge branch 'branch-Level-8'
sherrpass Aug 26, 2021
47516e5
Extract out closely related code as classes
sherrpass Aug 27, 2021
f8a5b52
Shift all files into Duke package
sherrpass Aug 27, 2021
1d97570
Add Junit Test for Storage and Deadline classes
sherrpass Aug 28, 2021
c730033
Add Javadoc
sherrpass Aug 28, 2021
d1ad490
Fix styling and naming to fit coding standards
sherrpass Aug 28, 2021
edebd71
Add functionality to find tasks by queries.
sherrpass Aug 28, 2021
4feab0a
Merge branch 'branch-A-JavaDoc'
sherrpass Aug 28, 2021
a98da27
Merge branch 'branch-A-CodingStandard'
sherrpass Aug 28, 2021
c0ab76b
Merge branch 'branch-Level-9'
sherrpass Aug 28, 2021
151e8d7
Merge remote-tracking branch 'origin/add-gradle-support' into A-Gradle
sherrpass Sep 2, 2021
a5257cb
Add gradle
sherrpass Sep 2, 2021
1ddb630
Merge branch 'A-Gradle'
sherrpass Sep 2, 2021
54bd1f7
Add Checkstyle to detect style violations, clean up violations
sherrpass Sep 2, 2021
91f63af
Add GUI using JavaFC
sherrpass Sep 3, 2021
36ac23c
Merge branch 'Level-10'
sherrpass Sep 3, 2021
6b1fa17
Add Assert feature
sherrpass Sep 9, 2021
e16ee69
Improve code quality
sherrpass Sep 9, 2021
18b8e5b
Merge pull request #2 from sherrpass/branch-A-Assertions
sherrpass Sep 14, 2021
3e1f1f7
Merge branch 'master' into branch-A-CodeQuality
sherrpass Sep 14, 2021
66de513
Merge pull request #3 from sherrpass/branch-A-CodeQuality
sherrpass Sep 14, 2021
525fa21
Implement undo command
sherrpass Sep 14, 2021
f56aba8
Merge pull request #4 from sherrpass/branch-BCD-Extension
sherrpass Sep 14, 2021
0be78e1
Support undoing multiple commands.
sherrpass Sep 15, 2021
e686719
Add extra exception handling, change profile pictures, add ui screenshot
sherrpass Sep 17, 2021
af7c1a5
Set theme jekyll-theme-slate
sherrpass Sep 17, 2021
6abe1b1
Update user guide in README.md and renamed Duke class to DukeMaster
sherrpass Sep 17, 2021
ba5770c
Merge branch 'master' of https://github.com/sherrpass/ip
sherrpass Sep 17, 2021
e74aa7c
Fix header issue in user guide
sherrpass Sep 17, 2021
5dec90c
Add response message to list command if task list is empty
sherrpass Sep 17, 2021
9a2c9eb
Add new DukeDataException subclass and error handling for invalid dat…
sherrpass Sep 17, 2021
b1ec315
Add undo to user guide.
sherrpass Sep 17, 2021
6ae3eb6
Clean up user guide.
sherrpass Sep 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ bin/

/text-ui-test/ACTUAL.txt
text-ui-test/EXPECTED-UNIX.TXT

/data/
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Duke project template
# duke.Duke project template

This is a project template for a greenfield Java project. It's named after the Java mascot _Duke_. Given below are instructions on how to use it.

Expand All @@ -13,7 +13,7 @@ Prerequisites: JDK 11, update Intellij to the most recent version.
1. If there are any further prompts, accept the defaults.
1. Configure the project to use **JDK 11** (not other versions) as explained in [here](https://www.jetbrains.com/help/idea/sdk.html#set-up-jdk).<br>
In the same dialog, set the **Project language level** field to the `SDK default` option.
3. After that, locate the `src/main/java/Duke.java` file, right-click it, and choose `Run Duke.main()` (if the code editor is showing compile errors, try restarting the IDE). If the setup is correct, you should see something like the below as the output:
3. After that, locate the `src/main/java/duke.Duke.java` file, right-click it, and choose `Run duke.Duke.main()` (if the code editor is showing compile errors, try restarting the IDE). If the setup is correct, you should see something like the below as the output:
```
Hello from
____ _
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/Duke.java

This file was deleted.

3 changes: 3 additions & 0 deletions src/main/java/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: duke.Duke

59 changes: 59 additions & 0 deletions src/main/java/duke/AddCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package duke;

import java.time.LocalDate;
import java.time.format.DateTimeParseException;

/**
* Represents a command to add tasks to the task list.
*/
public class AddCommand extends Command {
private String taskType;
private String description;
private LocalDate date;

/**
* Sole constructor for this class
*
* @param taskType Task type to add.
* @param description Task description.
* @param date Task date for events and deadlines.
* @throws DukeException If description is empty.
*/
public AddCommand(String taskType, String description, LocalDate date) throws DukeException {
if (description.equals("")) {
throw new DukeException("Please provide a description to the task.");
}
this.taskType = taskType;
this.description = description;
this.date = date;
}

/**
* Creates the task, adds it to the task list, updates the data file and displays the the new task to the UI.
*
* @param tasks Task list component.
* @param storage Storage component.
* @param ui UI component.
* @throws DukeException If invalid task type was provided.
*/
@Override
public void execute(TaskList tasks, Storage storage, Ui ui) throws DukeException {
Task newTask;
switch (taskType) {
case "todo":
newTask = new Todo(description);
break;
case "deadline":
newTask = new Deadline(description, date);
break;
case "event":
newTask = new Event(description, date);
break;
default:
throw new DukeException("Invalid task type provided!");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coding standard for CS2103 requires switch statements to not have tab for case, take note to edit the default IDE settings!

}
tasks.addTask(newTask);
storage.updateTasks(tasks);
ui.showAddedNewTask(newTask, tasks);
}
}
15 changes: 15 additions & 0 deletions src/main/java/duke/Command.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package duke;

/**
* Represents a generic command.
*/
public abstract class Command {
/**
* Executes the command.
*
* @param tasks Task list component.
* @param storage Storage component.
* @param ui UI component.
*/
public abstract void execute(TaskList tasks, Storage storage, Ui ui);
}
58 changes: 58 additions & 0 deletions src/main/java/duke/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package duke;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

/**
* Represents a deadline task.
*/
public class Deadline extends Task {
protected LocalDate by;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should perhaps be private since there is already a getter method that exposes this variable


/**
* Constructor for deadline class.
*
* @param description Deadline description.
* @param by Due date of deadline.
*/
public Deadline(String description, LocalDate by) {
super(description);
this.by = by;
}

/**
* Returns the task's details in a String.
*
* @return Task's details in a String.
*/
@Override
public String toString() {
return "[D]" + super.toString() + " (by: " + by.format(DateTimeFormatter.ofPattern("MMM dd yyyy")) + ")";
}

/**
* Returns deadline's due date.
*
* @return Deadline's due date.
*/
public LocalDate getDueDate() {
return by;
}

/**
* Returns task's details in a format that will be stored in the data file.
*
* @return Task's details in a format that will be stored in the data file.
*/
@Override
public String toStringData() {
return "D" + super.toStringData() + "|" + by;
}

@Override
public boolean matches(String query) {
return super.matches(query)
|| by.format(DateTimeFormatter.ofPattern("MMM dd yyyy")).toLowerCase().contains(query.toLowerCase())
|| query.equalsIgnoreCase("deadline");
}
Comment on lines +52 to +57

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A comment to explain this logic would be great

}
34 changes: 34 additions & 0 deletions src/main/java/duke/DeleteCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package duke;

/**
* Represents the delete task command.
*/
public class DeleteCommand extends Command {
private int taskIndex;

/**
* Constructor for DeleteCommand
*
* @param taskIndex Index of task to delete.
*/
public DeleteCommand(int taskIndex) {
this.taskIndex = taskIndex;
}

/**
* Removes task from task list, updates tasks in data file and shows that task has been removed on UI.
*
* @param tasks Task list component.
* @param storage Storage component.
* @param ui UI component.
*/
@Override
public void execute(TaskList tasks, Storage storage, Ui ui) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public void execute(TaskList tasks, Storage storage, Ui ui) {
public void execute(TaskList tasks, Storage storage, Ui ui) throws DukeException {

if (tasks.getLength() < taskIndex || 0 >= taskIndex) {
throw new DukeException("Invalid task index provided!");
}
Task removedTask = tasks.removeTask(taskIndex);
storage.updateTasks(tasks);
ui.showRemovedTask(removedTask, tasks);
}
}
58 changes: 58 additions & 0 deletions src/main/java/duke/Duke.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package duke;

/**
* The Duke Application.
*/
public class Duke {
private Storage storage;
private TaskList tasks;
private Ui ui;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be private final


/**
* Constructor for the Duke class.
* Initialises the UI, Storage and loads tasks from data file into Task List.
*
* @param dataFolderPath Path to data folder.
* @param dataFilePath Path to data file.
*/
public Duke(String dataFolderPath, String dataFilePath) {
ui = new Ui();
storage = new Storage(dataFolderPath, dataFilePath);
try {
tasks = new TaskList(storage.load());
} catch (DukeException e) {
ui.showLoadingError();
tasks = new TaskList();
}
}

/**
* Starts the Duke application.
*/
public void run() {
ui.showWelcome();
boolean isExit = false;
while (!isExit) {
try {
String fullCommand = ui.readCommand();
ui.showLine(); // show the divider line ("_______")
Command c = Parser.parse(fullCommand);
c.execute(tasks, storage, ui);
isExit = c instanceof ExitCommand;
} catch (DukeException e) {
ui.showError(e.getMessage());
} finally {
ui.showLine();
}
}
}

/**
* Main function.
*
* @param args Program input arguments.
*/
public static void main(String[] args) {
new Duke("./data", "./data/tasks.txt").run();
}
}
16 changes: 16 additions & 0 deletions src/main/java/duke/DukeException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package duke;

/**
* Represents an expected exception that occurred within the operation of the Duke application.
*/
public class DukeException extends RuntimeException {

/**
* Constructor for DukeException
*
* @param errorMessage Error message.
*/
public DukeException(String errorMessage) {
super(errorMessage);
}
}
57 changes: 57 additions & 0 deletions src/main/java/duke/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package duke;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

/**
* Represents an Event task.
*/
public class Event extends Task {
protected LocalDate at;

/**
* Constructor for Event.
*
* @param description Event's description.
* @param at Event's date.
*/
public Event(String description, LocalDate at) {
super(description);
this.at = at;
}

/**
* Returns the Event's details in a String.
*
* @return Event's details in a String.
*/
@Override
public String toString() {
return "[E]" + super.toString() + " (at: " + at.format(DateTimeFormatter.ofPattern("MMM dd yyyy")) + ")";
}

/**
* Returns Event's date.
* @return Event's date.
*/
public LocalDate getEventDate() {
return at;
}

/**
* Returns task's details in a format that will be stored in the data file.
*
* @return Task's details in a format that will be stored in the data file.
*/
@Override
public String toStringData() {
return "E" + super.toStringData() + "|" + at;
}

@Override
public boolean matches(String query) {
return super.matches(query)
|| at.format(DateTimeFormatter.ofPattern("MMM dd yyyy")).toLowerCase().contains(query.toLowerCase())
|| query.equalsIgnoreCase("event");
}
}
19 changes: 19 additions & 0 deletions src/main/java/duke/ExitCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package duke;

/**
* Represents an exit command that will end the application run.
*/
public class ExitCommand extends Command {

/**
* Displays goodbye message on UI.
*
* @param tasks Task list component.
* @param storage Storage component.
* @param ui UI component.
*/
@Override
public void execute(TaskList tasks, Storage storage, Ui ui) {
ui.showGoodbye();
}
}
17 changes: 17 additions & 0 deletions src/main/java/duke/FindCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package duke;

public class FindCommand extends Command{
private String query;

public FindCommand(String query) throws DukeException {
if (query.equals("")) {
throw new DukeException("Query should not be empty.");
}
this.query = query;
}

@Override
public void execute(TaskList tasks, Storage storage, Ui ui) {
ui.showMatchingTasks(query, tasks);
}
}
Loading