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

[Lam Yue Wei] iP #57

Open
wants to merge 55 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
fcd317b
Completed Level 0 (Greet)
lamyuewei Jan 28, 2020
59307c5
Completed Level 1. Greet, Echo, Exit
lamyuewei Jan 31, 2020
5895960
Completed Level 2. Add, List
lamyuewei Jan 31, 2020
ce2126e
Completed Level 3. Mark as Done
lamyuewei Jan 31, 2020
dd30a60
Completed Extension of Level 3: A-Classes
lamyuewei Jan 31, 2020
19ae450
Completed tweaking the code to comply with a coding standard (A-Codin…
lamyuewei Jan 31, 2020
87cd5ff
Completed Level-4: ToDo, Event, Deadline
lamyuewei Feb 2, 2020
cc313b9
Completed A-TextUiTesting: Automated Text UI Testing
lamyuewei Feb 10, 2020
5baf6ea
A-CodeQuality: Improve Code Quality through refracting codes as well …
lamyuewei Feb 11, 2020
a9bead2
Refracted case list, done & bye into methods. Added Exceptions for li…
lamyuewei Feb 11, 2020
8e9ad00
Completed A-Exceptions. Refracted and added exception for todo, deadl…
lamyuewei Feb 13, 2020
45fee0f
Minimum editing to Task's getStatusIcon to make use of getter rather …
lamyuewei Feb 13, 2020
d7d84c2
Merge branch 'branch-Level-5'
lamyuewei Feb 13, 2020
d4b3fdc
Completed A-Packages: Organize into Packages
lamyuewei Feb 13, 2020
c38ed01
Updated input, actual and expected files to make testing more vigorou…
lamyuewei Feb 13, 2020
c159fbd
Merge branch 'branch-A-Packages'
lamyuewei Feb 13, 2020
d972c31
Commit manifest file for A-Jar
lamyuewei Feb 28, 2020
47b8924
Add delete method for level 6 and update test cases
lamyuewei Mar 1, 2020
9ed4570
Complete Level 7 Save Method
lamyuewei Mar 2, 2020
62e11ce
Merge branch 'branch-Level-6'
lamyuewei Mar 2, 2020
29f37cc
Merge branch 'branch-Level-7', Resolve Merge Conflict
lamyuewei Mar 2, 2020
d382133
Replace Symbols(Tick, Cross, Smiley Face) with Words
lamyuewei Mar 2, 2020
26b1ef0
Complete Level 9 Find, Modify runtest.bat to delete duke.txt in text-…
lamyuewei Mar 2, 2020
c367324
Merge pull request #2 from lamyuewei/branch-Level-9
lamyuewei Mar 2, 2020
dfd0064
Complete A-JavaDoc and Add JavaDoc comments
lamyuewei Mar 2, 2020
c03d3ab
Resolve merge conflict of branch 'master' into branch-A-JavaDoc
lamyuewei Mar 2, 2020
ecc5cff
Merge pull request #4 from lamyuewei/branch-A-JavaDoc
lamyuewei Mar 2, 2020
c11bc5e
Complete Level 8. Dates and Times for deadline and event
lamyuewei Mar 2, 2020
d9fdaf4
Resolve Merge Conflict of branch 'master' into branch-Level-8
lamyuewei Mar 2, 2020
8397876
Merge pull request #5 from lamyuewei/branch-Level-8
lamyuewei Mar 2, 2020
c150c23
Commit changes post Level 8
lamyuewei Mar 2, 2020
8d1b6bb
Edit Duke File
lamyuewei Mar 2, 2020
ed501e8
Merge branch 'master' of https://github.com/lamyuewei/duke
lamyuewei Mar 2, 2020
9db50ad
Set theme jekyll-theme-cayman
lamyuewei Mar 2, 2020
40c9d1c
Complete A-UserGuide: User Guide
lamyuewei Mar 2, 2020
6403971
Rectify issue of editing on the Wrong README earlier
lamyuewei Mar 2, 2020
8b2079c
Bug fixed to rmake word bold instead of showing #
lamyuewei Mar 2, 2020
0d43e60
Bug Fixed for README next line
lamyuewei Mar 2, 2020
1794379
Bug Fix for Summary of Content in README
lamyuewei Mar 2, 2020
a50358e
Bug fix v2 for Summary of Command in README
lamyuewei Mar 2, 2020
d434479
Bug fix v3 for Summary of Comand in README
lamyuewei Mar 2, 2020
3d47646
Bug Fixed Typo in README
lamyuewei Mar 2, 2020
8946f00
Add help command
lamyuewei Mar 2, 2020
2e37685
Add Storage and Ui class
lamyuewei Mar 2, 2020
03d714a
Add emphasize on keywords in README
lamyuewei Mar 3, 2020
fc66763
Add Parser and TaskList
lamyuewei Mar 13, 2020
f2cfdda
Add Command, HelpCommand, ListCommand
lamyuewei Mar 14, 2020
9fee2e4
Extract list and help into parser
lamyuewei Mar 15, 2020
0153e1f
Add DukeException and DukeDateTimeException
lamyuewei Mar 15, 2020
df59569
Add DoneCommand and FindCommand
lamyuewei Mar 15, 2020
b2c9113
Add DeleteCommand
lamyuewei Mar 15, 2020
245182d
Complete all extraction into Command and Parser
lamyuewei Mar 16, 2020
2ce54f1
Minor edit on javadoc
lamyuewei Mar 16, 2020
5df548e
Bug Fix on Storage, add exception in Parser
lamyuewei Mar 16, 2020
c182a6a
Package Storage, Ui, Parser, Constant, TaskList Object
lamyuewei Mar 16, 2020
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
11 changes: 11 additions & 0 deletions src/main/java/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
public class Deadline extends Task {
String date;
public Deadline(String description, String date) {
super(description);
this.date = date;
}

public String toString() {
return "[D]" + super.toString() + " (by: " + this.date + ")";
}
}
75 changes: 69 additions & 6 deletions src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,73 @@
import java.util.Scanner;
import java.util.Arrays;

public class Duke {
public static void main(String[] args) {
String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
Task[] tasks = new Task[100];
int count = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should use 'taskCount' to refer to the total number of tasks.

boolean isBye = false;
System.out.println(" ____________________________________________________________");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can apply refactoring to the greeting function.

System.out.println(" Hello! I'm Duke");
System.out.println(" What can I do for you?");
System.out.println(" ____________________________________________________________");
Scanner sc = new Scanner(System.in);
while (!isBye) {
String description;
String date;
System.out.println();
String string = sc.nextLine();
System.out.println(" ____________________________________________________________");
String[] stringSplit = string.split(" ");
switch (stringSplit[0]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use switch to deal with different types of commands is more clear than my method. Nice!

case "list":
System.out.println(" Here are the tasks in your list:");
for (int i = 0; i < count; i++) {
System.out.println(" " + (i + 1) + "." + tasks[i].toString());
}
break;
case "done":
int done = Integer.parseInt(stringSplit[1]) - 1;
tasks[done].markAsDone();
System.out.println(" Nice! I've marked this task as done: ");
System.out.println(" " + tasks[done].toString());
break;
case "bye":
System.out.println(" Bye. Hope to see you again soon!");
isBye = true;
break;
case "todo":
description = String.join(" ", Arrays.copyOfRange(stringSplit, 1, stringSplit.length));
tasks[count] = new Todo(description);
System.out.println(" Got it. I've added this task: ");
System.out.println(" " + tasks[count].toString());
count++;
System.out.println(" Now you have " + count + " tasks in the list.");
break;
case "deadline":
description = string.substring(0, string.indexOf(" /by")).replace("deadline ", "");
date = string.substring(string.indexOf("/by ")).replace("/by ", "");
tasks[count] = new Deadline(description, date);
System.out.println(" Got it. I've added this task: ");
System.out.println(" " + tasks[count].toString());
count++;
System.out.println(" Now you have " + count + " tasks in the list.");
break;
case "event":
description = string.substring(0, string.indexOf(" /at")).replace("event ", "");
date = string.substring(string.indexOf("/at ")).replace("/at ", "");
tasks[count] = new Event(description, date);
System.out.println(" Got it. I've added this task: ");
System.out.println(" " + tasks[count].toString());
count++;
System.out.println(" Now you have " + count + " tasks in the list.");
break;
default: //add Task into List
tasks[count] = new Task(string);
System.out.println(" added: " + tasks[count].getDescription());
count++;
break;
}
System.out.println(" ____________________________________________________________");
}
}
}
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 @@
public class Event extends Task {
String date;

public Event(String description, String date) {
super(description);
this.date = date;
}

public String toString() {
return "[E]" + super.toString() + " (at: " + this.date + ")";
}
}
30 changes: 30 additions & 0 deletions src/main/java/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
public class Task {
protected String description;
protected boolean isDone;

public Task(String description) {
this.description = description;
this.isDone = false;
}

public String getStatusIcon() {
return (isDone ? "\u2713" : "\u2718"); //return tick or X symbols
}

// Not immutable version
public void markAsDone() {
this.isDone = true;
}

public String getDescription() {
return this.description;
}

public boolean getIsDone() {
return this.isDone;
}

public String toString() {
return "[" + getStatusIcon() + "] " + getDescription();
}
}
9 changes: 9 additions & 0 deletions src/main/java/Todo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
public class Todo extends Task {
public Todo(String description) {
super(description);
}

public String toString() {
return "[T]" + super.toString();
}
}