Skip to content
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
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
556af3f
Add Gradle support
May 24, 2020
d931af6
Level-1
randallnhr Jan 16, 2023
34904a0
Level-1
randallnhr Jan 16, 2023
4e12dad
Level-2
randallnhr Jan 16, 2023
510ffff
Level-3
randallnhr Jan 18, 2023
927000e
Level-4
randallnhr Jan 19, 2023
7315848
A-TextUiTesting
randallnhr Jan 20, 2023
149e1d0
Level-5
randallnhr Jan 20, 2023
357e5f7
Level-6
randallnhr Jan 20, 2023
c2c6903
Level-7
randallnhr Feb 3, 2023
231ec2e
Level-8
randallnhr Feb 4, 2023
4614698
updated input and expected txt files
randallnhr Feb 4, 2023
dbb7cbf
Merge branch 'branch-Level-8'
randallnhr Feb 4, 2023
df38bca
Merge Level-8 to master
randallnhr Feb 4, 2023
5c0e7b1
A-MoreOOP
randallnhr Feb 4, 2023
674f297
A-Packages
randallnhr Feb 5, 2023
c894cbf
Merge remote-tracking branch 'origin/add-gradle-support'
randallnhr Feb 5, 2023
2e673f7
A-Gradle
randallnhr Feb 5, 2023
359765a
A-JUnit
randallnhr Feb 5, 2023
224fa30
Add increment A-JavaDoc
randallnhr Feb 5, 2023
24d5209
Remove redundant codes and correct layout of code
randallnhr Feb 5, 2023
74266a2
Add increment Level-9
randallnhr Feb 5, 2023
56f1dc5
Merge branch 'branch-A-CodingStandard'
randallnhr Feb 5, 2023
25c6740
Merge branch 'branch-Level-9'
randallnhr Feb 5, 2023
1318085
Add GUI
randallnhr Feb 11, 2023
31a8483
Add GUI
randallnhr Feb 12, 2023
c0d137a
Merge branch 'branch-Level-10'
randallnhr Feb 12, 2023
caacaec
Add assertions
randallnhr Feb 12, 2023
0af8473
Merge pull request #2 from randallnhr/branch-A-Assertions
randallnhr Feb 12, 2023
47ec878
Improve CodeQuality
randallnhr Feb 12, 2023
8794559
Fix error in Parser
randallnhr Feb 12, 2023
c21cf25
Merge pull request #3 from randallnhr/branch-A-CodeQuality
randallnhr Feb 12, 2023
8539e7e
Add reschedule functionality
randallnhr Feb 14, 2023
d962643
Merge branch 'branch-BCD-Extension'
randallnhr Feb 14, 2023
47632b4
Improve GUI
randallnhr Feb 16, 2023
0f35873
Add personality
randallnhr Feb 16, 2023
1c91d33
Add personality
randallnhr Feb 16, 2023
919e432
Edit delete and error message
randallnhr Feb 16, 2023
9a5d484
Add Ui.png
randallnhr Feb 16, 2023
a70e173
Edit README.md
randallnhr Feb 17, 2023
0c185b1
Edit README.md
randallnhr Feb 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/main/java/Deadline.java
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 + ")";
}
}
49 changes: 28 additions & 21 deletions src/main/java/Duke.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.ArrayList;
import java.util.Iterator;


public class Duke {
public static void main(String[] args) throws IOException {

Expand All @@ -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);

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

Choose a reason for hiding this comment

The 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")) {
Expand All @@ -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;
}
}
12 changes: 12 additions & 0 deletions src/main/java/Event.java
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 + ")";
}
}
20 changes: 20 additions & 0 deletions src/main/java/Task.java
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) {

Choose a reason for hiding this comment

The 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;
}
}
12 changes: 12 additions & 0 deletions src/main/java/Todo.java
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;
}
}