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
e3bb1f1
Duke.java: change chatbot name to Pythia
Ijaaz01 Jan 25, 2024
550f897
Duke.java: Increment level 1
Ijaaz01 Feb 1, 2024
6c2a44c
Duke.java: increment level 2
Ijaaz01 Feb 1, 2024
c9bf241
Duke.java: increment level 3
Ijaaz01 Feb 1, 2024
93f250d
Level 4: add todo, deadline, event functionality
Ijaaz01 Feb 9, 2024
2ff2c78
Add PythiaException class
Ijaaz01 Feb 15, 2024
617ba63
Add throws and catches to main loop
Ijaaz01 Feb 15, 2024
a9162e1
Merge branch 'branch-Level-5'
Ijaaz01 Feb 15, 2024
99083da
Add package duke
Ijaaz01 Feb 21, 2024
36b6f21
Merge branch 'branch-A-Packages'
Ijaaz01 Feb 21, 2024
b18d968
Add delete functionality
Ijaaz01 Feb 21, 2024
11a53c8
Add save functionality, jar file
Ijaaz01 Feb 21, 2024
9ed796b
Merge branch 'branch-Level-6'
Ijaaz01 Feb 21, 2024
8dd0afc
Bug fix, add filewriter.close
Ijaaz01 Feb 21, 2024
22bef9f
Merge branch 'branch-Level-7'
Ijaaz01 Feb 21, 2024
c2444c9
Fix format for event printing, save list automatically
Ijaaz01 Feb 22, 2024
a608d2a
Bug fixes
Ijaaz01 Feb 23, 2024
0639287
Refactor code, add command class, bug fix savedlist retrieval
Ijaaz01 Feb 23, 2024
bfffd2b
Add find functionality
Ijaaz01 Mar 6, 2024
f1019fd
Merge pull request #1 from Ijaaz01/branch-Level-9
Ijaaz01 Mar 6, 2024
8c70edb
Add UI, TaskList, unparsedTaskList and Storage classes
Ijaaz01 Mar 6, 2024
8fbb360
Add JavaDoc for UI, Parser and Command classes
Ijaaz01 Mar 7, 2024
f35f2ba
Merge pull request #2 from Ijaaz01/branch-A-JavaDoc
Ijaaz01 Mar 7, 2024
1f2ea47
Add JavaDoc headers for Duke, Storage, TaskList and UnparsedTaskList
Ijaaz01 Mar 7, 2024
1347803
Edit made to README.md file
Ijaaz01 Mar 7, 2024
f5e750d
Final touch ups to README file
Ijaaz01 Mar 7, 2024
2b44fe6
Fix formatting error in README file
Ijaaz01 Mar 7, 2024
def90c3
Add help command and angry sprite
Ijaaz01 Mar 8, 2024
12225f9
Add help command to README file
Ijaaz01 Mar 8, 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
188 changes: 177 additions & 11 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,195 @@
# Pythia

█████████████
██ ██
██ █████ ██
██ █████ ██
██ ██
█████████████
██ ██
████████████████████

This is Pythia an assistant that makes use of the CLI keep track of all your day to day tasks

# User Guide

## Features
## Features

### `todo`

Add a todo task (task with no due date)

Format: `todo [TASK]`

Example of usage:

`todo placeholder1`

Expected outcome:
```
added: [T][ ] placeholder1
----------------------------------------------------------
```

### `deadline`

Add a deadline task (task with a due date)

### Feature-ABC
Format: `deadline [TASK] /[DUEDATE]`

Description of the feature.
Example of usage:

### Feature-XYZ
`deadline placeholder2 /June 25th 6pm`

Expected outcome:
```
added: [D][ ] placeholder2 (June 25th 6pm)
----------------------------------------------------------
```

Description of the feature.
### `event`

## Usage
Add an event task (task with a start and end time)

### `Keyword` - Describe action
Format: `event [TASK] /[STARTTIME] /[ENDTIME]`

Describe the action and its outcome.
Example of usage:

`event placeholder3 /3pm /6pm`

Expected outcome:
```
added: [E][ ] placeholder3 (from: 3pm to: 6pm)
----------------------------------------------------------
```

### `list`

Lists all tasks currently in the list

Format: `list`

Example of usage:

`keyword (optional arguments)`
`list`

Expected outcome:
```
1.[T][ ] placeholder1
2.[D][ ] placeholder2 (June 25th 6pm)
3.[E][ ] placeholder3 (from: 3pm to: 6pm)
----------------------------------------------------------
```

### `mark`

Marks the specified index in the list

Format: `mark [INDEX]`

Example of usage:

`mark 1`

Expected outcome:
```
Marked placeholder1
----------------------------------------------------------
list
1.[T][X] placeholder1
2.[D][ ] placeholder2 (June 25th 6pm)
3.[E][ ] placeholder3 (from: 3pm to: 6pm)
----------------------------------------------------------
```

### `delete`

Delete a specific index in the task list

Format: `delete [INDEX]`

Example of usage:

`delete 2`

Expected outcome:
```
Deleted [D][ ] placeholder2 (June 25th 6pm)
----------------------------------------------------------
list
1.[T][X] placeholder1
2.[E][ ] placeholder3 (from: 3pm to: 6pm)
----------------------------------------------------------
```

### `unmark`

Unmarks the specified index in the list

Format: `unmark [INDEX]`

Description of the outcome.
Example of usage:

`unmark 1`

Expected outcome:
```
expected output
Unmarked placeholder1
----------------------------------------------------------
list
1.[T][ ] placeholder1
2.[E][ ] placeholder3 (from: 3pm to: 6pm)
----------------------------------------------------------
```

### `find`

Finds and prints all tasks that contain the specified keyword (only applies to task description)

Format: `find [KEYWORD]`

Example of usage:

`find 3`

Expected outcome:
```
[E][ ] placeholder3 (from: 3pm to: 6pm)
----------------------------------------------------------
```

### `help`

Lists all commands that can be inputted by the user

Format: `help`

Example of usage:

`help`

Expected outcome:
```
list
- prints all items in list
- Format: list
mark/unmark
- marks/unmarks an item in the list
- Format: mark/unmark [INDEX]
delete
- deletes an item in the list
- Format: delete [INDEX]
find
- finds all task descriptions that contain a keyword
- Format: find [KEYWORD]
todo
- creates a todo task with no deadline
- Format: todo [TASK]deadline
- creates a task with a deadline
- Format: deadline [TASK] /[DUEDATE]
event
- creates a task with start and end time/date
- Format: event [TASK] /[STARTTIME] /[ENDTIME]
----------------------------------------------------------
```

10 changes: 0 additions & 10 deletions src/main/java/Duke.java

This file was deleted.

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

/**
* Class that contains the executions for all possible commands
*/
public class Command {

private static final String HELP_TEXT = "list\n"
+ " - prints all items in list\n"
+ " - Format: list\n"
+ "mark/unmark\n"
+ " - marks/unmarks an item in the list\n"
+ " - Format: mark/unmark [INDEX]\n"
+ "delete\n"
+ " - deletes an item in the list\n"
+ " - Format: delete [INDEX]\n"
+ "find\n"
+ " - finds all task descriptions that contain a keyword\n"
+ " - Format: find [KEYWORD]\n"
+ "todo\n"
+ " - creates a todo task with no deadline\n"
+ " - Format: todo [TASK]"
+ "deadline\n"
+ " - creates a task with a deadline\n"
+ " - Format: deadline [TASK] /[DUEDATE]\n"
+ "event\n"
+ " - creates a task with start and end time/date\n"
+ " - Format: event [TASK] /[STARTTIME] /[ENDTIME]\n";

private static TaskList taskList = new TaskList();

private static UnparsedTaskList inputList = new UnparsedTaskList();

/**
* Prints out all items in the task list
*/
public static void list() {
for (int i = 0; i < taskList.size(); i++) {
System.out.println((i+1)+"."+taskList.get(i));
}
}

/**
* Tries to add a task to the task list.
* If a proper command is not given asks user to provide a proper input
* Also adds the raw command into the inputlist to be saved on their device
*
* @param input Input provided by the user
*/
public static void tryAddTask(String input) {
try {
taskList.add(addTask(input));
inputList.add(input);
System.out.println("added: " + taskList.get(taskList.size() - 1));
} catch (PythiaException pe) {
System.out.println("Please provide a proper input");
}
}

/**
* Adds a task without the 'added ...' message appearing
* Used only on startup when the locally saved list is retrieved
*
* @param input Input from the savedlist.txt file
*/
public static void directAddTask(String input) {
try {
taskList.add(addTask(input));
inputList.add(input);
} catch (PythiaException pe) {
System.out.println("Please provide a proper input");
}
}

/**
* Parses the input string and returns the appropriate task type
*
* @param task The user input the contains the task command
* @return A Task type variable
* @throws PythiaException Thrown if the required number of fields are not present
*/
public static Task addTask(String task) throws PythiaException{
Parser taskParser = new Parser();
String[] parsedTask;
if (task.contains("todo ")) {
task = task.replaceFirst("todo", "");
if (task.isBlank()) {
throw new PythiaException();
}
return new Todo(task);
} else if (task.contains("deadline ")) {
parsedTask = taskParser.parseDeadline(task);
if (parsedTask.length < 2) {
throw new PythiaException();
}
return new Deadline(parsedTask[0], parsedTask[1]);
} else if (task.contains("event ")){
parsedTask = taskParser.parseEvent(task);
if (parsedTask.length < 3) {
throw new PythiaException();
}
return new Event(parsedTask[0], parsedTask[1], parsedTask[2]);
} else {
throw new PythiaException();
}
}

/**
* Updates the Done status of a task to be false
*
* @param input The user input that contains the unmark command
*/
public static void unmark(String input) {
String[] splitInput = input.split(" ");
taskList.get(Integer.parseInt(splitInput[1])-1).doneIsFalse();
System.out.println("Unmarked "+ taskList.get(Integer.parseInt(splitInput[1])-1).getDescription());
}

/**
* Updates the Done status of a task to be true
*
* @param input The user input that contains the mark command
*/
public static void mark(String input) {
String[] splitInput = input.split(" ");
taskList.get(Integer.parseInt(splitInput[1])-1).doneIsTrue();
System.out.println("Marked "+ taskList.get(Integer.parseInt(splitInput[1])-1).getDescription());
}

/**
* Deletes a specific task from both the taskList and the inputList
*
* @param input The user input that contains the index of the item they want to delete
*/
public static void delete(String input) {
String[] splitInput = input.split(" ");
int indexToRemove = Integer.parseInt(splitInput[1])-1;
System.out.println("Deleted " + taskList.get(Integer.parseInt(splitInput[1])-1));
taskList.remove(taskList.get(indexToRemove));
inputList.remove(inputList.get(indexToRemove));
}

/**
* Finds and prints all tasks that contain the keyword specified by the user
*
* @param input User input that contains the keyword they would like to find
*/
public static void find(String input) {
boolean isFound = false;
String[] splitInput = input.split(" ");
for (int i = 0; i < taskList.size(); i++) {
if (taskList.get(i).getDescription().contains(splitInput[1])) {
isFound = true;
System.out.println(taskList.get(i));
}
}
if (!isFound) {
System.out.println("No such keyword exists");
}
}

/**
* Prints out a list of commands that the user can perform
*/
public static void help() {
System.out.print(HELP_TEXT);
}
}
Loading