-
Notifications
You must be signed in to change notification settings - Fork 77
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
Mor Ben Ami #66
Open
morbenami1
wants to merge
27
commits into
nus-cs2113-AY2223S1:master
Choose a base branch
from
morbenami1: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
Mor Ben Ami #66
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
3936521
Level-0
morbenami1 2441777
Level 1
morbenami1 d9d4dd1
Level-1
morbenami1 457aa97
Level-2
morbenami1 9a93152
Level-3
morbenami1 663e04a
level 4 - todo, deadline and event
morbenami1 ebce00b
level 4 - added deadline, todo and event
morbenami1 9b10885
Level-5
morbenami1 fa0a0b7
A-Packages
morbenami1 3014403
A-Packages
morbenami1 a75f0e9
delete added
morbenami1 384558f
file(level-7)
morbenami1 1863a24
Merge level-6
morbenami1 4415c2e
Merge branch 'branch-Level-7'
morbenami1 cc20b63
merge start
morbenami1 9aea67a
commit merge try
morbenami1 96e1a6a
delete added
morbenami1 ffefb0f
level 6 and level 7
morbenami1 62c739f
A-MoreOOP
morbenami1 4cea348
added find
morbenami1 72f1c66
added javaDoc
morbenami1 11ac390
Merge pull request #1 from morbenami1/A-JavaDoc
morbenami1 76f79c2
Merge branch 'master' into branch-Level-9
morbenami1 31ee941
Merge pull request #2 from morbenami1/branch-Level-9
morbenami1 e88fde8
finishing touches
morbenami1 b7f67af
A-UserGuide
morbenami1 586a162
Update README.md
morbenami1 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 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,52 @@ | ||
# User Guide | ||
|
||
## Features | ||
|
||
### Feature-ABC | ||
Duke is a task tracker for all the user’s tasks, | ||
the application allows the user to see and update all of his tasks divided into three categories - events, to-dos, and deadlines. | ||
For each task, there is adescriptionn and a mark if the task was done or not. | ||
Also, for events and deadlines there is a date description. | ||
The user can update the task lists with different runs, the task listsavese the list each time the userexistst the application. | ||
|
||
Description of the feature. | ||
|
||
### Feature-XYZ | ||
## Features | ||
|
||
Description of the feature. | ||
* help - all the features available | ||
* mark/unmark - mark a task as done or not | ||
* delete - delete a task from the list | ||
* add a task - todo/deadline/event | ||
* find all the tasks with certain words | ||
* list all the tasks currently in the duke application | ||
|
||
## Usage | ||
|
||
### `Keyword` - Describe action | ||
|
||
Describe the action and its outcome. | ||
input one of the features keywords and additional needed information regarding the keyword. | ||
|
||
### `Keyword` | ||
* 'help' | ||
Example of usage: | ||
|
||
`keyword (optional arguments)` | ||
help | ||
* 'list' | ||
Example of usage: | ||
list | ||
* 'mark' {index of task number to mark as done} | ||
Example of usage: | ||
mark 1 | ||
* 'unmark' {index of task number to mark as done} | ||
Example of usage: | ||
unmark 2 | ||
* 'delete' {index of task number to delete} | ||
Example of usage: | ||
delete 1 | ||
* 'todo' {task description} | ||
Example of usage: | ||
todo plan the weekend | ||
* 'event' {task description} '/at' {date_desciption} | ||
Example of usage: | ||
event F1 /at Singapore | ||
* 'deadline' {task description} '/at' {date_desciption} | ||
deadline CS assignment /by tomorrow | ||
* 'find' {words to search for in the tasks} | ||
find CS | ||
|
||
Expected outcome: | ||
|
||
Description of the outcome. | ||
|
||
``` | ||
expected output | ||
``` | ||
a text file with all the current tasks in the list |
This file contains 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 @@ | ||
T | 1 | be with alon | ||
E | 0 | eat will alon | afternoon |
This file was deleted.
Oops, something went wrong.
This file contains 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 @@ | ||
Manifest-Version: 1.0 | ||
Main-Class: duke.Duke | ||
|
This file contains 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,47 @@ | ||
package duke; | ||
|
||
public class Duke { | ||
protected static TaskList dukeList = new TaskList(); | ||
protected static Storage storage; | ||
public static final String markDone = "mark"; | ||
public static final String delete = "delete"; | ||
public static final String bye = "bye"; | ||
public static final String find = "find"; | ||
public static final String list = "list"; | ||
public static final String help = "help"; | ||
public static final String space = " "; | ||
public static final String unmarkDone = "unmark"; | ||
public static final String filename = "/duke.txt"; | ||
public static final String emptyString = ""; | ||
|
||
/** | ||
* Start and runs the duke application, | ||
* checks if the duke file exist if not creates one, | ||
* parsers input from the user and update duke accordingly | ||
* @throws DukeException | ||
*/ | ||
public static void run() throws DukeException { | ||
try { | ||
storage = new Storage(); | ||
storage.openOrCreateFile(); | ||
storage.uploadDataToList(); | ||
} catch (DukeException e){ | ||
Message.printSystemError(); | ||
} | ||
Message.printLogo(); | ||
Message.printGreeting(); | ||
Ui.input(); | ||
} | ||
|
||
/** | ||
* calls the run function and starts the duke application | ||
* @param args | ||
*/ | ||
public static void main(String[] args) { | ||
try { | ||
run(); | ||
} catch (DukeException e) { | ||
Message.printUnknownError(); | ||
} | ||
} | ||
} |
This file contains 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,10 @@ | ||
diff a/src/main/java/duke/Duke.java b/src/main/java/duke/Duke.java (rejected hunks) | ||
@@ -73,6 +73,8 @@ | ||
dukeList.unmarkItemDone(checkInteger(wordsInput)); | ||
} else if (wordsInput[0].equals(markDone)) { | ||
dukeList.markItemDone(checkInteger(wordsInput)); | ||
+ } else if (wordsInput[0].equals(delete)) { | ||
+ dukeList.deleteTask(checkInteger(wordsInput)); | ||
} else { | ||
dukeList.addTask(input); | ||
} |
This file contains 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 @@ | ||
package duke; | ||
public class DukeException extends Exception{ | ||
} |
This file contains 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,118 @@ | ||
package duke; | ||
|
||
import duke.task.Task; | ||
|
||
public class Message extends Duke { | ||
public static final String helloMessage = "Hello I'm Duke\nwhat can I do for you?\nenter help for input options"; | ||
public static final String line = "-----------------------------------------------------------"; | ||
public static final String errorLine = "!---------------------------------------------------------!"; | ||
public static final String helloFromMessage = "Hello from\n"; | ||
public static final String amountOfTasksInList = "Now you have %d tasks in the list.\n"; | ||
public static final String fileErrorMessage = "Error using list text, check file"; | ||
public static final String invalidInputMessage = "Invalid input, enter again in a correct format"; | ||
public static final String logo = " ____ _ \n" | ||
+ "| _ \\ _ _| | _____ \n" | ||
+ "| | | | | | | |/ / _ \\\n" | ||
+ "| |_| | |_| | < __/\n" | ||
+ "|____/ \\__,_|_|\\_\\___|\n"; | ||
public static final String beginningDeleteMessage = "Noted. I've removed this task: "; | ||
public static final String unknownErrorMessage = "Sorry, an unknown error occurred "; | ||
public static final String helpMessage = "The following option are available:\n" + | ||
"find {keyword}\nlist\nmark/unmark {index in duke list}\ntodo {description)\n" + | ||
"event {description} /at {time_description}\ndeadline {description} /by {time_description}\n" + | ||
"delete {index in duke list}"; | ||
public static final String byeMessage = "Bye. Hope to see you soon"; | ||
|
||
/** | ||
* prints greeting to the user | ||
*/ | ||
public static void printGreeting() { | ||
printHorizontalLine(); | ||
System.out.println(helloMessage); | ||
printHorizontalLine(); | ||
} | ||
|
||
/** | ||
* prints exit message to the user | ||
*/ | ||
|
||
public static void printingExit() { | ||
printHorizontalLine(); | ||
System.out.println(byeMessage); | ||
printHorizontalLine(); | ||
} | ||
|
||
|
||
/** | ||
* prints horizontal line to the user | ||
*/ | ||
|
||
public static void printHorizontalLine() { | ||
System.out.println(line); | ||
} | ||
|
||
/** | ||
* print horizontal error line message to the user | ||
*/ | ||
public static void printHorizontalErrorLine() { | ||
System.out.println(errorLine); | ||
} | ||
|
||
/** | ||
* prints an error message to the user - | ||
* "Invalid input, enter again in a correct format" | ||
*/ | ||
public static void printError() { | ||
printHorizontalErrorLine(); | ||
System.out.println(invalidInputMessage); | ||
printHorizontalErrorLine(); | ||
} | ||
|
||
|
||
/** | ||
* prints an error the user when there is an | ||
* error with the text file | ||
*/ | ||
|
||
public static void printSystemError() { | ||
printHorizontalErrorLine(); | ||
System.out.println(fileErrorMessage); | ||
printHorizontalErrorLine(); | ||
} | ||
|
||
/** | ||
* prints the duke logo to the user | ||
*/ | ||
public static void printLogo() { | ||
System.out.println(helloFromMessage + logo); | ||
} | ||
|
||
/** | ||
* prints an error to the user | ||
* that an unknown error has happened | ||
*/ | ||
|
||
public static void printUnknownError() { | ||
printHorizontalErrorLine(); | ||
System.out.println(unknownErrorMessage); | ||
printHorizontalErrorLine(); | ||
} | ||
|
||
|
||
public static void printHelp() { | ||
System.out.println(helpMessage); | ||
} | ||
|
||
/** | ||
* prints to the user that the input task has been deleted | ||
* | ||
* @param taskToDelete | ||
*/ | ||
public static void printTaskDeleted(Task taskToDelete) { | ||
System.out.println(beginningDeleteMessage); | ||
System.out.println(taskToDelete); | ||
System.out.printf(amountOfTasksInList, dukeList.getListSize()); | ||
} | ||
|
||
|
||
} |
This file contains 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,112 @@ | ||
package duke; | ||
|
||
import java.io.File; | ||
import java.io.FileNotFoundException; | ||
import java.util.Scanner; | ||
import java.io.IOException; | ||
import java.io.FileWriter; | ||
|
||
public class Storage extends Duke { | ||
public static final String event = "E"; | ||
public static final String one = "1"; | ||
public static final String zero = "0"; | ||
public static final String todo = "T"; | ||
public static final String deadline = "D"; | ||
public static final String divider = " | "; | ||
public static final String dividerSplit = " \\| "; | ||
|
||
private static File file; | ||
public Storage() throws DukeException { | ||
String home = System.getProperty("user.home"); | ||
file = new File(home +filename); | ||
openOrCreateFile(); | ||
} | ||
|
||
/** | ||
* checks if a duke file exists, | ||
* if not, creates one and opens the file | ||
* @throws DukeException | ||
*/ | ||
public void openOrCreateFile() throws DukeException { | ||
|
||
try { | ||
file.createNewFile(); | ||
} catch (IOException e) { | ||
throw new DukeException(); | ||
} | ||
} | ||
|
||
|
||
/** | ||
* uploads list from | ||
* @throws DukeException | ||
*/ | ||
public void uploadDataToList() throws DukeException { | ||
try { | ||
Scanner reader = new Scanner(file); | ||
while (reader.hasNextLine()) { | ||
String data = reader.nextLine(); | ||
translateLineFromFile(data); | ||
} | ||
} catch (FileNotFoundException e) { | ||
throw new DukeException(); | ||
} | ||
} | ||
|
||
/** | ||
* marks isDone depending on the task in the file | ||
* @param isDone | ||
* @throws DukeException | ||
*/ | ||
private static void markIfDone(String isDone) throws DukeException { | ||
if (isDone.equals(one)) { | ||
dukeList.markItemDone(dukeList.getListSize()); | ||
} else if (!isDone.equals(zero)) { | ||
throw new DukeException(); | ||
} | ||
|
||
} | ||
/** | ||
* updates line by line from file to dukelist | ||
* @param line | ||
* @throws DukeException | ||
*/ | ||
public static void translateLineFromFile(String line) throws DukeException { | ||
String[] words = line.split(dividerSplit); | ||
switch (words[0]) { | ||
case todo: { | ||
TaskList.AddTodo(words[2]); | ||
break; | ||
} | ||
case event: { | ||
TaskList.AddEvent(words[2], words[3]); | ||
break; | ||
} | ||
case deadline: { | ||
TaskList.AddDeadline(words[2], words[3]); | ||
break; | ||
} | ||
default: { | ||
throw new DukeException(); | ||
} | ||
} | ||
markIfDone(words[1]); | ||
} | ||
|
||
/** | ||
* saves from dukelist to file | ||
* @throws DukeException | ||
*/ | ||
public static void saveListToFile() throws DukeException { | ||
String home = System.getProperty("user.home"); | ||
try { | ||
FileWriter fw = new FileWriter(home+filename); | ||
for (int i = 0; i < dukeList.getListSize(); i++) { | ||
fw.write(dukeList.getTaskFromList(i).getFileFormat() + System.lineSeparator()); | ||
} | ||
fw.close(); | ||
} catch (IOException e) { | ||
throw new DukeException(); | ||
} | ||
} | ||
} |
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 renaming this function to
printExit
rather thanprintingExit