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

[Jingtan]iP #51

Open
wants to merge 48 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
65f72a8
Add support for Gradle workflow
j-lum Aug 6, 2019
0112efe
Add sample checkstyle configuration
j-lum Aug 12, 2019
cfd6da7
Change file mode on `gradle` to be executable
j-lum Aug 18, 2019
6e6ace1
Merge pull request #12 from j-lum/gradle+x
j-lum Aug 18, 2019
a3ca5a4
Add configuration for console applications
j-lum Aug 20, 2019
7b60e81
Merge pull request #13 from j-lum/javaexec
j-lum Aug 21, 2019
c4678f7
JavaFX tutorial: Support cross-platform JARs
j-lum Sep 20, 2019
30efbae
JavaFX tutorial: Support cross-platform JARs [#16]
damithc Oct 7, 2019
88d53b0
Level-1
JTWang2000 Jan 30, 2020
507e0c5
Add List
JTWang2000 Jan 30, 2020
a76509a
Delete useless class and add horizontal lines, remain in Level 2
JTWang2000 Jan 30, 2020
fe534da
Add the ability to mark tasks as done.
JTWang2000 Jan 30, 2020
9cb4fc3
Add the ability to mark tasks as done.
JTWang2000 Jan 30, 2020
c8d841c
Debug an error of listing task and Refactoring
JTWang2000 Feb 3, 2020
8dd00b3
Add support for tracking three types of tasks
JTWang2000 Feb 3, 2020
10b91e7
Improve code quality
JTWang2000 Feb 3, 2020
41b2e87
Add automated text UI testing
JTWang2000 Feb 10, 2020
b5dffc2
Handle two types of errors: meaningless input and empty task description
JTWang2000 Feb 10, 2020
49c4e44
Handle errors of list, done and wrong format of deadline and event
JTWang2000 Feb 10, 2020
ce678f9
Merge branch 'branch-Level-5'
JTWang2000 Feb 10, 2020
21746f9
Add packages: duke and duke.task; Update ui-test
JTWang2000 Feb 10, 2020
79a49ba
Delete: Add support for deleting tasks from the list.
JTWang2000 Feb 16, 2020
55b86ca
Use Java Collections classes: ArrayList<Task> to store the tasks.
JTWang2000 Feb 16, 2020
69abf30
Load the data from hard disk when Duke starts up
JTWang2000 Feb 16, 2020
8c5fe95
Save the tasks in the hard disk automatically whenever the task list …
JTWang2000 Feb 16, 2020
6624f8c
Merge branch 'branch-Level-6'
JTWang2000 Feb 16, 2020
a6c4cc2
Merge branch 'branch-Level-7'
JTWang2000 Feb 16, 2020
a28ff87
Merge branch 'gradle'
JTWang2000 Feb 17, 2020
34d44a8
Create a JAR and set up gradle so that you can build and run Duke usi…
JTWang2000 Feb 17, 2020
e149a6a
Create back up file when there is no such file exists.
JTWang2000 Feb 17, 2020
099dc7e
Follow Java Coding Standard
JTWang2000 Feb 25, 2020
bb1ae6a
Add constants file
JTWang2000 Feb 25, 2020
4116a14
Use more OOP and update the test-ui
JTWang2000 Feb 26, 2020
51dc541
Change command to be abstract class and modify the exitcommand.
JTWang2000 Feb 27, 2020
80a856b
Find: Give users a way to find a task by searching for a keyword in d…
JTWang2000 Feb 27, 2020
9232bc8
Dates and Times: Teach Duke to understand dates and times.
JTWang2000 Feb 27, 2020
c93b0d6
Stretch goal: add a command CHECK to print deadlines/events occurring…
JTWang2000 Feb 27, 2020
5a8a358
Add JavaDoc comments to the code.
JTWang2000 Feb 27, 2020
bf391b2
Add more JavaDoc comments to the code.
JTWang2000 Feb 27, 2020
e4e865f
Merge pull request #2 from JTWang2000/branch-Level-8
JTWang2000 Feb 28, 2020
13325ba
Merge branch 'master' into branch-Level-9
JTWang2000 Feb 28, 2020
a2d1f30
Merge pull request #3 from JTWang2000/branch-Level-9
JTWang2000 Feb 28, 2020
9c66984
Merge branch 'master' into branch-A-JavaDoc
JTWang2000 Feb 28, 2020
28862e9
Merge pull request #4 from JTWang2000/branch-A-JavaDoc
JTWang2000 Feb 28, 2020
05c3f9f
Add JAVADoc for newly merged classes and cording coding standard issues.
JTWang2000 Feb 29, 2020
9961085
Add HELP command for users to understand Duke.
JTWang2000 Feb 29, 2020
e74dc07
Add User Guide
JTWang2000 Feb 29, 2020
d87fa9b
Set theme jekyll-theme-cayman
JTWang2000 Feb 29, 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
14 changes: 14 additions & 0 deletions src/main/java/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
public class Deadline extends Task{

protected String by;

public Deadline(String description,String by){
super(description);
this.by = by;
}

@Override
public String toString(){
return "[D]" + super.toString() + " (by: " + by + ")";
}
}
87 changes: 87 additions & 0 deletions src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,97 @@
import java.util.Scanner;

Choose a reason for hiding this comment

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

For readability, it might be better to have a new line to separate main code and import lines.

public class Duke {

private static Task[] tasks = new Task[100];

Choose a reason for hiding this comment

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

I think it was mentioned not to use magic numbers, perhaps a static int could be used instead

private static int taskCount = 0;

public static void main(String[] args) {
String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
greet();

String userResponde;
Scanner in = new Scanner(System.in);
do {
userResponde = in.nextLine();
dukeResponde(userResponde);

}while(!userResponde.equals("bye"));

Choose a reason for hiding this comment

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

It would be nice if there was a space between } and "while" so that it is easier to read.


}

public static void greet(){
printLine();
System.out.println("\tHello! I'm Duke");
System.out.println("\tWhat can I do for you?");
printLine();
System.out.println();
}

public static void dukeResponde(String userResponde){
printLine();
if(userResponde.equals("bye")){
sayBye();
}
else if(userResponde.equals("list")) {
listTask();
}
else if(userResponde.startsWith("done")) {
markAsDone(userResponde);
}
else{
addNewTask(userResponde);
}

Choose a reason for hiding this comment

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

With reference to the coding standard, it is recommended that "else" is on the same line as "}" of the previous case.
if (xxx) {
} else {
}

printLine();
System.out.println();
}

public static void printLine(){
System.out.println("\t____________________________________________________________");
}

public static void sayBye(){
System.out.println("\tBye. Hope to see you again soon!");
}

public static void listTask(){
System.out.println("\tHere are the tasks in your list:");
for(int i = 0; i < taskCount; i++) {
System.out.println("\t" + (i + 1) + "." + tasks[i]);
}
}

public static void markAsDone(String userResponde){
int doneCount = Integer.parseInt(userResponde.substring(5)) - 1;

Choose a reason for hiding this comment

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

The variable name for this seems to be slightly misleading as count is usually used to keep count, this is more of an index. Just an opinion though.

tasks[doneCount].markAsDone();
System.out.println("\tNice! I've marked this task as done:");
System.out.println("\t [\u2713] " + tasks[doneCount].getDescription());
}

public static void addNewTask(String userResponde){
if(userResponde.startsWith("todo")){
tasks[taskCount] = new Todo(userResponde.substring(5));
}
else if(userResponde.startsWith("deadline")){
int dividerPosition = userResponde.indexOf(" /by");
String taskName = userResponde.substring(9,dividerPosition);
String deadlineTime = userResponde.substring(dividerPosition + 5);
tasks[taskCount] = new Deadline(taskName,deadlineTime);
}
else if(userResponde.startsWith("event")){
int dividerPosition = userResponde.indexOf(" /at");
String taskName = userResponde.substring(6,dividerPosition);
String deadlineTime = userResponde.substring(dividerPosition + 5);
tasks[taskCount] = new Event(taskName,deadlineTime);
}

Choose a reason for hiding this comment

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

With reference to the coding standard, it is recommended that "else" is on the same line as "}" of the previous case.
if (xxx) {
} else {
}

System.out.println("\tGot it. I've added this task:");
System.out.println("\t " + tasks[taskCount]);
System.out.println("\tNow you have " + (taskCount+1) + " tasks in the list");
taskCount++;
}

}

14 changes: 14 additions & 0 deletions src/main/java/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
public class Event extends Task{

protected String at;

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

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

public Task(){

}

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

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

public String getDescription(){

Choose a reason for hiding this comment

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

For consistency, it might be better to decide on having a space between "()" and "{"

return description;
}

public void markAsDone(){
isDone = true;
}

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

public Todo(String description){
super(description);
}

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