Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
08758df
Rename Duke to Chatbot
imaginer96 Aug 31, 2023
70db08d
Implemented skeletal chatbot functionality
imaginer96 Aug 31, 2023
f199592
Implemented Level 1 - echo, bye
imaginer96 Aug 31, 2023
74cd269
Implemented Level 2 - Add, list
imaginer96 Aug 31, 2023
89fbf7b
Implemented Level 3 - Mark as Done
imaginer96 Aug 31, 2023
c78ca99
Level 4. ToDos, Events, Deadlines implemented
imaginer96 Sep 6, 2023
fc69e5c
A-Inheritance Implemented
imaginer96 Sep 6, 2023
725a683
Implemented Level-5 with Exceptions
imaginer96 Sep 12, 2023
7f288f7
Merge branch 'branch-Level-5'
imaginer96 Sep 12, 2023
6d91851
Implemented A-Packages
imaginer96 Sep 12, 2023
45634a7
Merge branch 'branch-A-Packages'
imaginer96 Sep 12, 2023
05dfeaf
Implemented Level-6 with A-Collections using ArrayList
imaginer96 Sep 20, 2023
c6f11a2
Implemented Level-7
imaginer96 Sep 20, 2023
0321771
Merge branch 'branch-Level-6'
imaginer96 Sep 20, 2023
5526242
Fixed bug where Task status was not saved in storage file
imaginer96 Sep 20, 2023
a608f54
Removed static variable numOfTask
imaginer96 Sep 20, 2023
5e2946d
Removed numOfTask variable references
imaginer96 Sep 20, 2023
46504a4
Implemented A-MoreOOP
imaginer96 Oct 6, 2023
5b89da7
Implemented A-MoreOOP
imaginer96 Oct 6, 2023
c33523b
Implemented branch-Level-9
imaginer96 Oct 6, 2023
2026fdf
A-UserGuide
imaginer96 Oct 6, 2023
0465ace
Modified user guide
imaginer96 Oct 6, 2023
3c63edf
update docs
imaginer96 Oct 8, 2023
8b4c583
extracted most .println calls from Command to the Ui class
imaginer96 Oct 24, 2023
0838b6a
added command package
imaginer96 Oct 24, 2023
1e16cf3
Refactored if-else commands to individual classes
imaginer96 Oct 24, 2023
ba940d1
fixed bug where program exists upon exception
imaginer96 Oct 24, 2023
888536f
added function comments
imaginer96 Oct 24, 2023
5cc3861
Merge pull request #1 from imaginarys96/FinalImprovements
imaginarys96 Oct 24, 2023
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
187 changes: 176 additions & 11 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,194 @@
# User Guide
The Chatbot name is very intuitive - Chatbot.

## Features
1. list
2. mark
3. unmark
4. todo
5. deadline
6. event
7. delete
8. find

### Feature-list
List all tasks
### Feature-mark
Mark a task as done
### Feature-unmark
Unmark a task as done
### Feature-todo
Add a todo
### Feature-deadline
Add a deadline
### Feature-event
Add an event
### Feature-delete
Delete a task
### Feature-find
Find a task

### Feature-ABC

Description of the feature.

### Feature-XYZ

Description of the feature.

## Usage

### `Keyword` - Describe action
### `list` - list all tasks
List all the tasks recorded

Command: `list`

Argument: Nil

Example: `list`

Example of outcome:

Tasks are listed
```
____________________________________________________________
Here are the tasks in your list:
1.[T][X] read book
2.[D][ ] return book (by: June 6th)
3.[E][ ] project meeting (from: Aug 6th 2pm to: 4pm)
4.[T][X] join sports club
5.[T][ ] borrow book
____________________________________________________________
```

### `mark` - mark a task
Command: `mark`

Argument: <int> ID of the task

Example: `mark 1`

Example of outcome:

Task is marked as done

```
____________________________________________________________
Nice! I've marked this task as done:
[X] borrow new book
____________________________________________________________
```

### `unmark` - unmark a task
Mark a task as done

Describe the action and its outcome.
Command: `unmark`

Example of usage:
Argument: <int> ID of the task

`keyword (optional arguments)`
Example: `unmark 1`

Expected outcome:
Example of outcome:

Description of the outcome.
Task is unmarked

```
expected output
____________________________________________________________
OK, I've marked this task as not done yet:
[ ] borrow new book
____________________________________________________________
```

### `todo` - add a todo

Command: `todo`

Argument: <String> description of the task

Example: `todo borrow book`

Example of outcome:

Todo is added

```
____________________________________________________________
Got it. I've added this task:
[T][ ] borrow book
Now you have 5 tasks in the list.
____________________________________________________________
```

### `deadline` - add a deadline

Command: `deadline`

Argument: <String> description of the deadline

Example: `deadline return book /by Sunday`

Example of outcome:

Deadline is added

```
____________________________________________________________
Got it. I've added this task:
[D][ ] return book (by: Sunday)
Now you have 6 tasks in the list.
____________________________________________________________
```

### `event` - add an event

Command: `event`

Argument: <String> description of the event

Example: `event project meeting /from Mon 2pm /to 4pm`

Example of outcome:

Event is added

```
____________________________________________________________
Got it. I've added this task:
[E][ ] project meeting (from: Mon 2pm to: 4pm)
Now you have 7 tasks in the list.
____________________________________________________________
```
### `delete` - delete a task

Command: `delete`

Argument: <int> ID of the task to delete

Example: `delete 1`

Example of outcome:

Task is deleted

```
____________________________________________________________
Noted. I've removed this task:
[E][ ] project meeting (from: Aug 6th 2pm to: 4pm)
Now you have 4 tasks in the list.
____________________________________________________________
```

### `find` - find a task
Command: `find`

Argument: `String` What to search for

Example: `find book`

Example of outcome:

book is found

```
____________________________________________________________
Here are the matching tasks in your list:
[T][ ] borrow book
[T][ ] borrow new book
____________________________________________________________
```
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: chatbot.Chatbot

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

import chatbot.command.Command;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Chatbot {
private Storage storage;
private Parser parser;
private Ui ui;
private TaskList taskList;

public Chatbot() {
this.ui = new Ui();
this.storage = new Storage("./tasklist.txt");
this.parser = new Parser();
this.taskList = new TaskList();
}


/**
* Runs the main routine of the app
*
* @author Jeremy
* @since 2023-10-06
*/
public void run() throws IOException {
this.ui.showGreetingMessage();

ArrayList<String> lines = storage.parseFile(this.taskList.getTaskList());
for(String line : lines) {
try {
Command c = this.parser.parseCommand(line);
c.execute(this.taskList.getTaskList(), false);
} catch(ChatbotUnknownCommandException | ChatbotEmptyDescException e) {
this.ui.showError(e.getMessage(), true);
continue;
} catch (Exception e) {
this.ui.showError(e.getMessage(), false);
}
}

Scanner in = new Scanner(System.in);
String input = "";
while(!input.equals("bye")) {
try{
input = in.nextLine();
Command c = this.parser.parseCommand(input);
c.execute(this.taskList.getTaskList(), true);
} catch(ChatbotUnknownCommandException | ChatbotEmptyDescException e) {
this.ui.showError(e.getMessage(), true);
continue;
} catch (Exception e) {
this.ui.showError(e.getMessage(), false);
}
}
this.ui.showByeMessage();
}

public static void main(String[] args) throws Exception {
new Chatbot().run();
}
}
7 changes: 7 additions & 0 deletions src/main/java/chatbot/ChatbotEmptyDescException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package chatbot;

public class ChatbotEmptyDescException extends Exception {
public ChatbotEmptyDescException(String exceptionMsg) {
super(exceptionMsg);
}
}
7 changes: 7 additions & 0 deletions src/main/java/chatbot/ChatbotUnknownCommandException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package chatbot;

public class ChatbotUnknownCommandException extends Exception {
public ChatbotUnknownCommandException(String exceptionMsg) {
super(exceptionMsg);
}
}
15 changes: 15 additions & 0 deletions src/main/java/chatbot/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package chatbot;

public class Deadline extends Task {
protected String by;

public Deadline(String description, String by) {
super(description);
this.by = by;
}

@Override
public String toString() {
return "[D]" + super.toString() + " (by: " + by + ")";
}
}
16 changes: 16 additions & 0 deletions src/main/java/chatbot/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package chatbot;

public class Event extends Task {
protected String fromDate;
protected String toDate;
public Event(String description, String fromDate, String toDate) {
super(description);
this.fromDate = fromDate;
this.toDate = toDate;
}

@Override
public String toString() {
return "[E]" + super.toString() + " (from: " + this.fromDate + " to: " + this.toDate + ")";
}
}
35 changes: 35 additions & 0 deletions src/main/java/chatbot/Parser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package chatbot;

import chatbot.command.*;

public class Parser {
/**
* Parse the command and returns a Command object
*
* @param input The input to be parsed
* @author Jeremy
* @since 2023-10-06
*/
public Command parseCommand(String input) throws ChatbotUnknownCommandException {
if (input.equals("list")) {
return new ListCommand("list", input);
} else if (input.startsWith("mark ")) {
return new MarkCommand("mark", input);
} else if (input.startsWith("unmark ")) {
return new UnmarkCommand("unmark", input);
} else if (input.startsWith("todo")) {
return new TodoCommand("todo", input);
} else if (input.startsWith("deadline")) {
return new DeadlineCommand("deadline", input);
} else if (input.startsWith("event")) {
return new EventCommand("event", input);
} else if (input.startsWith("delete")) {
return new DeleteCommand("delete", input);
} else if (input.startsWith("find")) {
return new FindCommand("find", input);
} else {
// unknown command
throw new ChatbotUnknownCommandException(" ☹ OOPS!!! I'm sorry, but I don't know what that means :-(");
}
}
}
Loading