Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Brandon Owen Sjarif] iP #82

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
57 changes: 57 additions & 0 deletions Duke.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import java.io.*;
import java.util.Scanner;
import duke.error.DukeException;
import duke.main.*;
import duke.tasks.*;
import java.util.ArrayList;

public class Duke {
static int COMMAND_INDEX = 0;
static String FILE_PATH = "./duke.txt";
static String FILE_SEPARATOR = "-";
static String LINE_DIVIDER = "/";
static String COMMAND_WORD_EXIT = "bye";

// class methods
private Storage storage;
private TaskList tasks;
private Ui ui;

/**
* Initializes Duke and handles if there has been no previous usage of Duke
* @param filePath
*/
public Duke(String filePath) {
ui = new Ui();
storage = new Storage(filePath);
try {
tasks = new TaskList(storage.load());
} catch (FileNotFoundException e) {
ui.showLoadingError();
tasks = new TaskList();
}
}

/**
* Handles user input
* Exits Duke if user enters COMMAND_WORD_EXIT
*/
public void run() {
Ui.greet();
Scanner input = new Scanner(System.in);
String line = input.nextLine();
String command = line.split(" ")[COMMAND_INDEX];

while (!command.matches(COMMAND_WORD_EXIT)) {
Parser.parse(line);
line = input.nextLine();
command = line.split(" ")[COMMAND_INDEX];
}

Ui.exit();
}

public static void main(String[] args) {
new Duke(FILE_PATH).run();
}
}
3 changes: 3 additions & 0 deletions 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

203 changes: 194 additions & 9 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,213 @@

## Features

### Feature-ABC
### Add Tasks

Description of the feature.
There are 3 types of tasks that can be added to Duke:
1. Deadline
2. Event
3. Todo

### Feature-XYZ
For task Deadline and Event, you can also include a date using the '/by' tag.

Description of the feature.
### Mark Tasks as Done

You can mark the tasks that you have added as done so you remember which tasks you have completed!

### Mark Tasks as Undone

You can also unmark or mark the task as undone in case you mark the wrong task as done!

### List Tasks

You can list all the tasks that you have added to Duke in case you forget what you have added.

### Delete Tasks

You can also delete tasks from Duke in case you made a mistake when previously adding a task.

### Find Tasks

Duke also allows you to find the tasks that contains a certain keyword and will list them for you.

### Save your Tasks Locally

Duke will also save your tasks locally so that you can check what tasks you have anytime you want!

## Usage

### `Keyword` - Describe action
### `deadline` - Adds a deadline task

Describe the action and its outcome.
Adds a deadline task to Duke with a deadline date.

Example of usage:

`keyword (optional arguments)`
`deadline CS2113 Individual Project /by today`

Expected outcome:

Message that the deadline task has been added to Duke along with the number of tasks in Duke.

```
------------------------------------------------------------
Got it. I've added this task:
[D][ ] CS2113 Individual Project (by: today)
Now you have 1 tasks in the list.
------------------------------------------------------------
```


### `event` - Adds an event task

Adds an event task to Duke with an event date.

Example of usage:

`event CS2113 /on Thursday`

Expected outcome:

Message that the event task has been added to Duke along with the number of tasks in Duke.

```
------------------------------------------------------------
Got it. I've added this task:
[E][ ] CS2113 Tutorial (on: Thursday)
Now you have 2 tasks in the list.
------------------------------------------------------------
```

### `todo` - Adds a todo task

Adds a todo task to Duke.

Example of usage:

`todo Individual Project ReadMe`

Expected outcome:

Description of the outcome.
Message that the todo task has been added to Duke along with the number of tasks in Duke.

```
expected output
------------------------------------------------------------
Got it. I've added this task:
[T][ ] Individual Project ReadMe
Now you have 3 tasks in the list.
------------------------------------------------------------
```

### `list` - Lists all the tasks in Duke

Lists all the tasks you have added into Duke.

Example of usage:

`list`

Expected outcome:

A list of all the tasks in Duke.

```
------------------------------------------------------------
Here are the tasks in your list:
[D][ ] CS2113 Individual Project (by: today)
[E][ ] CS2113 Tutorial (on: Thuraday)
[T][ ] Individual Project ReadMe
------------------------------------------------------------
```

### `delete` - Delete a task from Duke

Delete a task from Duke based on the task index.

Example of usage:

`delete 1`

Expected outcome:

A message of which task has been deleted from Duke.

```
------------------------------------------------------------
Noted. I've removed this task:
[D][ ] CS2113 Individual Project (by: today)
------------------------------------------------------------
```

### `mark` - Mark a task as done in Duke

Marks a task as done based on the task index.

Example of usage:

`mark 1`

Expected outcome:

A message showing that the task has been done.

```
------------------------------------------------------------
Nice! I've marked this task as done:
[E][X] CS2113 Tutorial (on: Thursday)
------------------------------------------------------------
```

### `unmark` - Mark a task as not done in Duke

Marks a task as not done based on the task index.

Example of usage:

`unmark 1`

Expected outcome:

A message showing that the task has been undone.

```
------------------------------------------------------------
OK, I've marked this task as not done yet:
[E][ ] CS2113 Tutorial (on: Thursday)
------------------------------------------------------------
```

### `find` - Finds all tasks that contain a certain keyword

Finds all the tasks that contain a keyword you have inputted!

Example of usage:

`find Tutorial`

Expected outcome:

A list of all the matching tasks in Duke.

```
------------------------------------------------------------
Here are the tasks in your list:
1. [E][ ] CS2113 Tutorial (on: Thursday)
------------------------------------------------------------
```

### `bye` - Exits Duke

Leaves Duke.

Example of usage:

`bye`

Expected outcome:

A signing off message from Duke.

```
------------------------------------------------------------
Bye. Hope to see you again soon!
------------------------------------------------------------
```
2 changes: 2 additions & 0 deletions duke.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
E- CS2113 Tutorial -Thuraday
T- Individual Project ReadMe-
File renamed without changes.
Binary file added duke/error/DukeException.class
Binary file not shown.
7 changes: 7 additions & 0 deletions duke/error/DukeException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package duke.error;

public class DukeException extends Exception {
public DukeException(String errorMessage) {
super(errorMessage);
}
}
Loading