-
Notifications
You must be signed in to change notification settings - Fork 200
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
[Sebastian Soewanto] iP #205
base: master
Are you sure you want to change the base?
Changes from 1 commit
12a4d6f
3c57457
a96a8be
57d0c6a
bd71f69
7473a4c
fa25e2d
3230034
bb5533e
6fa95ff
ca05154
b07c63e
f44576f
e5fb6f9
47689bc
805e73b
97208ba
a839b28
ca10bdd
62dee31
98a859b
eed248b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,21 +8,39 @@ public static void main(String[] args) { | |
+ "| |_| | |_| | < __/\n" | ||
+ "|____/ \\__,_|_|\\_\\___|\n"; | ||
|
||
String line = "_________________________________\n"; | ||
String line = "____________________________________________________\n"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Naming can be changed to avoid confusion down the code block, could change to -> e.g. 'static final String margin' (since its a repeating string pattern to be printed out) |
||
System.out.println("Hello from\n" + logo); | ||
System.out.print(line + "Hello! I'm Duke\n" + "What can I do for you?\n" + line); | ||
String[] list = new String[100]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you use this list to store the different tasks, so maybe it's better to name it as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Naming of ' String[ ] list ' is quite vague, maybe if possible to provide a more useful name for readability? e.g. ' String [ ] taskList ' |
||
boolean[] isDone = new boolean[100]; | ||
String toFill; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think naming it |
||
int listCount = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe something like |
||
while(true) { | ||
Scanner userInput = new Scanner(System.in); | ||
String input = userInput.nextLine(); | ||
if (input.equals("bye")) { | ||
System.out.print(line + "Bye. Hope to see you again soon!\n" + line); | ||
break; | ||
} else if(input.equals("list")) { | ||
} else if (input.startsWith("mark")) { | ||
int mark = Integer.parseInt(input.substring(5)); | ||
isDone[mark - 1] = true; | ||
System.out.println(line + "Nice! I've marked this task as done:\n" + " [X] " + list[mark - 1]); | ||
System.out.print(line); | ||
} else if (input.startsWith("unmark")) { | ||
int unmark = Integer.parseInt(input.substring(7)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The naming of ' unmark' is a bit confusing, maybe switch to ' taskToUnmark '? |
||
isDone[unmark - 1] = false; | ||
System.out.println(line + "OK, I've marked this task as not done yet:\n" + " [ ] "+ list[unmark - 1]); | ||
System.out.print(line); | ||
} else if(input.equals("list")) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good indentation and presenting the conditional statements, which helps the code's readability. |
||
System.out.print(line + "Here are the tasks in your list:\n"); | ||
for (int i = 0; i < listCount; i++) { | ||
System.out.println(i + 1 + ". " + list[i]); | ||
if (isDone[i]) { | ||
toFill = "X"; | ||
} | ||
else { | ||
toFill = " "; | ||
} | ||
System.out.println(i + 1 + ". [" + toFill + "] " + list[i]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extracting i+1 to another line as |
||
} | ||
System.out.print(line); | ||
} else { | ||
|
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.
Seems like it is a constant, so maybe consider using
static final LINE_DIVIDER
(or some other similar name)?