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

[Cheng Tze Ning] iP #67

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Changes from 3 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
be01343
Change duke to greet
tzzzening Jan 21, 2020
fbf3a39
Add String "Duke"
tzzzening Jan 30, 2020
1c27416
Add checked items on list
tzzzening Jan 31, 2020
a33dfcd
Add Level 4 increment
tzzzening Feb 3, 2020
a542137
Touch up Level 4 increment
tzzzening Feb 6, 2020
26b35eb
Neaten "if else" conditions
tzzzening Feb 6, 2020
dad0e8a
Change conditional statements to "startsWith" string method
tzzzening Feb 9, 2020
da534c2
Throw exceptions
tzzzening Feb 11, 2020
cdaf1d1
Add idk what
tzzzening Feb 13, 2020
016a60c
Attempt to add TextUiTesting but failed
tzzzening Feb 13, 2020
8e898b3
Change "Duke" logo to "Hi"
tzzzening Feb 13, 2020
a2017c2
Add "OIOIOIO"
tzzzening Feb 13, 2020
10bc426
Merge branch 'master' into feature1
tzzzening Feb 13, 2020
2c7f344
Add list of commands to greeting
tzzzening Feb 13, 2020
447777d
Edit last statement
tzzzening Feb 13, 2020
3f2a978
Merge branch 'feature1'
tzzzening Feb 13, 2020
8607dbf
Add "Singapore"
tzzzening Feb 13, 2020
35a5861
Add "Jurong"
tzzzening Feb 13, 2020
feb2568
Delete "Jurong"
tzzzening Feb 13, 2020
6e43fcd
Merge branch 'delete-jurong'
tzzzening Feb 13, 2020
eaa4979
Chang back to Duke
tzzzening Feb 18, 2020
38b7914
Merge branch 'delete-jurong'
tzzzening Feb 18, 2020
b602d58
Attempt at adding level 6 increment (but it fails on me)
tzzzening Feb 24, 2020
2685652
Add incomplete Level 6 increment
tzzzening Feb 29, 2020
a29ddcf
Add Level 7 increment through PrintWriter
tzzzening Feb 29, 2020
6ec227d
Merge tag 'branch-Level-6'
tzzzening Feb 29, 2020
8b2763b
Merge tag 'branch-Level-7'
tzzzening Feb 29, 2020
88e44fa
Add Code Quality increment
tzzzening Mar 1, 2020
4d4a195
Add More OOP increment
tzzzening Mar 1, 2020
60122da
Add Level 9 increment with a minor bug
tzzzening Mar 2, 2020
bc2cba1
Add JavaDocs
tzzzening Mar 2, 2020
f8a42ff
Merge pull request #2 from chengTzeNing/branch-Level-9
tzzzening Mar 2, 2020
4aeaf4f
Merge branch 'master' of https://github.com/chengTzeNing/duke
tzzzening Mar 2, 2020
b25c605
Merge tag 'JavaDocs'
tzzzening Mar 2, 2020
5dcc300
Fix minor bug
tzzzening Mar 2, 2020
d656f7b
Fix spelling error and created a JAR file?
tzzzening Mar 2, 2020
f7fad9f
Fix bugs
tzzzening Mar 2, 2020
1da6df9
Add README file for User Guide correctly
tzzzening Mar 2, 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
32 changes: 31 additions & 1 deletion src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,40 @@
import java.util.Scanner;
import java.util.ArrayList;

public class Duke {
static ArrayList<Task> list = new ArrayList<Task>();

public static void printTasks() {
System.out.println("Here are the tasks in your list:");
for (Task task : list) {
System.out.println(String.format("%d. [%c] %s", task.getTaskId(),
task.isDone() ? '✓' : '✗', task.getTaskName()));
}
}

public static void main(String[] args) {
String logo = " ____ _ \n"
String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
System.out.println("Hello! I'm Duke\nWhat can I do for you?");
Scanner scan = new Scanner(System.in);
String userInput = scan.nextLine();
while (!userInput.equals("bye")) {
if (userInput.equals("list")) {
printTasks();
} else if (userInput.length() > 4 && userInput.substring(0, 5).equals("done ")) {
Copy link

Choose a reason for hiding this comment

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

Consider simplifying the conditional statement using startsWith. It is applicable to the rest of the conditions below.
Ex. else if(userInput.startsWith("done")

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for your suggestion. I find it very efficient 👍 Will add it to my code later on.

list.get(Integer.parseInt(Character.toString(
userInput.charAt(userInput.length() - 1))) - 1).setDone();
} else {
System.out.println("added: " + userInput);
Task task = new Task(userInput);
list.add(task);
}
userInput = scan.nextLine();
}
System.out.println("Bye. Hope to see you again soon!");
}
}