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

[Yingchao Dai] iP #102

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

Conversation

baggiiiie
Copy link

No description provided.

Copy link

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

continue;
} else if (inputStringSplit[0].equalsIgnoreCase("done")){
try{
int tempindex = Integer.parseInt(inputStringSplit[1]);

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

public class Duke {
public static String inputString;
public static int listindex = 0;

Choose a reason for hiding this comment

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

camelCase here too!

}while(!inputString.equalsIgnoreCase("bye"));
}

public static void AddIntoList(){

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

public class Duke {
public static String inputString;
public static int listindex = 0;
public static String list[] = new String[100];

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

Copy link

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

greetings();
StartingMenu();
goodbye();
}

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!

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];

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

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]);
}

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

do {
Scanner userinput = new Scanner(System.in);
inputString = userinput.useDelimiter("\\A").nextLine();

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

Copy link

@BlubberMonster BlubberMonster left a 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.

}
System.out.println(inputString);
System.out.println("____________________________________________________________");
}while(!inputString.equalsIgnoreCase("bye"));

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"?




public static void greetings(){

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.

}
}

public static void MarkAsDone(String donetask){

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 ?

PrintList(0, listindex);
}
}

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.

// listindex += 1;
//}
//
public static void PrintList(int startIndex, int endIndex) {

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.

Copy link

@rabhijit rabhijit left a 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.

import java.util.List;
import java.util.Scanner;
import java.util.ArrayList;
import java.io.*;

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

import java.io.*;

public class Duke {
private static String LINE = "____________________________________________________________";

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)

}
}

private static void readFile(List<Task> lists){

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!

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());

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)

if (isDone.equals("true")) {
taskInFile.markAsDone();
}
} else {

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

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.

5 participants