Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
1d65904
no message
rohitcube Sep 7, 2023
102f25f
commmit
rohitcube Sep 7, 2023
31650d6
seperated classes into seperate files
rohitcube Sep 8, 2023
3b2adcc
final with comments
rohitcube Sep 8, 2023
76a133a
actual final with comments
rohitcube Sep 8, 2023
fb4c7e8
switch statement and use of split method
rohitcube Sep 14, 2023
046aa40
exceptions and error handling
rohitcube Sep 15, 2023
6d3621e
put tasks into one package
rohitcube Sep 15, 2023
7d71e38
delete function
rohitcube Sep 21, 2023
47c89fa
2 functions added for saving tasks to file and transferring tasks fro…
rohitcube Oct 5, 2023
2ca1a03
JAR file tested
rohitcube Oct 5, 2023
2840b04
Level-7
rohitcube Oct 5, 2023
d9e74d0
Level-7
rohitcube Oct 5, 2023
22e6d32
Merge branch 'branch-Level-6'
rohitcube Oct 5, 2023
a185c4a
resolve merging issues with branch-Level-6
rohitcube Oct 5, 2023
d46612a
keyword search function
rohitcube Oct 5, 2023
a4fd5f6
Ui class
rohitcube Oct 5, 2023
afbf41f
OOP v1
rohitcube Oct 5, 2023
841f65c
OOP v2 with parser
rohitcube Oct 5, 2023
3731fe1
JavaDoc Update
rohitcube Oct 5, 2023
1552e4d
JavaDoc Update 2
rohitcube Oct 5, 2023
f26d5a3
JavaDoc Update 3
rohitcube Oct 5, 2023
4129c36
JavaDoc Update 4
rohitcube Oct 5, 2023
7a801e3
Merge pull request #2 from rohitcube/branch-Level-9
rohitcube Oct 5, 2023
c36c6f3
resolving merge conflicts
rohitcube Oct 5, 2023
afbb48e
resolving merge conflicts
rohitcube Oct 5, 2023
e9f3fd3
Merge pull request #1 from rohitcube/branch-A-JavaDoc
rohitcube Oct 5, 2023
cdec293
User Guide
rohitcube Oct 5, 2023
d71f127
removing comments
rohitcube Oct 5, 2023
7a861a7
delete line function
rohitcube Oct 6, 2023
a049895
fixed addtodo bug
rohitcube Oct 6, 2023
35b3563
added javadocs
rohitcube Oct 6, 2023
9cbbef5
Fix Empty Input Bugs
rohitcube Oct 21, 2023
372929a
Remove command class
rohitcube Oct 25, 2023
455325c
Add error messages for todo, event, deadline, unrecognized command
rohitcube Oct 25, 2023
6924d30
Add conditions to catch empty inputs for mark, unmark and find commands
rohitcube Oct 25, 2023
d615630
Fix bugs in 'deleteLineFromFile' function
rohitcube Oct 25, 2023
2254701
Add Error Messages to DukeyErrorMessages
rohitcube Oct 25, 2023
63815fe
Add JavaDoc to DukeyErrorMessages
rohitcube Oct 25, 2023
a25d92c
Add details to README
rohitcube Oct 25, 2023
b41095c
Add details to README
rohitcube Oct 25, 2023
25bd15c
Add details to README
rohitcube Oct 25, 2023
98e22e3
Add details to README
rohitcube Oct 25, 2023
6484d32
Add details to README
rohitcube Oct 25, 2023
d81536c
Add details to README
rohitcube Oct 25, 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
2 changes: 2 additions & 0 deletions Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
public class Main {
}
3 changes: 3 additions & 0 deletions data/dukey.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
4.[T][ ] hey
4.[T][ ] yn
3.[T][ ] hi
138 changes: 124 additions & 14 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,139 @@
# Dukey Chatbot
# User Guide

## Features

### Feature-ABC

Description of the feature.
## Usage of Features

### Feature-XYZ
### `bye` - Exit Program

Description of the feature.
This command is used to exit the program.

## Usage
Format:

### `Keyword` - Describe action
`bye`

Describe the action and its outcome.
Expected outcome: Bye. Hope to see you again soon!

Example of usage:

`keyword (optional arguments)`
### `list` - List Tasks

This command is used to list all tasks.

Format:

`list`


Expected outcome:
1.[T][ ] homework
2.[T][ ] go to the beach
3.[E][ ] cycle (from: 5am to: 8am)


### `mark` - Mark Task as Done

This command is used to mark a task as done.

Format:

`mark (task number)`


Expected outcome: Nice! I've marked this task as done:
`[T][X]` hi


### `unmark` - Unmark Task

This command is used to unmark a task (mark it as not done).

Format:

`unmark (task number)`

Expected outcome: Nice! I've marked this task as done:
[T][ ] hi



### `deadline` - Add Deadline Task

This command is used to add a deadline task.

Format:

`deadline (description) /by (due date)`

Example of input :
`Submit assignment /by 9am`

Expected outcome: [D][ ] Submit assignment (by: 9am)


### `event` - Add Event Task

This command is used to add an event task.

Format:

`event (description) /from (start time) /to (end time)`

Example of input :
`Rohit attends cs2113 lecture /from 4pm /to 6pm`

Expected outcome: [E][ ] Rohit attends cs2113 lecture (from: 4pm to: 6pm)


### `todo` - Add Todo Task

This command is used to add a todo task.

Format:

`todo (description)`

Example of input :
`todo buy groceries`

Expected outcome: [T][ ] buy groceries


### `delete` - Delete Task

This command is used to delete a task.

Format:

`delete (task number)`

Expected outcome:
"Noted. I have removed this task:
[D][ ] bro (by:tmr)
Now you have 3 tasks in the list."

### `find` - Find a task/tasks

This command is used to search for tasks that contain a particular
keyword in the description.

Format:

`find (task number)`

Example of input:
`find hohoho`

Expected Outcome:

"Here are the matching tasks in your list:

[T][ ] hohoho
[T][ ] hohoho
[E][ ] hohoho (from: 9am to: 5pm)"


Description of the outcome.
### Additional Notes For Users

```
expected output
```
- Do not input whitespaces before your command
- e.g. ( `todo homework` is invalid), (`todo homework` is valid)
1 change: 1 addition & 0 deletions docs/dukey.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Empty file added docs/psuedo.txt
Empty file.
11 changes: 1 addition & 10 deletions src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
public class Duke {
public static void main(String[] args) {
String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
}
}

139 changes: 139 additions & 0 deletions src/main/java/Dukey.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
import Exceptions.DukeyErrorMessages;
import Tasks.*;

import java.util.ArrayList;
import java.util.Scanner;
import java.io.IOException;
public class Dukey {
protected Storage storage;
protected TaskList tasks;
protected Ui ui;
protected String filePath = "data/dukey.txt";

public Dukey(String filePath) {
ui = new Ui();
storage = new Storage(filePath);
try {
ArrayList<Task> array1 = new ArrayList<>();
storage.fileToTaskArray(filePath, array1);
tasks = new TaskList(array1); // Assigning the TaskList to the class-level variable
} catch (Exception e) {
Ui.showLoadingError();
this.tasks = new TaskList(new ArrayList<>());
}
}

public void run() throws IOException {
ui.showWelcomeMessage();
Scanner in = new Scanner(System.in);
String line;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider changing the variable name to something more appropriate such as userInput.

storage.checkDirectoryExists("data");
storage.checkFileExists(filePath);
while (true) {
line = in.nextLine();
String[] input = Parser.parseUserInput(line);
String command = input[0];
switch (command) {
case "bye":
Ui.showExitMessage();
return;
case "list":
TaskList.printTaskList(tasks.tasks);
break;
case "mark":
try {
TaskList.markTask(line, tasks.tasks);
storage.markTaskInFile(Integer.parseInt(input[1].trim()) - 1, filePath);
} catch (IndexOutOfBoundsException e) {
DukeyErrorMessages.markInvalidError();
} catch (NumberFormatException e) {
DukeyErrorMessages.markInvalidTypeError();
}
break;
case "unmark":
try {
TaskList.unmarkTask(line, tasks.tasks);
storage.unmarkTaskInFile(Integer.parseInt(input[1].trim()) - 1, filePath);
} catch (IndexOutOfBoundsException e) {
DukeyErrorMessages.unmarkInvalidError();
} catch (NumberFormatException e) {
DukeyErrorMessages.unmarkInvalidTypeError();
}
break;
case "deadline":
try {
String[] deadline = Parser.parseCommandInput(command, input[1]);
if (deadline[0].trim().isEmpty() || deadline[1].trim().isEmpty()) {
DukeyErrorMessages.deadlineEmptyInputError();
break;
}
TaskList.addDeadline(deadline[0], deadline[1], tasks.tasks);
} catch (ArrayIndexOutOfBoundsException e) {
DukeyErrorMessages.deadlineFormatError();
}
storage.taskArrayToFile(filePath, tasks.tasks);
break;
case "event":
try {
String[] events = Parser.parseCommandInput(command, input[1]);
if (events[2].isEmpty() || events[1].isEmpty() || events[0].isEmpty()) {
DukeyErrorMessages.eventEmptyInputError();
break;
}
TaskList.addEvent(events[0], events[1], events[2], tasks.tasks);
storage.taskArrayToFile(filePath, tasks.tasks);
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println(Exceptions.DukeyException.EmptyInputError());
DukeyErrorMessages.eventFormatError();
} catch (StringIndexOutOfBoundsException e) {
DukeyErrorMessages.eventFormatError();
}
break;
case "todo":
try {
String[] todo = Parser.parseCommandInput(command, input[1]);
if (input[1].trim().isEmpty()) {
DukeyErrorMessages.todoEmptyInputError();
break;
}
TaskList.addTodo(todo[0], tasks.tasks);
storage.taskArrayToFile(filePath, tasks.tasks);
} catch (ArrayIndexOutOfBoundsException e) {
DukeyErrorMessages.todoFormatError();
}
break;
case "delete":
try {
TaskList.deleteTask(line, tasks.tasks);
storage.deleteLineFromFile(Integer.parseInt(input[1].trim()) - 1, filePath);
}
catch (ArrayIndexOutOfBoundsException e) {
DukeyErrorMessages.deleteEmptyInputError();
} catch (NumberFormatException e) {
DukeyErrorMessages.deleteInvalidTypeError();
}
break;
case "find":
TaskList.findKeyword(line, tasks.tasks);
break;
default:
if (line.trim().isEmpty()) {
DukeyErrorMessages.unrecognizedCommandError();
} else {
DukeyErrorMessages.unrecognizedCommandError();
}
}
}
}
public static void main(String[] args) {
try {
new Dukey("data/dukey.txt").run();
} catch (IOException e) {
System.out.println("An error occurred: " + e.getMessage());
}
}

}



Loading