-
Notifications
You must be signed in to change notification settings - Fork 228
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
Michael Ong iP #235
base: master
Are you sure you want to change the base?
Michael Ong iP #235
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, I found your code quite easy to understand for the most part except for a few places where nesting was too deep. I have noted some repeated code and coding standard violations. :)
src/main/java/Duke.java
Outdated
System.out.println("____________________________________"); | ||
|
||
Scanner input = new Scanner(System.in); | ||
while(input.hasNextLine()) { |
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.
Maybe it would be better if you avoid deep nesting to improve code quality
src/main/java/Duke.java
Outdated
for(String str: strings) { | ||
char identifier = str.charAt(1); | ||
switch(identifier) { | ||
case 'D': |
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.
Maybe it would be better to leave out the indentation for case clauses
src/main/java/Duke.java
Outdated
catch (FileNotFoundException e){ | ||
throw new FileNotFoundException("No File Detected"); | ||
} | ||
System.out.println("____________________________________"); |
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 it be better to have this line format as a constant since it is repeated several times in the class?
src/main/java/Database.java
Outdated
} | ||
|
||
public ArrayList<String> readFile() throws FileNotFoundException { | ||
try { |
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 your indentations in this class!
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 couple of code standard comments, but otherwise adheres to standards pretty nicely!
src/main/java/Database.java
Outdated
} | ||
} | ||
|
||
public void writeTaskToFile(List<Task> tasks){ |
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 the spaces 😉
public void writeTaskToFile(List<Task> tasks){ | |
public void writeTaskToFile(List<Task> tasks){ |
src/main/java/Database.java
Outdated
|
||
String name; | ||
|
||
|
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 might have inadvertently added an extra blank line here:
https://se-education.org/guides/conventions/java/intermediate.html#layout
src/main/java/Duke.java
Outdated
Database database = new Database( "data.txt"); | ||
ArrayList<String> listOfTasks; | ||
ArrayList<Task> myList; | ||
try { |
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.
The indentation is a little off here: should be in line with the block.
try { | |
try { |
src/main/java/Duke.java
Outdated
} | ||
catch (FileNotFoundException e){ |
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.
The catch
keyword should be in line with the closing brace.
} | |
catch (FileNotFoundException e){ | |
} catch (FileNotFoundException e){ |
src/main/java/Duke.java
Outdated
System.out.println("____________________________________"); | ||
|
||
Scanner input = new Scanner(System.in); | ||
while(input.hasNextLine()) { |
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.
Another space missed 😉
while(input.hasNextLine()) { | |
while (input.hasNextLine()) { |
src/main/java/Duke.java
Outdated
case "todo": | ||
System.out.println("____________________________________"); | ||
try { | ||
String s1 = input.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.
You might have missed this: variable names could do with a more specific name, especially since the scope isn't small. Perhaps s1
can be renamed as userInputLine
.
src/main/java/Duke.java
Outdated
database.writeTaskToFile(myList); | ||
|
||
} | ||
} catch(DukeException e) { |
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.
Not a coding standard, but figured I could chip in. Since the catch
block is the same as that below in line 86, you can consider removing the try-except
block here.
src/main/java/Duke.java
Outdated
case "list": | ||
System.out.println("____________________________________"); | ||
System.out.println("Here are the tasks in your list:"); | ||
for(int i=1; i< myList.size()+1; i++){ |
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.
Note the spaces here as well:
for(int i=1; i< myList.size()+1; i++){ | |
for (int i = 1; i < myList.size() + 1; i++) { |
src/main/java/Database.java
Outdated
import java.util.List; | ||
import java.util.Scanner; | ||
|
||
public class Database { |
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 adding a couple of class-level comments describing the class.
Might not be immediately clear otherwise what this Database
class is intended for.
src/main/java/Database.java
Outdated
@@ -0,0 +1,47 @@ | |||
import java.io.File; |
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.
Your import
statements are very nicely formatted 🎉
package files in duke
Adhere to coding standards
implement Assertions
Create User guide in ReadMe
pull request for week 3