-
Notifications
You must be signed in to change notification settings - Fork 228
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
[Andrea Tan] iP #263
Open
andrea-twl
wants to merge
31
commits into
nus-cs2103-AY2021S2:master
Choose a base branch
from
andrea-twl: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
[Andrea Tan] iP #263
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
af7e8f9
Level 1 complete
andrea-twl c621220
Level-2 complete
andrea-twl b3a5323
Level-3 complete
andrea-twl 25b1d6b
level-4 completed (implemented ToDo.java, Deadline.java and Event.jav…
andrea-twl dd45d1b
Level-5 complete (added DukeIncompleteCommandException.java and DukeI…
andrea-twl 26418a3
Level-6 completed (added delete function)
andrea-twl 0a0fc47
Level-7 complete (save and load - added saveFile() and loadFIle(), as…
andrea-twl 18b425d
Level-8 complete (added date, recoded loadFile(), handled exceptions)
andrea-twl a7089c6
Merge branch 'branch-Level-8'
andrea-twl 75632ce
Merge branch 'branch-Level-7'
andrea-twl 2061878
A-MoreOOP (added Tasklist.java, Storage.java, Parser.java and UI.java)
andrea-twl b785eec
A-JUnit (added ParserTest.java, TodoTest.java and DukeTest.java)
andrea-twl 5ea5f47
A-JavaDoc (added JavaDocs to most classes)
andrea-twl 1f42308
A-CodingStandard (fixed tabs, added line breaks)
andrea-twl 8b0510b
Level-9 complete (Find)
andrea-twl e7cb203
Merge branch 'branch-A-CodingStandard'
andrea-twl 3038258
Merge branch 'branch-Level-9'
andrea-twl c475678
Level-10 GUI
andrea-twl b5e8f0f
Bug fixes - reconfigured duke package
andrea-twl a61b6df
A-Assertions
andrea-twl 62293f2
A-CodeQuality
andrea-twl 081fe4e
Merge pull request #2 from andrea-twl/branch-A-Assertions
andrea-twl c9172b6
merge commit
andrea-twl 1abb403
Merge branch 'master' into branch-A-CodeQuality
andrea-twl ae13b46
BCD-Extension (added C-Sort)
andrea-twl 382cb20
Merge branch 'branch-A-CodeQuality'
andrea-twl e6d3f36
Updated README, added help menu
andrea-twl be967e3
Set theme jekyll-theme-cayman
andrea-twl ddd5d12
Update README.md
andrea-twl b7d0bbe
added Ui.png
andrea-twl 7e15137
Merge branch 'master' of https://github.com/andrea-twl/ip
andrea-twl 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,18 +1,29 @@ | ||
package com.jetbrains; | ||
|
||
import java.lang.Throwable; | ||
public class Deadline extends Task { | ||
String dueDate; | ||
String by; | ||
|
||
Deadline(String input) { | ||
String[] inputs = input.trim().split("/by "); | ||
this.task = inputs[0].substring(9); | ||
Deadline(String input) throws DukeIncompleteCommandException { | ||
input = input.substring(8).trim(); | ||
|
||
if (input.equals("")) { | ||
throw new DukeIncompleteCommandException(); | ||
} | ||
|
||
String[] inputs = input.split("/by"); | ||
|
||
if (!input.contains("/by") || inputs.length < 2) { | ||
throw new DukeIncompleteCommandException("Oh no! Please enter an due date. :P"); | ||
} | ||
this.task = inputs[0]; | ||
this.isDone = false; | ||
this.dueDate = inputs[1]; | ||
this.by = inputs[1].trim(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("DDLN%s (by: %s)" , | ||
super.toString(), dueDate); | ||
super.toString(), by); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
import java.util.Scanner; | ||
import java.util.ArrayList; | ||
import java.lang.Throwable; | ||
|
||
public class Duke { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe some java docs will be useful to make the user understand the code better! |
||
public static void main(String[] args) { | ||
|
@@ -18,17 +19,21 @@ public static void main(String[] args) { | |
Scanner sc = new Scanner(System.in); | ||
String input = sc.nextLine(); | ||
while (!input.equals("bye")) { | ||
Task task; | ||
try { | ||
if (input.equals("list")) { | ||
displayList(list); | ||
System.out.println("\n"); | ||
} else if (input.contains("done")) { | ||
String[] doneCommand = input.split(" "); | ||
Task task = list.get(Integer.parseInt(doneCommand[1]) - 1); | ||
task = list.get(Integer.parseInt(doneCommand[1]) - 1); | ||
System.out.println("Good job! I've marked this task as done:\n " + | ||
task.markDone() + | ||
"\n"); | ||
} else { | ||
Task task; | ||
} else if (input.contains("todo") || | ||
input.contains("deadline") || | ||
input.contains("event")) { | ||
|
||
if (input.contains("todo")) { | ||
task = new ToDo(input); | ||
} else if (input.contains("deadline")) { | ||
|
@@ -39,10 +44,16 @@ public static void main(String[] args) { | |
list.add(task); | ||
System.out.println("I'll take note! \n added: " + | ||
task + "\nNow you have " + list.size() + | ||
" task(s) in the list. \n" ); | ||
" task(s) in the list. \n"); | ||
} else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is great that you implemented Duke Exceptions early! |
||
throw new DukeInvalidCommandException(); | ||
} | ||
} catch (Exception e) { | ||
System.out.println(e.getMessage()); | ||
} | ||
input = sc.nextLine(); | ||
} | ||
input = sc.nextLine(); | ||
} | ||
|
||
sc.close(); | ||
System.out.println("Bye! Stay on task!"); | ||
} | ||
|
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,18 @@ | ||
package com.jetbrains; | ||
|
||
public class DukeIncompleteCommandException extends Exception { | ||
public String message; | ||
DukeIncompleteCommandException() { | ||
this.message = "Oh no! Task cannot be empty. ):"; | ||
} | ||
DukeIncompleteCommandException(String message) { | ||
this.message = message; | ||
} | ||
@Override | ||
public String getMessage() { | ||
return message; | ||
} | ||
public String toString() { | ||
return message; | ||
} | ||
} |
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,16 @@ | ||
package com.jetbrains; | ||
|
||
public class DukeInvalidCommandException extends Exception { | ||
public String message = "Oh no! I don't know what that means. ):"; | ||
DukeInvalidCommandException() { | ||
} | ||
|
||
@Override | ||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
public String toString() { | ||
return message; | ||
} | ||
} |
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,18 +1,31 @@ | ||
package com.jetbrains; | ||
|
||
import java.lang.Throwable; | ||
public class Event extends Task { | ||
String eventDate; | ||
String at; | ||
|
||
Event(String input) { | ||
String[] inputs = input.trim().split("/at "); | ||
this.task = inputs[0].substring(6); | ||
Event(String input) throws DukeIncompleteCommandException { | ||
input = input.substring(5).trim(); | ||
|
||
if (input.equals("")) { | ||
throw new DukeIncompleteCommandException(); | ||
} | ||
|
||
String[] inputs = input.split("/at"); | ||
|
||
if (!input.contains("/at") || inputs.length < 2) { | ||
throw new DukeIncompleteCommandException("Oh no! Please enter an event date. :P"); | ||
} | ||
|
||
this.task = inputs[0]; | ||
this.isDone = false; | ||
this.eventDate = inputs[1]; | ||
this.at = inputs[1].trim(); | ||
} | ||
|
||
|
||
@Override | ||
public String toString() { | ||
return String.format("EVNT%s (at: %s)" , | ||
super.toString(), eventDate); | ||
super.toString(), at); | ||
} | ||
} |
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
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.
I think dueDate should be used instead of by as the former is more understandable!