-
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
[CHEN ZIHAN] ip #198
base: master
Are you sure you want to change the base?
[CHEN ZIHAN] ip #198
Changes from 4 commits
1f84246
a1b47d9
150d2b1
9fb9073
1948f11
20513b3
2f37e5d
aad1876
52c2484
2531402
46b06d9
bc3b345
feac7eb
96306a3
31edec0
3d14bd2
5673757
cd4ec76
07841ce
3bce789
18ced02
a8b8903
8260134
c6c4e31
c44b7a0
da48b0a
31518e0
144ebda
aca6055
3d4ec2e
91ab442
2ca723e
9717c16
330455f
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 | ||||
---|---|---|---|---|---|---|
@@ -1,10 +1,56 @@ | ||||||
import java.util.Scanner; | ||||||
|
||||||
public class Duke { | ||||||
|
||||||
public static final int MAX_INT = 100; | ||||||
|
||||||
public static void greeting() { | ||||||
System.out.println(" Hello! I'm Duke"); | ||||||
System.out.println(" What can I do for you?"); | ||||||
|
||||||
} | ||||||
|
||||||
|
||||||
|
||||||
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. remove the unnecessary blank spaces, follow one uniform spacing |
||||||
public static void add() { | ||||||
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. Coding Standard violation: Ambiguity of function. Can change the name of the function to explain more. e.g. addTodo() |
||||||
boolean isByeEntered = true; | ||||||
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. Could |
||||||
String outputs; | ||||||
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. Coding Standard Violation: Plural form is reserved for collections of objects.
Suggested change
|
||||||
String[] storeList; | ||||||
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. Coding Standard Violation: Array should be plural
Suggested change
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 like how your array specifier is attached to the type and not the variable 👍 nice |
||||||
storeList = new String[MAX_INT]; | ||||||
int i = 0; | ||||||
int a = 1; | ||||||
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 wasn't sure on what |
||||||
|
||||||
while (isByeEntered) { | ||||||
Scanner scan = new Scanner(System.in); | ||||||
outputs = scan.nextLine(); | ||||||
if (outputs.equals("bye")) { | ||||||
System.out.println("Bye. Hope to see you again soon!"); | ||||||
return; | ||||||
} else if(outputs.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. Coding Standard Violation: Give space before and after statement
Suggested change
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. same goes for line 30, 35 |
||||||
for(String list : storeList){ | ||||||
if(list!=null) { | ||||||
System.out.println(a + ". " + list); | ||||||
a++; | ||||||
}else{ | ||||||
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. Spacing is sometimes inconsistent (maybe by accident?). Here, |
||||||
break; | ||||||
} | ||||||
} | ||||||
|
||||||
} else { | ||||||
System.out.println("added: " + outputs); | ||||||
storeList[i] = outputs; | ||||||
i++; | ||||||
} | ||||||
} | ||||||
} | ||||||
|
||||||
|
||||||
public static void main(String[] args) { | ||||||
String logo = " ____ _ \n" | ||||||
+ "| _ \\ _ _| | _____ \n" | ||||||
+ "| | | | | | | |/ / _ \\\n" | ||||||
+ "| |_| | |_| | < __/\n" | ||||||
+ "|____/ \\__,_|_|\\_\\___|\n"; | ||||||
System.out.println("Hello from\n" + logo); | ||||||
|
||||||
greeting(); | ||||||
add(); | ||||||
|
||||||
|
||||||
|
||||||
} | ||||||
} |
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.
Nice! I like your usage of constants (instead of magic numbers) and I like how they are typed (all uppercase, underscore to separate words).