Starter code for the Duke project
C:\.cd command to navigate to the correct folder and run the program using java -jar [filename].jar. The cd navigation is important as duke will only search the current directory for the file, and not the root directory of the duke program itself automatically.Duke has the following commands:
list: Lists the tasks entered into the program that are not deletedtodo : Adds a todo task to the listdeadline : Adds a deadline task to the listevent : Adds an event task to the listdone : Marks an existing task as donedelete : Deletes an existing taskfind : Finds all tasks that contain the supplied keyword, including in the date section for Deadlines and Eventsbye: Exits the applicationlistPrints out the list of tasks stored in the program.
Format: list without any arguments.
Usage: list
Outcome:
Here are the tasks in your list:
1. [T][✓] eat breakfast
Exceptions: None. This command will always run.
todo Adds a todo task into the list.
Format: todo [task description]
Usage: todo finish homework
Outcome:
Got it. I've added this task:
[T][✘] finish homework
Now you have 8 tasks in the list.
Exceptions: The program will display an error message Invalid command. if you type todo without a task description.
deadline Adds a deadline task into the list.
Format: deadline [task description] /by [deadline]. The [deadline] is in string format so it can be e.g. “tommorrow” as well.
Usage: deadline finish homework /by tommorrow
Outcome:
Got it. I've added this task:
[D][✘] finish homework (by: tommorrow)
Now you have 6 tasks in the list.
Exceptions: The program will display an error message Invalid command. if you type deadline without a task description nor the deadline.
The program will display an error message Invalid format. Please check your syntax. for all other syntax errors, such as an empty description, a lack
of “/by “ in the input, or an empty deadline in the input.
event Adds a event task into the list.
Format: event [task description] /on [occurrence]. The [occurrence] is in string format so it can be e.g. “yesterday” as well.
Usage: event midterms /on friday
Outcome:
Got it. I've added this task:
[E][✘] midterms (on: friday)
Now you have 2 tasks in the list.
Exceptions: The program will display an error message Invalid command. if you type event without a task description nor the occurrance.
The program will display an error message Invalid format. Please check your syntax. for all other syntax errors, such as an empty description, a lack
of “/on “ in the input, or an empty occurrance in the input.
done Marks the specified task as done. If the task is already done, a message This task is already done! will be shown.
Format: done [task number]
Usage: done 3
Outcome:
Nice! I've marked this task as done:
[✓] movies
Outcome:
This task is already done!
Exceptions: The program will display an error message Please Enter a number! if you type done without a task number, or you typed a non-number
character in its place. If the number you typed is not valid, e.g. 0 or 3 when you only have 1 task in the list, you will receive the error message
Invalid task number or task does not exist. Please try again..
delete Deletes the specified task from the list AND duke.txt immediately. Please exercise caution before deleting a task.
Format: delete [task number]
Usage: delete 3
Outcome:
Noted. I've removed this task:
[✓] lunch
Exceptions: The program will display an error message Invalid task number or input is not a number. No items are deleted. for all invalid inputs,
such as if you typed delete without a task number, typed a non-number character instead, or typed a number that is not valid.
find Finds tasks with the specified keyword. Also searches in the date section in Deadlines and Events. If you enter find without a keyword, the entire
list is printed out.
Format: find [keyword]
Usage: find homework
Outcome:
Here are the matching tasks in your list:
1. [✓] all the homework
2. [E][✘] midterms (on: the day without homework)
Exceptions: None.
byeExits the application. The data entered have been saved into duke.txt. If required, please backup this file for safekeeping purposes.
Format: bye without any arguments.
Usage: bye
Outcome:
Bye. Hope to see you again soon!
Exceptions: None.
Adds a traditional task into the list. Accepts most inputs. Exceptions include delete and todo . Inputs accepted include delete and duke.
Format: [input]
Usage: todo, event, find, java, movie /at 9pm
Outcome:
Added: todo
Outcome:
Added: movie /at 9pm
Exceptions: None.
You may experience these errors in different situations:
I/O error. File not found or corrupt.There is a problem preventing a new file from being created.Unable to create file! Reason: [Reason]File not found error.Move the jar file to another folder with proper access. For example, refrain from using restricted directories such as C:\ or C:\Windows\System32.
Q1: How do I ensure my tasks are saved even if my storage fails (e.g. HDD failure)?
A1: Please backup duke.txt and place it at the same directory as the duke program. Do take note to cd to said directory in terminal before running duke so that
duke recognizes the presence of the file.
Q2: I marked a task as done by mistake. Can I undo it?
A2: Undo functions are not supported. Please make a duplicate task and delete the former task as a workaround.
Q3: I am not able to see ticks and crosses on the tasks. I can only see “?”. How do I resolve this?
A3: Run Chcp 65001 followed by java -Dfile.encoding=UTF-8 -jar [filename].jar to resolve the issue. Also, change the fonts for your console
application to NSimSun. Please ensure you are in the correct directory before doing so.
| Command | Format | Usage Example |
|---|---|---|
| list | list |
list |
| todo | todo [task description] |
todo mop the room |
| deadline | deadline [task description] /by [deadline] |
deadline homework /by tommorrow |
| event | event [task description] /on [occurrence] |
event favorite show /on yesterday |
| find | find [keyword] |
find homework |
| done | done [task number] |
done 8 |
| delete | delete [task number] |
delete 1 |
| bye | bye |
bye |
| traditional task | [input] |
buy book |