Skip to content
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

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open

Conversation

maikongeh
Copy link

pull request for week 3

damithc and others added 8 commits July 23, 2020 23:27
test
Greet, Echo, Exit
add, list
Mark as done, todo, event deadline inherits tasks.
delete, error handling and running test cases
Add save function
Copy link

@tashawan23 tashawan23 left a 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. :)

System.out.println("____________________________________");

Scanner input = new Scanner(System.in);
while(input.hasNextLine()) {

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

for(String str: strings) {
char identifier = str.charAt(1);
switch(identifier) {
case 'D':

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

catch (FileNotFoundException e){
throw new FileNotFoundException("No File Detected");
}
System.out.println("____________________________________");

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?

}

public ArrayList<String> readFile() throws FileNotFoundException {
try {

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!

Copy link

@pyuxiang pyuxiang left a 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!

}
}

public void writeTaskToFile(List<Task> tasks){
Copy link

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 😉

Suggested change
public void writeTaskToFile(List<Task> tasks){
public void writeTaskToFile(List<Task> tasks){


String name;


Copy link

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

Suggested change

Database database = new Database( "data.txt");
ArrayList<String> listOfTasks;
ArrayList<Task> myList;
try {
Copy link

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.

Suggested change
try {
try {

Comment on lines 14 to 15
}
catch (FileNotFoundException e){
Copy link

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.

Suggested change
}
catch (FileNotFoundException e){
} catch (FileNotFoundException e){

System.out.println("____________________________________");

Scanner input = new Scanner(System.in);
while(input.hasNextLine()) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another space missed 😉

Suggested change
while(input.hasNextLine()) {
while (input.hasNextLine()) {

case "todo":
System.out.println("____________________________________");
try {
String s1 = input.nextLine();
Copy link

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.

database.writeTaskToFile(myList);

}
} catch(DukeException e) {
Copy link

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.

case "list":
System.out.println("____________________________________");
System.out.println("Here are the tasks in your list:");
for(int i=1; i< myList.size()+1; i++){
Copy link

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:

Suggested change
for(int i=1; i< myList.size()+1; i++){
for (int i = 1; i < myList.size() + 1; i++) {

import java.util.List;
import java.util.Scanner;

public class Database {
Copy link

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.

@@ -0,0 +1,47 @@
import java.io.File;
Copy link

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 🎉

Implement date function using LocalDate package
implement database - same functionality as storage,
parser to handle different switch cases, Ui to handle ouput for different commands and error handling.
package files in duke
Introduce JavaDocs to my class and methods
Adhere to coding standards
Implemented find
Implemented gradle support
implement GUI
implement Assertions
Create User guide in ReadMe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants