Conversation
tashawan23
left a comment
There was a problem hiding this comment.
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.
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.
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.
Would it be better to have this line format as a constant since it is repeated several times in the class?
| } | ||
|
|
||
| public ArrayList<String> readFile() throws FileNotFoundException { | ||
| try { |
There was a problem hiding this comment.
I like your indentations in this class!
pyuxiang
left a comment
There was a problem hiding this comment.
A couple of code standard comments, but otherwise adheres to standards pretty nicely!
| } | ||
| } | ||
|
|
||
| public void writeTaskToFile(List<Task> tasks){ |
There was a problem hiding this comment.
Be careful of the spaces 😉
| public void writeTaskToFile(List<Task> tasks){ | |
| public void writeTaskToFile(List<Task> tasks){ |
|
|
||
| String name; | ||
|
|
||
|
|
There was a problem hiding this comment.
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.
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.
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.
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.
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.
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.
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.
Consider adding a couple of class-level comments describing the class.
Might not be immediately clear otherwise what this Database class is intended for.
| @@ -0,0 +1,47 @@ | |||
| import java.io.File; | |||
There was a problem hiding this comment.
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