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

[Liu Han] ip #500

Open
wants to merge 49 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
556af3f
Add Gradle support
May 24, 2020
9676077
Level 1
SweetPotato0213 Aug 18, 2022
0d9ef52
Level 2. Add, List
SweetPotato0213 Aug 18, 2022
5da01cb
Level 3. Mark as Done
SweetPotato0213 Aug 18, 2022
0de5e80
Level 4. ToDos, Events, Deadlines
SweetPotato0213 Aug 18, 2022
3eed790
A-TextUiTesting: Automated Text UI Testing
SweetPotato0213 Aug 18, 2022
dac7f8e
Level 5. Handle Errors
SweetPotato0213 Aug 18, 2022
880e4c0
Level 6. Delete
SweetPotato0213 Aug 18, 2022
2fe064a
A-Enums: Use Enums
SweetPotato0213 Aug 18, 2022
a553d00
Cosmetic changes to follow coding standards
SweetPotato0213 Aug 29, 2022
f5659ce
Level 2(v2)
SweetPotato0213 Aug 29, 2022
27413b8
Level 3(v2)
SweetPotato0213 Aug 29, 2022
ab182d3
Level 4(v2)
SweetPotato0213 Sep 5, 2022
a226e93
Test using the I/O redirection technique
SweetPotato0213 Sep 5, 2022
dbe31f4
Level 5(v2)
SweetPotato0213 Sep 6, 2022
ab2bbb2
Level 6(v2)
SweetPotato0213 Sep 6, 2022
d224115
Level 7.Save
SweetPotato0213 Sep 6, 2022
ece43a0
Level 8. Dates and Times
SweetPotato0213 Sep 6, 2022
eb63281
Level 7. Save
SweetPotato0213 Sep 6, 2022
0e48f38
Level 8. Date time
SweetPotato0213 Sep 6, 2022
e98b02e
Merge branch 'branch-Level-8'
SweetPotato0213 Sep 6, 2022
474467d
Level 7(v2)
SweetPotato0213 Sep 6, 2022
3f2cd52
Merge branch 'branch-Level-7'
SweetPotato0213 Sep 6, 2022
1f03af6
Use More OOP
SweetPotato0213 Sep 6, 2022
dd62132
Organize classes into a package
SweetPotato0213 Sep 6, 2022
82c1254
Merge branch 'add-gradle-support'
SweetPotato0213 Sep 6, 2022
fce0fb3
Use Gradle
SweetPotato0213 Sep 6, 2022
733de7f
Add JUnit Tests
SweetPotato0213 Sep 7, 2022
aea7a3a
Create a JAR file
SweetPotato0213 Sep 7, 2022
75e8974
Add JavaDoc Comments
SweetPotato0213 Sep 7, 2022
f96b9c0
Follow the coding standard
SweetPotato0213 Sep 7, 2022
0948713
Implement Find function
SweetPotato0213 Sep 7, 2022
66c9edc
Merge branch 'branch-A-CodingStandard'
SweetPotato0213 Sep 7, 2022
8a3b775
Merge branch 'branch-Level-9'
SweetPotato0213 Sep 7, 2022
c8a71d1
Cosmetic changes following coding standard
SweetPotato0213 Sep 7, 2022
4c5a763
javafx test
SweetPotato0213 Sep 12, 2022
82f3c2b
Added Main.java and fxml files
SweetPotato0213 Sep 12, 2022
f22bafd
Create MainWindow.java
SweetPotato0213 Sep 12, 2022
57cac3f
Added GUI
SweetPotato0213 Sep 18, 2022
64a62a0
Improve Code Quality
SweetPotato0213 Sep 19, 2022
3493580
Use Assertions
SweetPotato0213 Sep 19, 2022
6a2a08d
Improve the Javadoc statement for getStatus method
SweetPotato0213 Sep 19, 2022
068277a
Merge pull request #2 from SweetPotato0213/branch-A-CodeQuality
SweetPotato0213 Sep 19, 2022
16a3594
Merge pull request #3 from SweetPotato0213/branch-A-Assertions
SweetPotato0213 Sep 19, 2022
719d544
Add an extension Update
SweetPotato0213 Sep 19, 2022
20602c7
User Guide
SweetPotato0213 Sep 19, 2022
4faf015
Attempt to get the GUI work
SweetPotato0213 Oct 20, 2022
271d87c
CLI correction
SweetPotato0213 Oct 24, 2022
d8c698b
CLI update
SweetPotato0213 Oct 24, 2022
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
86 changes: 80 additions & 6 deletions src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,84 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Duke {

enum Ability {

Choose a reason for hiding this comment

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

Good use of enums for different commands!

BYE,
LIST,
MARK,
UNMARK,
TODO,
DELETE
}

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

String hello = " ____________________________________________________________\n" +
" Hello! I'm Duke\n" +
" What can I do for you?\n" +
" ____________________________________________________________\n";
Copy link

Choose a reason for hiding this comment

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

Good minimalist design

System.out.println(hello);

List<Task> list = new ArrayList<Task>();

Choose a reason for hiding this comment

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

Maybe you can change this variable name to tasks or something like that to make it clearer?


Scanner sc = new Scanner(System.in);
String input = sc.next();

while (!input.equals("bye")) {
if (input.equals("list")) {
Copy link

Choose a reason for hiding this comment

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

Consider using switch case instead of if-else

for (int i = 0; i < list.size(); i++) {
System.out.println(i + 1 + "." + list.get(i));
}
} else if (input.equals("mark")) {
int number = sc.nextInt();
Task task = list.get(number - 1);
task.markAsDone();
System.out.println(" ____________________________________________________________\n" +

Choose a reason for hiding this comment

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

You may consider placing line break before operator +

Copy link

Choose a reason for hiding this comment

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

Also consider storing the separator as a constant

" Nice! I've marked this task as done:\n " +
task +
"\n ____________________________________________________________");
} else if (input.equals("unmark")) {
int number = sc.nextInt();
Task task = list.get(number - 1);
task.markAsNotDone();
System.out.println(" ____________________________________________________________\n" +
" Nice! I've marked this task as not done yet:\n " +
task +
"\n ____________________________________________________________");
} else {
input = input + sc.nextLine();
System.out.println("Added: " + input);
Task task = new Task(input);
list.add(task);
}
input = sc.next();
}



String strlst = "____________________________________________________________\n" +

Choose a reason for hiding this comment

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

Maybe you can change this variable to stringList or something like that to make it clearer?

" Here are the tasks in your list:";

System.out.println(strlst);

Choose a reason for hiding this comment

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

I think can remove a blank line here 😃

String todolist = "____________________________________________________________\n" +

Choose a reason for hiding this comment

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

Should this be todoList?

" Got it. I've added this task:";
System.out.println(todolist);

String todoEmpty = "____________________________________________________________\n" +
" ☹ OOPS!!! The description of a todo cannot be empty.\n" +
"____________________________________________________________\n";
System.out.println(todoEmpty);

String unkown = "____________________________________________________________\n" +
" ☹ OOPS!!! I'm sorry, but I don't know what that means :-(\n" +
"____________________________________________________________\n";

System.out.println(unkown);

// if("delete")

}
}
Binary file added src/main/java/Task.class
Binary file not shown.
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 getStatus() {
if (isDone) {
return "X";
} else {
return " ";
}
}

public void markAsDone() {
this.isDone = true;
}

public void markAsNotDone() {
this.isDone = false;
}

@Override
public String toString() {
return "[" + getStatus() + "] " + this.description;
}
}
2 changes: 1 addition & 1 deletion text-ui-test/runtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ then
fi

# compile the code into the bin folder, terminates if error occurred
if ! javac -cp ../src/main/java -Xlint:none -d ../bin ../src/main/java/*.java
if ! javac -cp ../src/main/java -Xlint:none -d ../bin ../src/main/java/Duke.java

Choose a reason for hiding this comment

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

I like how you changed the accessibility where it is more specific 😄

then
echo "********** BUILD FAILURE **********"
exit 1
Expand Down