-
Notifications
You must be signed in to change notification settings - Fork 103
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
[Yingchao Dai] iP #102
base: master
Are you sure you want to change the base?
[Yingchao Dai] iP #102
Conversation
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 goodjob! Just some small code standard violations!
src/main/java/Duke.java
Outdated
continue; | ||
} else if (inputStringSplit[0].equalsIgnoreCase("done")){ | ||
try{ | ||
int tempindex = Integer.parseInt(inputStringSplit[1]); |
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.
Although its a small variable, names should be in camelCase
src/main/java/Duke.java
Outdated
public class Duke { | ||
public static String inputString; | ||
public static int listindex = 0; |
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.
camelCase here too!
src/main/java/Duke.java
Outdated
}while(!inputString.equalsIgnoreCase("bye")); | ||
} | ||
|
||
public static void AddIntoList(){ |
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.
Methods should be written in camelCase as well
src/main/java/Duke.java
Outdated
public class Duke { | ||
public static String inputString; | ||
public static int listindex = 0; | ||
public static String list[] = new String[100]; |
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.
Collection of tasks should be in plural form i.e lists
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 good job, some small detail can be improved!
src/main/java/Duke.java
Outdated
greetings(); | ||
StartingMenu(); | ||
goodbye(); | ||
} |
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.
Can leave one line space between two boxes of codes!
src/main/java/Duke.java
Outdated
public static int listindex = 0; | ||
public static String list[][] = new String[100][5]; | ||
//public static String isDone[] = new String[100]; | ||
//public static String tasktype[] = new String[100]; |
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.
Can delete the useless comments code
src/main/java/Duke.java
Outdated
public static void PrintList(int startIndex, int endIndex) { | ||
for (int i = startIndex; i < endIndex; i++) { | ||
System.out.println(i + 1 + ": [" + list[i][0] + "][" + list[i][1] + "]:" + " " + list[i][2] +list[i][3]); | ||
} |
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.
can change i to some words meaningful
src/main/java/Duke.java
Outdated
do { | ||
Scanner userinput = new Scanner(System.in); | ||
inputString = userinput.useDelimiter("\\A").nextLine(); | ||
|
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.
Can delete this empty line
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.
Generally, your code had clear and easy to read. I liked that you used meaningful words to name your variables and methods. I noted a few issues pertaining to code quality and coding standards. You can also consider splitting into smaller classes if possible.
src/main/java/Duke.java
Outdated
} | ||
System.out.println(inputString); | ||
System.out.println("____________________________________________________________"); | ||
}while(!inputString.equalsIgnoreCase("bye")); |
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.
Perhaps you can insert a space between the '}' and "while"?
src/main/java/Duke.java
Outdated
|
||
|
||
|
||
public static void greetings(){ |
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 like that you modularize your program. It definitely increases the readability.
src/main/java/Duke.java
Outdated
} | ||
} | ||
|
||
public static void MarkAsDone(String donetask){ |
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.
Perhaps you might consider putting this method in another class ?
src/main/java/Duke.java
Outdated
PrintList(0, listindex); | ||
} | ||
} | ||
|
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.
You can consider deleting the lines here.
src/main/java/Duke.java
Outdated
// listindex += 1; | ||
//} | ||
// | ||
public static void PrintList(int startIndex, int endIndex) { |
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 like how you used meaningful words to name your parameters.
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, good work! In terms of code readability, I think you could improve on simplifying/breaking down overly long methods, reducing long lines of code and reducing deep if-else nesting. But otherwise, your code is organised and readable. Consider including comments to explain what your code is doing as well.
src/main/java/Duke/Duke.java
Outdated
import java.util.List; | ||
import java.util.Scanner; | ||
import java.util.ArrayList; | ||
import java.io.*; |
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.
It's best to avoid wildcard imports, as seen here
src/main/java/Duke/Duke.java
Outdated
import java.io.*; | ||
|
||
public class Duke { | ||
private static String LINE = "____________________________________________________________"; |
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.
Reserve uppercase variable names for constants (i.e. static final variables)
src/main/java/Duke/Duke.java
Outdated
} | ||
} | ||
|
||
private static void readFile(List<Task> lists){ |
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.
Perhaps you could restructure your functions to avoid deep if-else nesting, to increase its readability and make debugging easier for yourself!
src/main/java/Duke/Duke.java
Outdated
if (taskInList instanceof ToDoTask) { | ||
writer.write(taskInList.getTaskType() + "|" + taskInList.isDone() + "|" + taskInList.getTask().trim()); | ||
} else { | ||
writer.write(taskInList.getTaskType() + "|" + taskInList.isDone() + "|" + taskInList.getTask().trim() + "|" + taskInList.getTaskTime().trim()); |
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.
If your code lines are getting overly long, it's best to break it down into multiple lines (e.g. you could save your variables before writing them)
src/main/java/Duke/Duke.java
Outdated
if (isDone.equals("true")) { | ||
taskInFile.markAsDone(); | ||
} | ||
} 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.
Try and explicitly state all what all your if and else-if conditions, and leave the 'else' statement for error handling mainly
* 'master' of https://github.com/baggiiiie/ip: Update README.md Update README.md Update README.md Update README.md Update README.md Update README.md Update README.md Update README.md Update README.md Update README.md Update README.md Update README.md Update README.md Update README.md Update README.md Update README.md Update README.md Update README.md Update README.md # Conflicts: # README.md
No description provided.