forked from se-edu/duke
-
Notifications
You must be signed in to change notification settings - Fork 73
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
tzzzening
wants to merge
38
commits into
nus-cs2113-AY1920S2:master
Choose a base branch
from
tzzzening:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
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 fbf3a39
Add String "Duke"
tzzzening 1c27416
Add checked items on list
tzzzening a33dfcd
Add Level 4 increment
tzzzening a542137
Touch up Level 4 increment
tzzzening 26b35eb
Neaten "if else" conditions
tzzzening dad0e8a
Change conditional statements to "startsWith" string method
tzzzening da534c2
Throw exceptions
tzzzening cdaf1d1
Add idk what
tzzzening 016a60c
Attempt to add TextUiTesting but failed
tzzzening 8e898b3
Change "Duke" logo to "Hi"
tzzzening a2017c2
Add "OIOIOIO"
tzzzening 10bc426
Merge branch 'master' into feature1
tzzzening 2c7f344
Add list of commands to greeting
tzzzening 447777d
Edit last statement
tzzzening 3f2a978
Merge branch 'feature1'
tzzzening 8607dbf
Add "Singapore"
tzzzening 35a5861
Add "Jurong"
tzzzening feb2568
Delete "Jurong"
tzzzening 6e43fcd
Merge branch 'delete-jurong'
tzzzening eaa4979
Chang back to Duke
tzzzening 38b7914
Merge branch 'delete-jurong'
tzzzening b602d58
Attempt at adding level 6 increment (but it fails on me)
tzzzening 2685652
Add incomplete Level 6 increment
tzzzening a29ddcf
Add Level 7 increment through PrintWriter
tzzzening 6ec227d
Merge tag 'branch-Level-6'
tzzzening 8b2763b
Merge tag 'branch-Level-7'
tzzzening 88e44fa
Add Code Quality increment
tzzzening 4d4a195
Add More OOP increment
tzzzening 60122da
Add Level 9 increment with a minor bug
tzzzening bc2cba1
Add JavaDocs
tzzzening f8a42ff
Merge pull request #2 from chengTzeNing/branch-Level-9
tzzzening 4aeaf4f
Merge branch 'master' of https://github.com/chengTzeNing/duke
tzzzening b25c605
Merge tag 'JavaDocs'
tzzzening 5dcc300
Fix minor bug
tzzzening d656f7b
Fix spelling error and created a JAR file?
tzzzening f7fad9f
Fix bugs
tzzzening 1da6df9
Add README file for User Guide correctly
tzzzening File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ")) { | ||
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!"); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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")
There was a problem hiding this comment.
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.