-
Notifications
You must be signed in to change notification settings - Fork 76
[rohitcube] iP #86
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
Open
rohitcube
wants to merge
45
commits into
nus-cs2113-AY2324S1:master
Choose a base branch
from
rohitcube:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[rohitcube] iP #86
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
1d65904
no message
rohitcube 102f25f
commmit
rohitcube 31650d6
seperated classes into seperate files
rohitcube 3b2adcc
final with comments
rohitcube 76a133a
actual final with comments
rohitcube fb4c7e8
switch statement and use of split method
rohitcube 046aa40
exceptions and error handling
rohitcube 6d3621e
put tasks into one package
rohitcube 7d71e38
delete function
rohitcube 47c89fa
2 functions added for saving tasks to file and transferring tasks fro…
rohitcube 2ca1a03
JAR file tested
rohitcube 2840b04
Level-7
rohitcube d9e74d0
Level-7
rohitcube 22e6d32
Merge branch 'branch-Level-6'
rohitcube a185c4a
resolve merging issues with branch-Level-6
rohitcube d46612a
keyword search function
rohitcube a4fd5f6
Ui class
rohitcube afbf41f
OOP v1
rohitcube 841f65c
OOP v2 with parser
rohitcube 3731fe1
JavaDoc Update
rohitcube 1552e4d
JavaDoc Update 2
rohitcube f26d5a3
JavaDoc Update 3
rohitcube 4129c36
JavaDoc Update 4
rohitcube 7a801e3
Merge pull request #2 from rohitcube/branch-Level-9
rohitcube c36c6f3
resolving merge conflicts
rohitcube afbb48e
resolving merge conflicts
rohitcube e9f3fd3
Merge pull request #1 from rohitcube/branch-A-JavaDoc
rohitcube cdec293
User Guide
rohitcube d71f127
removing comments
rohitcube 7a861a7
delete line function
rohitcube a049895
fixed addtodo bug
rohitcube 35b3563
added javadocs
rohitcube 9cbbef5
Fix Empty Input Bugs
rohitcube 372929a
Remove command class
rohitcube 455325c
Add error messages for todo, event, deadline, unrecognized command
rohitcube 6924d30
Add conditions to catch empty inputs for mark, unmark and find commands
rohitcube d615630
Fix bugs in 'deleteLineFromFile' function
rohitcube 2254701
Add Error Messages to DukeyErrorMessages
rohitcube 63815fe
Add JavaDoc to DukeyErrorMessages
rohitcube a25d92c
Add details to README
rohitcube b41095c
Add details to README
rohitcube 25bd15c
Add details to README
rohitcube 98e22e3
Add details to README
rohitcube 6484d32
Add details to README
rohitcube d81536c
Add details to README
rohitcube File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| public class Main { | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| 4.[T][ ] hey | ||
| 4.[T][ ] yn | ||
| 3.[T][ ] hi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
|
|
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| 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()); | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.