-
Notifications
You must be signed in to change notification settings - Fork 362
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
[randallnhr] iP #389
Open
randallnhr
wants to merge
41
commits into
nus-cs2103-AY2223S2:master
Choose a base branch
from
randallnhr: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
[randallnhr] iP #389
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
556af3f
Add Gradle support
d931af6
Level-1
randallnhr 34904a0
Level-1
randallnhr 4e12dad
Level-2
randallnhr 510ffff
Level-3
randallnhr 927000e
Level-4
randallnhr 7315848
A-TextUiTesting
randallnhr 149e1d0
Level-5
randallnhr 357e5f7
Level-6
randallnhr c2c6903
Level-7
randallnhr 231ec2e
Level-8
randallnhr 4614698
updated input and expected txt files
randallnhr dbb7cbf
Merge branch 'branch-Level-8'
randallnhr df38bca
Merge Level-8 to master
randallnhr 5c0e7b1
A-MoreOOP
randallnhr 674f297
A-Packages
randallnhr c894cbf
Merge remote-tracking branch 'origin/add-gradle-support'
randallnhr 2e673f7
A-Gradle
randallnhr 359765a
A-JUnit
randallnhr 224fa30
Add increment A-JavaDoc
randallnhr 24d5209
Remove redundant codes and correct layout of code
randallnhr 74266a2
Add increment Level-9
randallnhr 56f1dc5
Merge branch 'branch-A-CodingStandard'
randallnhr 25c6740
Merge branch 'branch-Level-9'
randallnhr 1318085
Add GUI
randallnhr 31a8483
Add GUI
randallnhr c0d137a
Merge branch 'branch-Level-10'
randallnhr caacaec
Add assertions
randallnhr 0af8473
Merge pull request #2 from randallnhr/branch-A-Assertions
randallnhr 47ec878
Improve CodeQuality
randallnhr 8794559
Fix error in Parser
randallnhr c21cf25
Merge pull request #3 from randallnhr/branch-A-CodeQuality
randallnhr 8539e7e
Add reschedule functionality
randallnhr d962643
Merge branch 'branch-BCD-Extension'
randallnhr 47632b4
Improve GUI
randallnhr 0f35873
Add personality
randallnhr 1c91d33
Add personality
randallnhr 919e432
Edit delete and error message
randallnhr 9a5d484
Add Ui.png
randallnhr a70e173
Edit README.md
randallnhr 0c185b1
Edit README.md
randallnhr 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class Deadline extends Task { | ||
public Deadline(String name, String start) { | ||
super(name, start, null); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return this.isDone | ||
? "[D][X] " + this.name + " (by: " + this.startDate + ")" | ||
: "[D][ ] " + this.name + " (by: " + this.startDate + ")"; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
import java.util.ArrayList; | ||
import java.util.Iterator; | ||
|
||
|
||
public class Duke { | ||
public static void main(String[] args) throws IOException { | ||
|
||
|
@@ -12,8 +13,9 @@ public static void main(String[] args) throws IOException { | |
|
||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | ||
|
||
String[] word = br.readLine().split(" "); | ||
String[] word = br.readLine().split(" ",2); | ||
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. would renaming word make it less vague and reflect more as a command? |
||
ArrayList<Task> lst = new ArrayList<>(); | ||
int count = 0; | ||
|
||
while (!word[0].equals("bye")) { | ||
if (word[0].equals("list")) { | ||
|
@@ -23,40 +25,45 @@ public static void main(String[] args) throws IOException { | |
System.out.println(curr + " " + iter.next()); | ||
curr++; | ||
} | ||
word = br.readLine().split(" "); | ||
word = br.readLine().split(" ",2); | ||
} else if (word[0].equals("mark")) { | ||
Task t = lst.get(Integer.parseInt(word[1]) - 1); | ||
t.isDone = true; | ||
System.out.println("Task has been marked as done:\n " + t); | ||
word = br.readLine().split(" "); | ||
word = br.readLine().split(" ",2); | ||
} else if (word[0].equals("unmark")) { | ||
Task t = lst.get(Integer.parseInt(word[1]) - 1); | ||
t.isDone = false; | ||
System.out.println("Task has been marked as not done:\n " + t); | ||
word = br.readLine().split(" "); | ||
word = br.readLine().split(" ",2); | ||
} else if (word[0].equals("todo")) { | ||
Task t = new Todo(word[1]); | ||
lst.add(t); | ||
count++; | ||
System.out.println("Added new todo:\n " + t + "\nNumber of tasks: " + count); | ||
word = br.readLine().split(" ",2); | ||
} else if (word[0].equals("deadline")) { | ||
String[] tempWord = word[1].split("/by "); | ||
Task t = new Deadline(tempWord[0], tempWord[1].strip()); | ||
lst.add(t); | ||
count++; | ||
System.out.println("Added new deadline:\n " + t + "\nNumber of tasks: " + count); | ||
word = br.readLine().split(" ",2); | ||
} else if (word[0].equals("event")) { | ||
String[] tempWord = word[1].split("/"); | ||
Task t = new Event(tempWord[0], tempWord[1].split(" ",2)[1].strip(), tempWord[2].split(" ")[1].strip()); | ||
lst.add(t); | ||
count++; | ||
System.out.println("Added new event:\n " + t + "\nNumber of tasks: " + count); | ||
word = br.readLine().split(" ",2); | ||
} else { | ||
System.out.println("Added task: " + word[0]); | ||
lst.add(new Task(word[0])); | ||
word = br.readLine().split(" "); | ||
System.out.println("Error"); | ||
word = br.readLine().split(" ",2); | ||
} | ||
} | ||
System.out.println("Duke: Goodbye"); | ||
} | ||
} | ||
|
||
class Task { | ||
protected String name; | ||
protected boolean isDone; | ||
|
||
public Task(String name) { | ||
this.name = name; | ||
this.isDone = false; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return isDone | ||
? "[X] " + this.name | ||
: "[ ] " + this.name; | ||
} | ||
} |
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,12 @@ | ||
class Event extends Task { | ||
public Event(String name, String start, String end) { | ||
super(name, start, end); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return this.isDone | ||
? "[E][X] " + this.name + " (from: " + this.startDate + " to: " + this.endDate + ")" | ||
: "[E][ ] " + this.name + " (from: " + this.startDate + " to: " + this.endDate + ")"; | ||
} | ||
} |
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,20 @@ | ||
public class Task { | ||
protected String name; | ||
protected boolean isDone; | ||
protected String startDate; | ||
protected String endDate; | ||
|
||
public Task(String name, String date1, String date2) { | ||
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. would it be better to abstract out startDate and endDate to Event class? |
||
this.name = name; | ||
this.isDone = false; | ||
this.startDate = date1; | ||
this.endDate = date2; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return this.isDone | ||
? "[X] " + this.name | ||
: "[ ] " + this.name; | ||
} | ||
} |
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,12 @@ | ||
public class Todo extends Task { | ||
public Todo(String name) { | ||
super(name, null, null); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return this.isDone | ||
? "[T][X] " + this.name | ||
: "[T][ ] " + this.name; | ||
} | ||
} |
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 like that you store word as a String array for easier manipulation