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

[Nigel Yeo] iP #18

Open
wants to merge 51 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
ba42b3f
Changed Duke to Legin and completed greet and bye functions
NigelYeoTW Aug 17, 2024
9480bca
Added echo function
NigelYeoTW Aug 24, 2024
9f79a46
Added list function
NigelYeoTW Aug 24, 2024
8268ee0
Added marking and unmarking task functions
NigelYeoTW Aug 24, 2024
cc18d41
Fixed bugs with mark and unmark functions
NigelYeoTW Aug 26, 2024
e7570df
Minor edits to conform to coding standards
NigelYeoTW Aug 30, 2024
d5e3ad5
Add different types of Task for Legin
NigelYeoTW Sep 1, 2024
e5bb5b4
Add text ui testing files for regression testing
NigelYeoTW Sep 1, 2024
3d3adbf
Revert "Add text ui testing files for regression testing"
NigelYeoTW Sep 1, 2024
ff4197b
Add text ui testing files for regression testing
NigelYeoTW Sep 1, 2024
eacfe95
Refactor code to improve code quality
NigelYeoTW Sep 1, 2024
27005e0
Add Exception classes and try catch statements
NigelYeoTW Sep 7, 2024
fe7a47c
Merge branch 'branch-Level-5'
NigelYeoTW Sep 7, 2024
81669a4
Package current files into task and exception
NigelYeoTW Sep 7, 2024
423cced
Merge branch 'branch-A-Packages'
NigelYeoTW Sep 7, 2024
941c4a7
Add delete feature to Legin
NigelYeoTW Sep 15, 2024
d001447
Add local save feature
NigelYeoTW Sep 15, 2024
2b5dfa1
Minor changes to fix update file bug
NigelYeoTW Sep 15, 2024
0d7ceca
Remove unneeded code blocks
NigelYeoTW Sep 15, 2024
b17a881
Merge branch 'branch-Level-6'
NigelYeoTW Sep 15, 2024
b23c82f
Merge branch 'branch-Level-7'
NigelYeoTW Sep 15, 2024
946e96f
Reactor code and creating new Classes
NigelYeoTW Sep 23, 2024
8eb51ec
Merge branch 'branch-A-MoreOOP'
NigelYeoTW Sep 23, 2024
b2a6450
Add find function to bot
NigelYeoTW Sep 23, 2024
e153271
Merge pull request #1 from NigelYeoTW/branch-Level-9
NigelYeoTW Sep 23, 2024
76a1379
Add JavaDoc comments for the entire code base
NigelYeoTW Sep 24, 2024
38071a3
Merge pull request #2 from NigelYeoTW/branch-A-JavaDoc
NigelYeoTW Sep 24, 2024
79e8102
Minor changes to tidy up code
NigelYeoTW Sep 24, 2024
33034ee
Remove magic numbers from code
NigelYeoTW Sep 24, 2024
5a7094d
Update README.md
NigelYeoTW Sep 25, 2024
57717d6
Edit constants to fix bug
NigelYeoTW Sep 25, 2024
ea61d86
Update README.md
NigelYeoTW Sep 25, 2024
9850c6f
Update README.md
NigelYeoTW Sep 25, 2024
49e3636
Update README.md
NigelYeoTW Sep 25, 2024
f2ba19f
Update README.md
NigelYeoTW Sep 25, 2024
9e137a2
Rename variables with better readability
NigelYeoTW Sep 26, 2024
d72baff
Merge branch 'master' of https://github.com/NigelYeoTW/ip
NigelYeoTW Sep 26, 2024
dc3c9ec
Update README.md
NigelYeoTW Sep 26, 2024
1032379
Update README.md
NigelYeoTW Oct 2, 2024
9ef22f1
Update README.md
NigelYeoTW Oct 2, 2024
7426f4b
Update README.md
NigelYeoTW Oct 2, 2024
88097a9
Update README.md
NigelYeoTW Oct 2, 2024
a10412d
Update README.md
NigelYeoTW Oct 2, 2024
e950539
Update README.md
NigelYeoTW Oct 2, 2024
5f5c2fc
Update README.md
NigelYeoTW Oct 2, 2024
c8f728c
Update README.md
NigelYeoTW Oct 2, 2024
d46b4aa
Update README.md
NigelYeoTW Oct 2, 2024
62a277d
Repackage files and clean up code
NigelYeoTW Oct 5, 2024
289f50c
Merge branch 'branch-cleanUp'
NigelYeoTW Oct 5, 2024
08bc279
Merge pull request #3 from NigelYeoTW/branch-cleanUp
NigelYeoTW Oct 5, 2024
8c4c8f5
Merge branch 'master' of https://github.com/NigelYeoTW/ip
NigelYeoTW Oct 5, 2024
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
/out/
/*.iml

*.class

# Gradle build files
/.gradle/
/build/
Expand All @@ -14,4 +16,3 @@ src/main/resources/docs/
bin/

/text-ui-test/ACTUAL.TXT
text-ui-test/EXPECTED-UNIX.TXT
147 changes: 131 additions & 16 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,145 @@
# Duke User Guide
# Legin User Guide

// Update the title above to match the actual product name
Legin is a command line chat bot that helps users with their daily tracking of tasks, these tasks includes various types such as Todo, Deadline and Event types. The bot is able to store these data and retrieve where the user last left off, allowing continuous usage of the bot from day to day.

// Product screenshot goes here
## Quick Start

// Product intro goes here
1. Ensure you have Java ```17``` or above installed in your Computer.
2. Download the latest ```.jar``` file from [here](https://github.com/NigelYeoTW/ip/releases).
3. Copy the file to the folder you want to use as the home folder for Legin. Note that the data storage text file will also be created in this folder.
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.
The following should be displayed in your command line upon successfully starting up Legin
![image](https://github.com/user-attachments/assets/d37c981f-5a60-4824-896b-45a59795157b)
Note that the file path displayed will be your specific file path where you store the jar file
5. Type some of these commands into the command line and press Enter to execute it
Here are some of the commands you can try:
+ ```list```: List all tasks you have with indexes
+ ```todo read up CS2113 Tutorial 2```: Adds a Todo task into your task list with description 'read up CS2113 Tutorial 2'
+ ```mark 3```: Marks the 3rd task in the list as done
+ ```delete 5```: Deletes the 5th task in the task list
+ ```find homework```: Search through the task list and outputs all the task that have 'homework' in their description
+ ```bye```: Terminates Legin
6. Refer to the [Features](#features) below for details of each command.

## Adding deadlines
## Features

// Describe the action and its outcome.
### Adding a Todo task: ```todo```

// Give examples of usage
Adds a Todo task to the task list. <br />
Format: ```todo TASK_DESCRIPTION``` <br />
Example:
+ ```todo Water the plants``` <br />
The following would be seen on the terminal if done correctly:
![image](https://github.com/user-attachments/assets/777aa717-3c10-4e65-a484-79ec87161220)

Example: `keyword (optional arguments)`

// A description of the expected outcome goes here
### Adding a Deadline task: ```deadline```

```
expected output
```
Adds a task that has a deadline to the task list. <br />
Format: ```deadline TASK_DESCRIPTION /by DEADLINE``` <br />
Example:
+ ```deadline submit quiz 1 /by 27 October 4pm``` <br />
The following would be seen on the terminal if done correctly:
![image](https://github.com/user-attachments/assets/ad576583-c6d2-49ab-9cbe-867826817688)

Note: Users are to adhere to the space after ```TASK_DESCRIPTION``` and ```/by``` to prevent unexpected behavior

## Feature ABC
### Adding a Event task: ```event```

// Feature details
Adds a event that has a duration period into the task list. <br />
Format: ```event EVENT_DESCRIPTION /from EVENT_START /to EVENT_END``` <br />
Example:
+ ```event Meet friend at Yishun /from 18 October 9pm /to 18 October 11pm``` <br />
The following would be seen on the terminal if done correctly:
![image](https://github.com/user-attachments/assets/2ac2d029-b1fe-4083-9835-0e599d41f0e9)

Note: Users are to adhere to the space after ```EVENT_DESCRIPTION```, ```/from``` and ```/to``` to prevent unexpected behavior


## Feature XYZ
### Marking a task: ```mark```

// Feature details
Marks a tasks in the task list by its index as done. Index of task can be obtained by using the ```list``` command. <br />
Format: ```mark INDEX``` <br />
Example:
+ ```mark 3```

Note: ```INDEX``` should be displayed in task list when ```list``` is called


### Unmarking a task: ```unmark```

Unmarks a task in the task list by its index as undone. Index of task can be obtained by using the ```list``` command. <br />
Format: ```unmark INDEX``` <br />
Example:
+ ```unmark 5```

Note: ```INDEX``` should be displayed in task list when ```list``` is called


### Listing all tasks: ```list```

Lists out all the tasks in the task list. <br />
Format: ```list```


### Deleting a task: ```delete```

Deletes a task in the task list by it index. Index of task can be obtained by using the ```list``` command. <br />
Format: ```delete INDEX``` <br />
Note: ```INDEX``` should be displayed in task list when ```list``` is called


### Find task by description: ```find```

Finds all tasks with description that matches the given keyword by user <br />
Format: ```find KEYWORD [MORE_KEYWORDS]...``` <br />
Example:
+ ```find tutorial``` returns ```tutorial 4```, ```math tutorial```, ```english tutorial 6```
+ ```find jurong west``` returns ```meeting at jurong west```, ```jurong west cafe```
+ ```find real``` returns ```really good cafe```, ```surreal theme park at Hougang```

Note:
+ Keywords used are case sensitive
+ Keywords can be partial words of a full word
+ Keywords should only be used to match task desciption, task type should be ommited


### Terminating Legin: ```bye```

Terminates program. <br />
Format: ```bye``` <br />
Note: User should not close the application before using this command to avoid unsaved data from current window


### Saving the data
Data will be saved in a text file where the ```.jar``` file is stored with file name ```tasklist.txt``` <br />
Data will be saved upon termination of the program with ```bye```


### Editting the data file
Data is stored in the form of:
+ 'TASK_TYPE\|IS_TASK_DONE\|TASK_DESCRIPTION' for Todo tasks <br />
+ 'TASK_TYPE\|IS_TASK_DONE\|TASK_DESCRIPTION\|DUEDATE' for Deadline tasks <br />
+ 'TASK_TYPE\|IS_TASK_DONE\|TASK_DESCRIPTION\|TIME_START\|TIME_END' for Event tasks <br />
Each line stores data for only one task

The following are some fixed parameters:
TASK_TYPE:
+ 'T' - Todo task
+ 'D' - Deadline task
+ 'E' - Event task

IS_TASK_DONE:
+ 'true' - marks task as done
+ 'false' - marks task as undone

## Command Summary
+ Action|Format, Examples
Add Todo task|```todo TASK_DESCRIPTION``` <br /> eg. ```todo Water the plants```
Add Deadline task|```deadline TASK_DESCRIPTION /by DEADLINE``` <br /> eg. ```deadline submit quiz 1 /by 27 October 4pm```
Add Event task|```event EVENT_DESCRIPTION /from EVENT_START /to EVENT_END``` <br /> eg. ```event Meet friend at Yishun /from 18 October 9pm /to 18 October 11pm```
Mark task as done|```mark INDEX``` <br /> eg. ```mark 3```
Mark task as undone|```unmark INDEX``` <br /> eg. ```unmark 5```
List all tasks|```list```
Delete task|```delete INDEX```
Find task|```find KEYWORD [MORE_KEYWORDS]...``` <br /> eg . ```find jurong west```
10 changes: 0 additions & 10 deletions src/main/java/Duke.java

This file was deleted.

42 changes: 42 additions & 0 deletions src/main/java/Legin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import parser.Parser;
import storage.Storage;
import task.TaskList;
import ui.Ui;

/**
* Represents the command line bot that helps stores your tasks.
* Functionalities include adding, deleting, finding and marking tasks as well as categorise them into todo, deadline
* and event.
* <p>
* User input should follow the following: [command][arg...]
*/
public class Legin {
private final TaskList taskList;
private final Storage storage;
private final Ui ui = new Ui();
private final Parser parser = new Parser();

private Legin() {
storage = new Storage();
taskList = storage.getloadedTaskList();
}

private void runBot() {
boolean hasSaidBye = false;
ui.greet();
while (!hasSaidBye) {
String input = ui.readInput();
hasSaidBye = parser.parseInput(taskList, input);
}
storage.updateTextFile(taskList);
ui.exiting();
}

/**
* Initialises the bot and start running the bot until the user terminates it
*/
public static void main(String[] args) {
Legin legin = new Legin();
legin.runBot();
}
}
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: Legin

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

/**
* Signals that the task the user input has no description
*/
public class LeginEmptyTaskException extends LeginException{
private static final String ERROR_MESSAGE = "BROO! No task description is given!";
public LeginEmptyTaskException() {
super(ERROR_MESSAGE);
}
}
10 changes: 10 additions & 0 deletions src/main/java/exception/LeginException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package exception;

/**
* Serves as a general class for all Legin exceptions
*/
public class LeginException extends Exception{
public LeginException(String errorMessage) {
super(errorMessage);
}
}
12 changes: 12 additions & 0 deletions src/main/java/exception/LeginIndexOutOfBoundsException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package exception;

/**
* Signals that the index the user input is out of the range of the task list array
*/
public class LeginIndexOutOfBoundsException extends LeginException{
private static final String ERROR_MESSAGE = "BROO! No such task index!";
public LeginIndexOutOfBoundsException() {
super(ERROR_MESSAGE);
}
}

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

/**
* Signals that the user has input a command that does not exist
*/
public class LeginInvalidCommandException extends LeginException{
private static final String ERROR_MESSAGE = "BROO! No such command!";
public LeginInvalidCommandException() {
super(ERROR_MESSAGE);
}
}
12 changes: 12 additions & 0 deletions src/main/java/exception/LeginMissingParamsException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package exception;

/**
* Signals that the user failed to input all arguments required for the type of task <br>
* Usually thrown due to missing time stamps or duration in input
*/
public class LeginMissingParamsException extends LeginException {
private static final String ERROR_MESSAGE = "BROO! Missing Parameters!";
public LeginMissingParamsException() {
super(ERROR_MESSAGE);
}
}
78 changes: 78 additions & 0 deletions src/main/java/parser/Parser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package parser;
import exception.LeginIndexOutOfBoundsException;
import exception.LeginInvalidCommandException;
import task.TaskList;
import ui.Ui;

/**
* Pulls command from user input and calling {@code TaskList} methods to execute them
*/
public class Parser {
private static final int COMMAND_INDEX = 0;
private static final int INDEX_TO_MARK = 1;
private final Ui ui = new Ui();

private void checkIndexValidity(TaskList tasklist, int index) throws LeginIndexOutOfBoundsException {
if (index > tasklist.getTaskCount()) {
throw new LeginIndexOutOfBoundsException();
}
}

private boolean selectCommand(TaskList taskList, String command, String[] words, String input) {
int indexOfTaskToMark;
try {
switch (command) {
case "bye":
return true;
case "list":
taskList.listAllTask();
break;
case "mark":
indexOfTaskToMark = Integer.parseInt(words[INDEX_TO_MARK]);
checkIndexValidity(taskList, indexOfTaskToMark);
taskList.markTask(indexOfTaskToMark);
break;
case "unmark":
indexOfTaskToMark = Integer.parseInt(words[INDEX_TO_MARK]);
checkIndexValidity(taskList, indexOfTaskToMark);
taskList.unmarkTask(indexOfTaskToMark);
break;
case "todo":
taskList.addTodo(input);
break;
case "deadline":
taskList.addDeadline(input);
break;
case "event":
taskList.addEvent(input);
break;
case "delete":
int indexOfTaskToDelete = Integer.parseInt(words[1]);
checkIndexValidity(taskList, indexOfTaskToDelete);
taskList.deleteTask(indexOfTaskToDelete);
break;
case "find":
taskList.findAllMatchingTask(input);
break;
default:
throw new LeginInvalidCommandException();
}
} catch (LeginInvalidCommandException | LeginIndexOutOfBoundsException e) {
ui.printExceptionMessage(e);
}
return false;
}

/**
* Parse the user input and retrieves the command, calling {@code selectCommand} to execute the command
*
* @param taskList Contains all information of current tasks
* @param input User input into command line
* @return {@code true} if the user command is bye
*/
public boolean parseInput(TaskList taskList, String input) {
String[] wordsOfInput = input.split(" ");
String command = wordsOfInput[COMMAND_INDEX];
return selectCommand(taskList, command, wordsOfInput, input);
}
}
Loading