-
Notifications
You must be signed in to change notification settings - Fork 361
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
[Fahim Tajwar] iP #377
base: master
Are you sure you want to change the base?
[Fahim Tajwar] iP #377
Conversation
…sted switch-case.
…, badly formatted deadlines, badly formatted events.
…xceptions to come.
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.
Good work here, some suggestions for your code:
- Wildcard imports shouldn't be used, this might've resulted from the default settings in Intellij that auto converts imports into wildcard imports (try disabling it)
- You might want to implement an
symbol
attribute to each type of task, rather than hardcoding it into thetoString()
method. This would also help for the storage requirement, if you want to use the task symbols in the storage format :) - A
reply(String reply)
method in your Duke class can solve the tediousness of having to print the divider line for each output by the chatbot - Each case for a switch statement should be on the same indent line as the
switch():
statement itself, there's also a setting in Intellij that disables that
Nice job though, I found your code easy to read and understand :)
Add error message for badly formatted dates.
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.
Overall, the code seems okay. However, you may want to consider some of Java's coding standards in regards to layout and comments.
src/main/java/Duke.java
Outdated
ArrayList<Task> tasks = new ArrayList<>(); | ||
Scanner sc = new Scanner(System.in); | ||
|
||
while(sc.hasNext()) { |
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.
I noticed several Java reserved words such as while
in this case not being followed by a white space. e.g.
while(sc.hasNext()) { | |
while (sc.hasNext()) { |
Perhaps you could consider using IntelliJ's code cleanup feature to add these white spaces automatically.
src/main/java/Duke.java
Outdated
while(sc.hasNext()) { | ||
String instr = sc.nextLine(); | ||
switch(instr) { //Single-word instructions | ||
case "list": //List down |
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.
Should indentation for case
clauses be removed?
case "list": //List down | |
case "list": |
src/main/java/Duke.java
Outdated
+ "| |_| | |_| | < __/\n" | ||
+ "|____/ \\__,_|_|\\_\\___|\n"; | ||
System.out.println("Hello from\n" + logo); | ||
public static void main(String[] args) { |
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.
Should basic indentation be changed from 2 spaces to 4 spaces to align with the Java coding standard?
public static void main(String[] args) { | |
public static void main(String[] args) { |
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.
Good start so far. Consider abstracting away with more functions as the code expands with future levels.
src/main/java/Duke.java
Outdated
ArrayList<Task> tasks = new ArrayList<>(); | ||
Scanner sc = new Scanner(System.in); | ||
|
||
while(sc.hasNext()) { |
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.
Be careful of using sc.hasNext()
vs sc.hasNextLine()
src/main/java/Duke.java
Outdated
System.out.println(divider + "OOPS!!! The description of a " + action + " cannot be empty.\n" + divider); | ||
} | ||
|
||
switch(action) { //For instructions with argument(s). |
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.
Would recommend against nesting switch-case
block for code quality
src/main/java/Duke.java
Outdated
} | ||
} |
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.
A lot of nested blocks. Consider abstracting away with methods within the main class. For example you can have:
// in main
switch(...) {
case "todo":
addToDo(tokens);
}
// add implementation
public void addToDo(String[] tokens) {
// your implementation
}
Add separate UI, Parser, TaskList classes. Add NoArgumentException to handle empty argument cases.
P.S. Checkstyle violations fixed in previous commits.
Long lists are no longer cut short with "...".
Remove redundant exception class. Remove dead code.
DukePro
DukePro frees your mind off remembering tasks. It's
FASTSUPER FAST to useAnd it's free!
All you need to do is:
todo
,deadline
andevent
.mark
andunmark
.delete
.find
!Features: