Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
5296d43
customize welcome message
dyahnafisah Aug 29, 2021
4080854
add a program to greet the user, echo the command, and exit
dyahnafisah Aug 29, 2021
856fe73
create Task class
dyahnafisah Aug 29, 2021
3c0be23
add a method to add tasks to the list
dyahnafisah Aug 29, 2021
dc262ae
add a method to mark completed tasks
dyahnafisah Aug 29, 2021
c96e2ce
fix the code according to the coding standard
dyahnafisah Aug 29, 2021
2f6b19d
create ToDo class as the extension of Task class
dyahnafisah Sep 4, 2021
88f5f62
create Deadline class as the extension of Task class
dyahnafisah Sep 4, 2021
181e7a3
create Event class as the extension of Task class
dyahnafisah Sep 4, 2021
ed1269b
update Task class
dyahnafisah Sep 4, 2021
a58b496
add methods to create todos, deadlines, and events
dyahnafisah Sep 4, 2021
812be1d
fix coding standard and code quality
dyahnafisah Sep 8, 2021
48d780b
create classes to handle specific exceptions
dyahnafisah Sep 8, 2021
6aefef8
update the program to handle some possible errors
dyahnafisah Sep 8, 2021
2bc6534
divide the classes into 3 packages
dyahnafisah Sep 8, 2021
59aa07a
Update method to handle errors
dyahnafisah Sep 28, 2021
78dc2b8
Merge branch 'branch-Level-5'
dyahnafisah Sep 28, 2021
96cac2c
Update emptyToDoDescription method
dyahnafisah Sep 28, 2021
104d604
Merge branch 'branch-A-Packages'
dyahnafisah Sep 28, 2021
151b4e9
Use Collections to store data
dyahnafisah Sep 28, 2021
899bae0
Add a method to delete task
dyahnafisah Sep 28, 2021
f27181d
Handle error for empty delete task number
dyahnafisah Sep 28, 2021
e9dd4b8
Create method to read and save file
dyahnafisah Sep 30, 2021
fcf6127
Handle error when directory not found
dyahnafisah Sep 30, 2021
535aae3
Merge branch 'branch-Level-6'
dyahnafisah Sep 30, 2021
31c05af
Merge branch 'branch-Level-7'
dyahnafisah Sep 30, 2021
edd7dc1
rename to duke
dyahnafisah Sep 30, 2021
3018c01
Create more classes
dyahnafisah Sep 30, 2021
e155601
Modify Deadline and Event to have LocalDate parameter
dyahnafisah Sep 30, 2021
9848f83
Add a method to find task based on a specific keyword
dyahnafisah Sep 30, 2021
f9f2eef
Merge pull request #1 from dyahnafisah/branch-Level-8
dyahnafisah Oct 1, 2021
5f6e945
Merge branch 'master' of https://github.com/dyahnafisah/ip into branc…
dyahnafisah Oct 1, 2021
53a2e5a
Add JavaDoc
dyahnafisah Oct 1, 2021
f772fb1
Merge pull request #3 from dyahnafisah/A-JavaDoc
dyahnafisah Oct 1, 2021
3d37fda
Add more JavaDoc
dyahnafisah Oct 1, 2021
c69cd5f
Add the User Guide
dyahnafisah Oct 1, 2021
94b4d6b
Delete manifest to add artifact
dyahnafisah Oct 1, 2021
6a2c795
Fix some bugs
dyahnafisah Oct 1, 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
4 changes: 4 additions & 0 deletions data/duke.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[T][X] read book
[D][X] return book /by Jun 1 2021
[E][ ] project meeting /at Aug 6 2021
[T][X] join sports club
125 changes: 116 additions & 9 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,135 @@

## Features

### Feature-ABC
### Add Tasks

Description of the feature.
Allows user to add different type of tasks to the list.

### Feature-XYZ
### Mark Tasks as Done

Description of the feature.
Allows user to mark tasks as completed.

### Delete Tasks

Allows user to remove tasks from the list.

### Search for Tasks

Allows user to search for some specific tasks within the list using a keyword.

### Data Storage

Allows the user to read and store the tasks from and to the directory `data/duke.txt`.

## Usage

### `Keyword` - Describe action
### `todo` - Add ToDo

Describe the action and its outcome.
Add ToDo type of task to the list and display a completion message.

Example of usage:

`keyword (optional arguments)`
`todo workout`

Expected outcome:

```
Ok, I've added this task:
[T][ ] workout
Now you have 6 tasks in the list. Anything else?
```

### `deadline` - Add Deadline

Add Deadline type of task with the date of format `yyyy-MM-dd` to the list and display a completion message with a date of format `MMM d yyyy`.

Example of usage:

`deadline finish ip /by 2021-10-01`

Expected outcome:

```
Ok, I've added this task:
[D][ ] finish ip /by Oct 1 2021
Now you have 7 tasks in the list. Anything else?
```

### `event` - Add Event

Add Event type of task with the date of format `yyyy-MM-dd` to the list and display a completion message with a date of format `MMM d yyyy`.

Example of usage:

`event attend meeting /at 2021-10-03`

Expected outcome:

```
Ok, I've added this task:
[E][ ] attend meeting /at Oct 3 2021
Now you have 8 tasks in the list. Anything else?
```

### `list` - Display Tasks

Print all the tasks in the list.

Example of usage:

`list`

Expected outcome:

Description of the outcome.
```
1.[T][X] read book
2.[D][ ] return book /by Jun 1 2021
3.[E][ ] project meeting /at Aug 6 2021
4.[T][X] join sports club
```

### `done` - Mark Task as Done

Mark completed task as done using the number of the respective task in the list.

Example of usage:

`done 2`

Expected outcome:

```
expected output
Congratulations! You have completed the task: [D][X] return book /by Jun 1 2021
```

### `delete` - Delete Task

Remove task from the list using the number of the respective task in the list.

Example of usage:

`delete 7`

Expected outcome:

```
Noted. I've removed this task:
[D][ ] finish ip /by Oct 1 2021
Now you have 7 tasks in the list. Anything else?
```

### `find` - Find Tasks

Find some tasks in the list that contain a keyword.

Example of usage:

`find book`

Expected outcome:

```
Here are the matching tasks in your list:
1.[T][X] read book
2.[D][X] return book /by Jun 1 2021
```
10 changes: 0 additions & 10 deletions src/main/java/Duke.java

This file was deleted.

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

import duke.task.Task;
import java.util.ArrayList;
import java.io.IOException;

public class Duke {
private static final String PATH = "data/duke.txt";
private static Ui ui;
private static Storage storage;
private static Parser parser;

/**
* Constructor class for Duke program.
* Initializes a UI and Storage class for the program.
*/
public Duke() {
ui = new Ui();
storage = new Storage();
}

/**
* Takes in user input repeatedly.
* Terminates when a user inputs <b>bye</b>.
* @throws IOException
*/
public static void run() throws IOException {
ArrayList<Task> tasksArrayList = new ArrayList<>();
ui.showWelcomeMessage();
tasksArrayList = storage.loadData();
parser.executeProgramWithErrorHandlings(tasksArrayList);
ui.exitProgram();
}

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

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

import duke.exceptions.*;
import duke.task.*;

import java.io.*;
import java.time.format.*;
import java.util.Scanner;
import java.util.ArrayList;

/**
* Contains the various actions taken when a user input a command to the program.
* Allowed commands are <b>todo, deadline, event, list, done, delete, find, bye</b>.
*/
public class Parser {

private static final String COMMAND_EXIT_WORD = "bye";
private static final String COMMAND_LIST_WORD = "list";
private static final String COMMAND_DONE_WORD = "done";
private static final String COMMAND_TODO_WORD = "todo";
private static final String COMMAND_DEADLINE_WORD = "deadline";
private static final String COMMAND_EVENT_WORD = "event";
private static final String COMMAND_DELETE_WORD = "delete";
private static final String COMMAND_FIND_WORD = "find";
private static final String[] COMMAND_WORDS_LIST = {COMMAND_TODO_WORD, COMMAND_DEADLINE_WORD, COMMAND_EVENT_WORD,
COMMAND_LIST_WORD, COMMAND_DONE_WORD, COMMAND_EXIT_WORD, COMMAND_DELETE_WORD, COMMAND_FIND_WORD};
private static final String PATH = "data/duke.txt";
private static final Scanner INPUT_COMMAND = new Scanner(System.in);
private static TaskList taskList = new TaskList();
private static Storage storage = new Storage();

/**
* Method to handle various exceptions in the program.
* @param tasksArrayList
* @throws IOException
*/
public static void executeProgramWithErrorHandlings(ArrayList<Task> tasksArrayList) throws IOException {
String inputLine = INPUT_COMMAND.nextLine();
;
while (!inputLine.equals(COMMAND_EXIT_WORD)) {
try {
executeCommand(tasksArrayList, inputLine.trim());
storage.writeToFile(PATH, tasksArrayList);
inputLine = INPUT_COMMAND.nextLine();
} catch (IllegalCommand e) {
System.out.println(" OOPS! I'm sorry, but I don't know what that means :(");
System.out.println(" I can only execute these commands: ");
for (int i = 1; i <= COMMAND_WORDS_LIST.length; i++) {
System.out.println(" " + i + ". " + COMMAND_WORDS_LIST[i - 1]);
}
inputLine = INPUT_COMMAND.nextLine();
} catch (EmptyDescription e) {
System.out.println(" OOPS! The description cannot be empty and must be separated using white space!");
System.out.println(" Please input again with the correct format!");
inputLine = INPUT_COMMAND.nextLine();
} catch (IllegalDeadlineInput e) {
System.out.println(" OOPS! Please input again using this format:");
System.out.println(" 'deadline <description> /by <due date>'");
inputLine = INPUT_COMMAND.nextLine();
} catch (DateTimeParseException e) {
System.out.println(" OOPS! Please input again the date using this format:");
System.out.println(" '2021-10-01'");
inputLine = INPUT_COMMAND.nextLine();
} catch (IllegalEventInput e) {
System.out.println(" OOPS! Please input again using this format:!");
System.out.println(" 'event <description> /at <event date>'");
inputLine = INPUT_COMMAND.nextLine();
} catch (EmptyTaskNumber e) {
System.out.println(" OOPS! Please specify the task number!");
System.out.println(" Example: 'done 1' or 'delete 2'");
inputLine = INPUT_COMMAND.nextLine();
} catch (NumberFormatException e) {
System.out.println(" OOPS! Please put only integer as the task number!");
System.out.println(" Example: 'done 1'");
inputLine = INPUT_COMMAND.nextLine();
} catch (IndexOutOfBoundsException e) {
System.out.println(" OOPS! You must have typed the wrong number. Please type in again correctly!");
inputLine = INPUT_COMMAND.nextLine();
} catch (IOException e) {
System.out.println(" OOPS! There was an error updating the file in the storage.");
}
}
}

/**
* Method to select which command should be executed based on the user input.
* @param tasksArrayList
* @param inputLine
* @throws IllegalCommand
* @throws EmptyDescription
* @throws IllegalDeadlineInput
* @throws IllegalEventInput
* @throws EmptyTaskNumber
*/
public static void executeCommand(ArrayList<Task> tasksArrayList, String inputLine) throws IllegalCommand, EmptyDescription, IllegalDeadlineInput, IllegalEventInput, EmptyTaskNumber {
String firstWord;
if (inputLine.contains(" ")) {
firstWord = inputLine.split(" ")[0];
} else {
firstWord = inputLine;
}
switch (firstWord) {
case COMMAND_TODO_WORD:
if (!inputLine.contains(" ")) {
throw new EmptyDescription();
}
taskList.addToDo(tasksArrayList, inputLine);
break;
case COMMAND_DEADLINE_WORD:
if (!inputLine.contains(" /by ")) {
throw new IllegalDeadlineInput();
}
taskList.addDeadline(tasksArrayList, inputLine);
break;
case COMMAND_EVENT_WORD:
if (!inputLine.contains(" /at ")) {
throw new IllegalEventInput();
}
taskList.addEvent(tasksArrayList, inputLine);
break;
case COMMAND_LIST_WORD:
taskList.printTasks(tasksArrayList);
break;
case COMMAND_DONE_WORD:
if (!inputLine.contains(" ")) {
throw new EmptyTaskNumber();
}
taskList.markAsDone(tasksArrayList, inputLine);
break;
case COMMAND_DELETE_WORD:
if (!inputLine.contains(" ")) {
throw new EmptyTaskNumber();
}
taskList.deleteTask(tasksArrayList, inputLine);
break;
case COMMAND_FIND_WORD:
if (!inputLine.contains(" ")) {
throw new EmptyDescription();
}
taskList.findTask(tasksArrayList, inputLine);
break;
default:
throw new IllegalCommand();
}

}

}
Loading