Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
c606c3c
Rename main class
DextheChik3n Aug 24, 2023
e3f01fa
Add greeting and exit functions
DextheChik3n Aug 24, 2023
3afcb6b
Refactor printHorrizontalLine function
DextheChik3n Aug 31, 2023
184e708
Add echo function
DextheChik3n Aug 31, 2023
cf80b82
Add list functionality
DextheChik3n Aug 31, 2023
1afaaf1
Add Task.java class
DextheChik3n Sep 3, 2023
e331bb9
Add mark and unmark tasks feature
DextheChik3n Sep 3, 2023
951a3e6
Main.java: Fix handling exit command
DextheChik3n Sep 3, 2023
7a7066d
Update Alan.java to follow coding standard
DextheChik3n Sep 3, 2023
32601dd
Add todo, deadline and event tasks
DextheChik3n Sep 7, 2023
ff60709
Update input.txt and EXPECTED.TXT for automated testing
DextheChik3n Sep 7, 2023
3550db1
Refactor Alan class
DextheChik3n Sep 7, 2023
ae095d1
Refactor Alan.java
DextheChik3n Sep 13, 2023
31437f8
Add error handling for invalid command and todo tasks
DextheChik3n Sep 13, 2023
511f4d2
Add error handling for deadline and event invalid input formatting
DextheChik3n Sep 13, 2023
eb7f6ae
Add error handling for mark/unmark unknown tasks
DextheChik3n Sep 13, 2023
b168238
Merge branch 'branch-Level-5'
DextheChik3n Sep 13, 2023
4194ba3
Change message texts
DextheChik3n Sep 14, 2023
8365fc3
Organize classes into java packages
DextheChik3n Sep 14, 2023
44587d6
Merge branch 'branch-A-Packages'
DextheChik3n Sep 14, 2023
c7bcaaa
Refactor error exception and command handling
DextheChik3n Sep 14, 2023
17b65ef
Change Alan to store tasks in ArrayList
DextheChik3n Sep 19, 2023
1933454
Add delete function
DextheChik3n Sep 19, 2023
41ce6df
Update tasks to set and get task contents
DextheChik3n Sep 20, 2023
88bace6
Add saving task list to text file functionality
DextheChik3n Sep 20, 2023
94bcc13
Update gitignore to exclude tasks.txt
DextheChik3n Sep 20, 2023
a49e395
Add saving and loading tasks from text file
DextheChik3n Sep 20, 2023
23738a8
Merge branch 'branch-Level-6'
DextheChik3n Sep 20, 2023
3dab5c7
Merge branch 'branch-Level-7'
DextheChik3n Sep 20, 2023
425e388
Refactor read function in Alan.java
DextheChik3n Sep 20, 2023
b6ecfbe
.gitignore: add MANIFEST.MF
DextheChik3n Sep 26, 2023
eeee528
Create packages to organise java classes
DextheChik3n Sep 30, 2023
d7ccba5
Create classes to organise code
DextheChik3n Oct 1, 2023
361eb39
Implement UI Class
DextheChik3n Oct 1, 2023
4935bba
Implement TaskList class
DextheChik3n Oct 1, 2023
7f3c631
Implement Parser class
DextheChik3n Oct 2, 2023
d140956
Implement Storage class
DextheChik3n Oct 2, 2023
2d45aff
Add reading invalid task type in Storage class
DextheChik3n Oct 2, 2023
310e2b4
Add date parsing
DextheChik3n Oct 2, 2023
61e0f3c
Add find task functionality
DextheChik3n Oct 2, 2023
4c9970f
Merge pull request #1 from DextheChik3n/branch-Level-8
DextheChik3n Oct 2, 2023
51959a1
Add JavaDoc comments
DextheChik3n Oct 3, 2023
64c21f4
Merge branch 'master' into branch-Level-9
DextheChik3n Oct 3, 2023
4b5849c
Merge branch 'master' into branch-A-JavaDoc
DextheChik3n Oct 3, 2023
4bac978
Merge pull request #2 from DextheChik3n/branch-Level-9
DextheChik3n Oct 3, 2023
ef54d91
Merge branch 'master' into branch-A-JavaDoc
DextheChik3n Oct 3, 2023
c63d05e
Merge pull request #3 from DextheChik3n/branch-A-JavaDoc
DextheChik3n Oct 3, 2023
7efbd2b
Update README.md
DextheChik3n Oct 3, 2023
4a0b8b8
Remove Command Summary section from README.md
DextheChik3n Oct 3, 2023
151f23c
Refactor magic strings
DextheChik3n Oct 3, 2023
1f42faa
Add error handling for empty user input
DextheChik3n Oct 3, 2023
efc4ab2
Add handling of printing empty lists
DextheChik3n Oct 3, 2023
036f277
Add error handling for mark, unmark and delete command
DextheChik3n Oct 3, 2023
f67cbbf
Remove unused imports
DextheChik3n Oct 3, 2023
6cc4255
Update README.md
DextheChik3n Oct 3, 2023
e4f770e
Fix storing empty TaskList to text file
DextheChik3n Oct 3, 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ bin/

/text-ui-test/ACTUAL.TXT
text-ui-test/EXPECTED-UNIX.TXT
data/tasks.txt
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
# Alan 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/Alan.java` file, right-click it, and choose `Run Alan.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
150 changes: 138 additions & 12 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,155 @@
# User Guide
Alan is a Personal Assistant chatbot application that can help with tracking tasks such as todos, deadlines and events.

## Features
* Quick Start
* Features
* Adding a todo : `todo`
* Adding a deadline : `deadline`
* Adding a event : `event`
* Listing all tasks: `list`
* Mark task as done : `mark`
* Mark task as not done : `unmark`
* Deleting a task : `delete`
* Finding tasks : `find`
* Exit program : `bye`

### Feature-ABC
## Quick start
1. Ensure you have Java `11` or above installed on your computer.
2. Download the latest `ip.jar` from [here](https://github.com/DextheChik3n/ip/releases)
3. Copy the file to the folder you want to use as the home folder for your Personal Assistant Chatbot.
4. Open a command terminal, `cd` into the folder you put the jar file in, and use the `java -jar ip.jar` command to run the application.
5. If the setup is correct, you should see something like the below as the output:
```
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sup dude! I'm
______ __ ______ __ __
/\ __ \ /\ \ /\ __ \ /\ "-.\ \
\ \ __ \ \ \ \____ \ \ __ \ \ \ \-. \
\ \_\ \_\ \ \_____\ \ \_\ \_\ \ \_\\"\_\
\/_/\/_/ \/_____/ \/_/\/_/ \/_/ \/_/
@/
/|
/ \
What can I do for you, my man?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Input:

```

## Features
> **Notes about command format:**
> - Words in `UPPER_CASE` are the arguments to be supplied by user. <br>
e.g. `deadline DESCRIPTION /by DATETIME`, `DESCRIPTION` and `DATETIME` are arguments to be specified by user.
> - Parameters need to be in the exact format as specified. <br>
e.g. `event DESCRIPTION /from DATETIME /to DATETIME`, `/from` must come before `/to`.

### Adding a todo : `todo`

Adds a todo task in the task list.

Format: `todo DESCRIPTION`

Example: <br> `todo read book`

### Adding a deadline : `deadline`

Adds a deadline task in the task list.

Description of the feature.
Format: `deadline DESCRIPTION /by DATETIME`

### Feature-XYZ
- `DATETIME` can be input as `yyyy-mm-dd` to be stored as `dd MMM yyyy` format
- e.g. the input `2020-02-14` will be stored as `14 Feb 2020` in the task list

Description of the feature.
Example: <br> `deadline return book /by Feb 14th`

## Usage
### Adding a event : `event`

### `Keyword` - Describe action
Adds a event task in the task list.

Describe the action and its outcome.
Format: `event DESCRIPTION /from DATETIME /to DATETIME`
- `DATETIME` can be input as `yyyy-mm-dd` to be stored as `dd MMM yyyy` format
- e.g. the input `2020-02-14` will be stored as `14 Feb 2020` in the task list

Example of usage:
Example: <br> `event project meeting /from Aug 6th 2pm /to Aug 6th 4pm`

`keyword (optional arguments)`
### Listing all tasks : `list`

Lists all the task in the task list.

Format: `list`

Expected outcome:

Description of the outcome.
`list` Prints all the task currently in the task list.

```
Input: list
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dude, check out these tasks on your list:
1. [T][X] read book
2. [D][X] 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 task as done : `mark`

Mark the task status as done.

Format: `mark TASK_INDEX`

- Marks task as done at specified `TASK_INDEX`
- The `TASK_INDEX` refers to the index number shown in the displayed task list.
The index must be a positive integer 1, 2, 3, …​

Example: <br> `mark 1` Marks the first task in the list as done.

### Mark task as not done : `unmark`

Unmark the task status as not done.

Format: `unmark TASK_INDEX`

- Marks task as not done at specified `TASK_INDEX`
- The `TASK_INDEX` refers to the index number shown in the displayed task list.
The index must be a positive integer 1, 2, 3, …​

Example: <br> `unmark 1` Marks the first task in the list as not done.

### Deleting a task : `delete`

Deletes the task in the task list.

Format: `delete TASK_INDEX`

- Deletes task at specified `TASK_INDEX`
- The `TASK_INDEX` refers to the index number shown in the displayed task list.
The index must be a positive integer 1, 2, 3, …​

Example: <br> `list` followed by `delete 2` deletes the 2nd task in the task list.

### Finding tasks : `find`

Finds tasks whose description matches the given keyword.

Format: `find KEYWORD`

Example: <br> `find book` will find tasks with the keyword `book` in the list.

```
expected output
Input: find book
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dude check it out, here are the matching tasks in your list:
1. [T][X] read book
2. [D][X] return book (by: June 6th)
3. [T][ ] borrow book
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

### Exit program : `bye`

Exits the chatbot program.

Format: `bye`
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: alan.Alan

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

import alan.data.TaskList;
import alan.data.exception.AlanException;
import alan.parser.Parser;
import alan.storage.Storage;
import alan.ui.Ui;

import java.io.FileNotFoundException;

/**
* Represents the main class and entry point of the Alan chatbot program.
*/
public class Alan {
private static Ui ui;
private static TaskList tasks;
private static Storage storage;

/**
* Represents the Alan constructor.
* Initializes the Ui, Storage and TaskList.
*
* @param filePath filePath of the text file used to store task data.
*/
public Alan(String filePath) {
ui = new Ui();
storage = new Storage(filePath);
try {
tasks = new TaskList(storage.load());
} catch (FileNotFoundException e) {
ui.showLoadingError();
tasks = new TaskList();
}
}

/**
* Runs the Alan chatbot program.
*/
public static void runAlan() {
Parser parser = new Parser(tasks, ui);

ui.showWelcomeMessage();

String userInput = null;
String command = "";

do {
try {
userInput = ui.getUserCommand();
command = parser.processCommandHandler(userInput);
} catch (AlanException e) {
ui.showToUser(e.getMessage());
} finally {
ui.printHorizontalLine();
}
} while (!command.equals("bye"));

try {
storage.save();
} catch (Exception e) {
ui.showSavingError();
}
}

/**
* Main method of the Alan program.
* @param args
*/
public static void main(String[] args) {
new Alan("data/tasks.txt").runAlan();
}
}
35 changes: 35 additions & 0 deletions src/main/java/alan/common/Messages.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package alan.common;
/**
* Represents a class that stores all the messages sent to the user.
*/
public class Messages {
public static final String manDrawing = " @/\n" +
"/| \n" +
"/ \\";
public static final String alanText = " ______ __ ______ __ __ \n" +
"/\\ __ \\ /\\ \\ /\\ __ \\ /\\ \"-.\\ \\ \n" +
"\\ \\ __ \\ \\ \\ \\____ \\ \\ __ \\ \\ \\ \\-. \\ \n" +
" \\ \\_\\ \\_\\ \\ \\_____\\ \\ \\_\\ \\_\\ \\ \\_\\\\\"\\_\\ \n" +
" \\/_/\\/_/ \\/_____/ \\/_/\\/_/ \\/_/ \\/_/ ";

public static final String horizontalDivider = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
public static final String MESSAGE_GREET = "Sup dude! I'm \n" + alanText + "\n" + manDrawing + "\n" + "What can I do for you, my man?";
public static final String MESSAGE_GOODBYE = "Later, dude! Can't wait to catch up again real soon!";
public static final String MESSAGE_LIST_COMMAND = "Dude, check out these tasks on your list:";
public static final String MESSAGE_MARK_TASK = "Alright bro! This task is officially checked off:";
public static final String MESSAGE_UNMARK_TASK = "Ok dude, I've marked this task as ain't done yet amigo:";
public static final String MESSAGE_DELETE_TASK = "Got it, dude. This task is outta here:";
public static final String MESSAGE_INVALID_INPUT_COMMAND = "Oof, I have no idea what are you saying duuude";
public static final String MESSAGE_EMPTY_DESCRIPTION = "Oof Dude, you can't leave the description empty";
public static final String MESSAGE_INVALID_DEADLINE_FORMAT = "Oof the deadline command isn't quite right you gotta fix the format, bro...\n[Remember it's: <description> /by <date>]";
public static final String MESSAGE_INVALID_EVENT_FROM_FORMAT = "Oof duude, your /from formatting is whack\n[Remember it's: <description> /from <date> /to <date>]";
public static final String MESSAGE_INVALID_EVENT_TO_FORMAT = "Oof my man, you need to work on that /to formatting\n[Remember it's: <description> /from <date> /to <date>]";
public static final String MESSAGE_INVALID_TASK_NUMBER = "Oof maaaan there's no such task";
public static final String MESSAGE_INVALID_TASK_TYPE_FOUND = "Yo I found a task type that doesn't make sense";
public static final String MESSAGE_FIND_TASK = "Dude check it out, here are the matching tasks in your list:";
public static final String MESSAGE_DATA_FOLDER_NOT_FOUND = "Data Folder was not found!\nIt's ok... new data folder has been created in ";
public static final String MESSAGE_DATA_FILE_NOT_FOUND = "tasks.txt was not found!\nIt's ok... new tasks.txt has been created in ";
public static final String MESSAGE_LOAD_FILE_ERROR = "Yo dude something ain't loading right :/";
public static final String MESSAGE_SAVE_FILE_ERROR = "Sorry man I can't seem to save to the text file D:";
public static final String MESSAGE_EMPTY_LIST = "...errr I don't see any tasks here ¯\\_(ツ)_/¯";
}
60 changes: 60 additions & 0 deletions src/main/java/alan/data/TaskList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package alan.data;

import alan.data.task.Deadline;
import alan.data.task.Event;
import alan.data.task.Task;
import alan.data.task.Todo;

import java.util.ArrayList;
/**
* Represents a list of the <code>Task</code> objects.
*/
public class TaskList {
private final ArrayList<Task> tasks;

public TaskList() {
tasks = new ArrayList<>();
}

public TaskList(ArrayList<Task> tasks) {
this.tasks = tasks;
}

public ArrayList<Task> getTaskList() {
return tasks;
}

public Task getSelectedTask(int selectedTaskIndex) {
return tasks.get(selectedTaskIndex);
}

public int getLastTaskIndex() {
return tasks.size() - 1;
}

public int getTaskListSize() {
return tasks.size();
}

public void addToDo(String description) {
tasks.add(new Todo(description));
}

public void addDeadline(String description, String by) {
tasks.add(new Deadline(description, by));
}

public void addEvent(String description, String from, String to) {
tasks.add(new Event(description, from, to));
}

public void markTask(int selectedTaskIndex, boolean isDone) {
tasks.get(selectedTaskIndex).setDone(isDone);
}

public void removeTask(int selectedTaskIndex) {
tasks.remove(selectedTaskIndex);
}


}
Loading