Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
db7b3b9
Added a FastReader
tehkokhoe Jan 19, 2022
f5cc97c
Level-1
tehkokhoe Jan 19, 2022
3a03048
Level-2
tehkokhoe Jan 19, 2022
98dd74f
added new Class Task
tehkokhoe Jan 20, 2022
82e3f0b
Level-3
tehkokhoe Jan 20, 2022
666bf39
Level-4 Added enum and additional functions
tehkokhoe Jan 20, 2022
3e42bcc
added a default constructor
tehkokhoe Jan 20, 2022
2623e50
Added Deadline class
tehkokhoe Jan 20, 2022
2f2eae3
added Event class
tehkokhoe Jan 20, 2022
c6c76f9
added ToDo class
tehkokhoe Jan 20, 2022
7253df2
Remove spaces on toString() method
tehkokhoe Jan 22, 2022
cd2cec9
Update accessor of enum, add error handling, and change display.
tehkokhoe Jan 22, 2022
074b3d5
Add test.
tehkokhoe Jan 22, 2022
220ea0d
Add DukeException class
tehkokhoe Jan 22, 2022
575afdb
Add delete feature
tehkokhoe Jan 22, 2022
53d3490
Add test cases for delete feature
tehkokhoe Jan 22, 2022
d355645
Add different display method for tasks for record purposes
tehkokhoe Jan 31, 2022
fb0bb08
Revert "Add different display method for tasks for record purposes"
tehkokhoe Jan 31, 2022
613ba0f
Add different display method for tasks for record purposes
tehkokhoe Jan 31, 2022
7ab38ce
Add save method and fix to coding standard
tehkokhoe Jan 31, 2022
c5d5d5e
Fix code to coding standard
tehkokhoe Jan 31, 2022
d418108
Allow dates to be recognized as the object 'Date'
tehkokhoe Feb 8, 2022
74b2b4d
Fix coding standards
tehkokhoe Feb 8, 2022
0fe362e
Merge branch 'branch-Level-8'
tehkokhoe Feb 8, 2022
70a8771
Adjust how date is displayed and recorded
tehkokhoe Feb 24, 2022
603ab96
Make program more OOP like
tehkokhoe Feb 24, 2022
80b2d81
Fix how date is parsed in event
tehkokhoe Feb 24, 2022
4967046
Package all classes
tehkokhoe Feb 24, 2022
5c83648
Add exception handler for invalid commands
tehkokhoe Feb 25, 2022
1536f41
Let parseCommand throw IllegalArgumentException
tehkokhoe Feb 25, 2022
1ac0efb
Add JUnit tests
tehkokhoe Feb 25, 2022
9ced633
Add checkstyle tests
tehkokhoe Feb 25, 2022
d83efcc
Add JavaDoc
tehkokhoe Feb 25, 2022
1642bc7
Fix coding standards
tehkokhoe Feb 25, 2022
dc491b3
Add find function
tehkokhoe Feb 25, 2022
f9dfa90
Merge branch 'branch-A-JavaDoc'
tehkokhoe Feb 25, 2022
4fdd0ad
Merge branch 'branch-A-CodingStandard'
tehkokhoe Feb 25, 2022
f429a7d
Merge branch 'branch-Level-9'
tehkokhoe Feb 25, 2022
5bee490
Add JavaDoc for find methods
tehkokhoe Feb 25, 2022
2b64ac0
Make a GFMD
tehkokhoe Feb 25, 2022
7145edb
no message
tehkokhoe Feb 25, 2022
8d43a6c
Add GUI
tehkokhoe Feb 26, 2022
b94ab8b
Merge branch 'branch-Level-10'
tehkokhoe Feb 26, 2022
4a75f69
Adjust JavaDoc
tehkokhoe Feb 26, 2022
4e8656a
Add assert
tehkokhoe Feb 26, 2022
f70a410
Merge branch 'branch-A-Assertions'
tehkokhoe Feb 26, 2022
d2fa202
Add duplicate detector
tehkokhoe Feb 26, 2022
d172734
Change UI to make more sense
tehkokhoe Feb 26, 2022
c78b885
Set theme jekyll-theme-architect
tehkokhoe Feb 26, 2022
86ccd94
Add User Guide
tehkokhoe Feb 26, 2022
1ec936f
Merge branch 'master' of https://github.com/tehkokhoe/ip
tehkokhoe Feb 26, 2022
79edc3b
Update dateformat links in User Guide
tehkokhoe Feb 26, 2022
32b47dc
Adjusted coding quality issues
tehkokhoe Feb 26, 2022
1a2789b
Add Ui screenshot
tehkokhoe Feb 26, 2022
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
398 changes: 398 additions & 0 deletions config/checkstyle/checkstyle.xml

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions config/checkstyle/suppressions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0"?>

<!DOCTYPE suppressions PUBLIC
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
"https://checkstyle.org/dtds/suppressions_1_2.dtd">

<suppressions>
<suppress checks="JavadocType" files=".*Test\.java"/>
<suppress checks="MissingJavadocMethodCheck" files=".*Test\.java"/>
</suppressions>
92 changes: 81 additions & 11 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,98 @@

## Features

### Feature-ABC
### Adding a ToDo task: `todo`

Description of the feature.
Adds a ToDo task to the task list.

### Feature-XYZ
Format: `todo TASK_DESCRIPTION`

Description of the feature.
Example: `todo read book`

## Usage
### Adding a Deadline task: `deadline`

### `Keyword` - Describe action
Adds a Deadline task to the task list.

Describe the action and its outcome.
Format: `deadline TASK_DESCRIPTION /by DATE`

Example of usage:
Example: `deadline return book /by 10/02/2024 1100`

`keyword (optional arguments)`
See [dateformat](https://github.com/tehkokhoe/ip/tree/master/docs#viewing-accepted-date-formats-dateformat) for accepted formats for date input.

### Adding an Event task: `event`

Adds an Event task to the task list.

Format: `event TASK_DESCRIPTION /at START_DATE[-END_DATE]`

Example:
- `event book fair /at 09/11/2022 1200-1300`
- `event lunch date /at 07/08/2022 1300`
- `event dinner date /at 04/12/2022`

See [dateformat](https://github.com/tehkokhoe/ip/tree/master/docs#viewing-accepted-date-formats-dateformat) for accepted formats for date input.

### Viewing your task list: `list`

Displays your task list.

### Marking a task as done: `mark`

Marks a task as done in your task list.

format: `mark INDEX`

Example: `mark 1`

Expected outcome:
```
Nice! I've marked this task as done:
[T][X] read book
```

### Marking a task as not done: `unmark`

Marks a task as not done in your task list.

format: `unmark INDEX`

Example: `unmark 2`

Expected outcome:
```
OK, I've marked this task as not done yet:
[T][ ] eat fish
```

### Deleting a task: `delete`

Deletes a task in your task list.

Description of the outcome.
format: `delete INDEX`

Example: `delete 3`

Expected outcome:
```
expected output
Noted. I've removed this task:
[T][ ] run
Now you have 2 task(s) in the list
```

### Finding tasks with specific keyword: `find`

Finds tasks that contains a keyword in the list.

format: `find KEYWORD`

Example: `find book`

Expected outcome:
```
Here are the matching tasks in your list:
1. [T][X] read book
```

### Viewing accepted date formats: `dateformat`

Displays a list of available date formats for input.
Binary file added docs/Ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
theme: jekyll-theme-architect
10 changes: 0 additions & 10 deletions src/main/java/Duke.java

This file was deleted.

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

public enum Command {
BYE {
public boolean isRunning() {
return false;
}
},
LIST {
public boolean isRunning() {
return true;
}
},
MARK {
public boolean isRunning() {
return true;
}
},
UNMARK {
public boolean isRunning() {
return true;
}
},
TODO {
public boolean isRunning() {
return true;
}
},
DEADLINE {
public boolean isRunning() {
return true;
}
},
EVENT {
public boolean isRunning() {
return true;
}
},
DELETE {
public boolean isRunning() {
return true;
}
},
DATEFORMAT {
public boolean isRunning() {
return true;
}
},
FIND {
public boolean isRunning() {
return true;
}
};

public abstract boolean isRunning();
}


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

import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.DateTimeFormatterBuilder;
import org.joda.time.format.DateTimeParser;

public class Deadline extends Task {
private String byString;
private DateTime byDate;

/**
* Constructs a {@link Task} that has a date associated to it. The date
* associated is normally the date that the {@link Task} should be finished.
*
* @param task the description of the task.
* @param byString the due date of the task.
*/
public Deadline(String task, String byString) {
super(task);
this.byString = byString;

try {
DateTimeParser[] dateParsers = {
DateTimeFormat.forPattern("d/MM/yyyy").getParser(),
DateTimeFormat.forPattern("yyyy-MM-dd").getParser(),
DateTimeFormat.forPattern("HHmm").getParser(),
DateTimeFormat.forPattern("d/MM/yyyy HHmm").getParser(),
DateTimeFormat.forPattern("yyyy-MM-dd HHmm").getParser(),
};
DateTimeFormatter formatter = new DateTimeFormatterBuilder().append(null, dateParsers).toFormatter();
DateTime date = formatter.parseDateTime(byString);
this.byDate = date;
} catch (UnsupportedOperationException e) {
this.byDate = null;
} catch (IllegalArgumentException e) {
this.byDate = null;
}
}

@Override
public String toString() {
if (this.byDate == null) {
return "[D]" + super.toString() + " (by: " + byString + ")";
} else {
String formattedDate = DateTimeFormat.forPattern("MMM dd yyyy h:mm a").print(byDate);
return "[D]" + super.toString() + " (by: " + formattedDate + ")";
}
}

@Override
public String toRecord() {
return "D | " + super.toRecord() + " | " + byString;
}
}
146 changes: 146 additions & 0 deletions src/main/java/duke/Duke.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
package duke;

import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.layout.VBox;

public class Duke {
private ScrollPane scrollPane;
private VBox dialogContainer;
private TextField userInput;
private Button sendButton;
private Scene scene;
private Image user = new Image(this.getClass().getResourceAsStream("/images/DaUser.png"));
private Image duke = new Image(this.getClass().getResourceAsStream("/images/DaDuke.png"));
private UI ui;
private Storage storage;
private TaskList tasks;

/**
* Constructs an instance of the main program, by setting up the
* {@link UI}, {@link Storage}, and loads the existing {@link TaskList}
* or creates a new {@link TaskList} if one does not already exist.
*/
public Duke() {
ui = new UI();
storage = new Storage();
try {
tasks = new TaskList(storage.load());
} catch (DukeException e) {
ui.showLoadingError(e.getMessage());
tasks = new TaskList();
}
}

/**
* Displays start screen. Runs program and keeps the program running until
* user exits. Accepts user input while running.
*/
public void run() {
ui.startScreen();
boolean isRunning = true;
while (isRunning) {
String[] inputs = Parser.parseInput(ui);
UI.startLine();

try {
Command cmd = Parser.parseCommand(inputs);
this.execute(cmd, inputs);
isRunning = cmd.isRunning();
} catch (IllegalArgumentException e) {
ui.showError(UI.getIndent() + "Invalid Command: " + inputs[0]);
}

UI.endLine();
}
}

public static void main(String[] args) {
new Duke().run();
}

/**
* Executes {@link Command} with inputs given and returns a response.
*
* @param cmd one of the commands given in the enum {@link Command}.
* @param inputs the user input the has been split into command and description.
* @return the response after executing command.
* @see Command
*/
public String execute(Command cmd, String[] inputs) {
try {
String result = "";
switch (cmd) {
case BYE:
ui.byeDisplay();
assert result == "";
break;
case LIST:
result = tasks.list();
assert result != "";
break;
case MARK:
result = tasks.mark(inputs);
storage.save(tasks.getTasks());
assert result != "";
break;
case UNMARK:
result = tasks.unmark(inputs);
storage.save(tasks.getTasks());
assert result != "";
break;
case TODO:
result = tasks.addToDo(inputs);
storage.save(tasks.getTasks());
assert result != "";
break;
case DEADLINE:
result = tasks.addDeadline(inputs);
storage.save(tasks.getTasks());
assert result != "";
break;
case EVENT:
result = tasks.addEvent(inputs);
storage.save(tasks.getTasks());
assert result != "";
break;
case DELETE:
result = tasks.delete(inputs);
storage.save(tasks.getTasks());
assert result != "";
break;
case DATEFORMAT:
result = ui.showDateFormats();
assert result != "";
break;
case FIND:
result = tasks.find(inputs);
assert result != "";
break;
default:
throw new IllegalStateException(UI.getIndent() + "Unexpected value: " + cmd);
}
return result;
} catch (NumberFormatException e) {
return ui.showError(UI.getIndent() + "☹ OOPS!!! Task number given is not suitable");
} catch (DukeException | IllegalStateException e) {
return ui.showError(e.getMessage());
} catch (IllegalArgumentException e) {
return ui.showError(UI.getIndent() + "Invalid command: " + cmd);
}
}

public String getResponse(String input) {
String[] inputs = Parser.parseGuiInput(input);
try {
Command cmd = Parser.parseCommand(inputs);
assert cmd == Command.valueOf(inputs[0]);
return this.execute(cmd, inputs);
} catch (IllegalArgumentException e) {
return ui.showError(UI.getIndent() + "Invalid Command: " + inputs[0]);
}
}
}
Loading