[Bryan] iP - #89
[Bryan] iP#89Bryan-BC wants to merge 15 commits into
Conversation
| ind = Integer.parseInt(commands[1]) - 1; | ||
| printMark(ind); | ||
| } else if (commands[0].equals("unmark")) { | ||
| ind = Integer.parseInt(commands[1]) - 1; |
There was a problem hiding this comment.
Perhaps a more descriptive variable name would be better instead of 'ind'?
| } | ||
|
|
||
| public static void printList() { | ||
| System.out.println("Hemre are the tasks im your list:"); |
There was a problem hiding this comment.
Was initially confused if you made a typo; realized it was the bot's personality! Nice!
| public static void printList() { | ||
| System.out.println("Hemre are the tasks im your list:"); | ||
| for (int i = 0; i < index; i++) { | ||
| String number = String.valueOf(i + 1) + ". "; |
There was a problem hiding this comment.
I think 'number' could be better named to describe the numbering of the list items!
| @@ -1,10 +1,85 @@ | |||
| import java.util.Scanner; | |||
|
|
|||
| public class Duke { | |||
There was a problem hiding this comment.
Perhaps you can consider adding some comments to describe each method? The format can be found here under 'Comments': https://se-education.org/guides/conventions/java/basic.html
| String command = in.nextLine(); | ||
| String[] commands = command.split(" "); | ||
| System.out.println(separator); | ||
| do { |
There was a problem hiding this comment.
Good bracing positioning! You may consider using a switch-case if you like!
| command = in.nextLine(); | ||
| commands = command.split(" "); | ||
| System.out.println(separator); | ||
| } while (!command.equals("bye")); |
There was a problem hiding this comment.
Maybe consider taking the string literals and turning them in Magic constants or enums?
|
|
||
| public class Duke { | ||
| private static int index = 0; | ||
| private static String separator = "-------------------------------------------"; |
There was a problem hiding this comment.
Separator here acts like a magic constant. Maybe consider declaring it final and making it capitalized?
| } | ||
|
|
||
| public static void farewell() { | ||
| String farewell = "Goodbye. See you next time frem!\n" + "-------------------------------------------"; |
There was a problem hiding this comment.
You can probably use the separator variable here.
| private static final String SEPARATOR = "-------------------------------------------"; | ||
| private static int numberOfTasks = 0; | ||
| private static Task[] tasks = new Task[100]; | ||
| private static Scanner in = new Scanner(System.in); |
There was a problem hiding this comment.
Maybe you could use a more descriptive name for the object. Maybe "inScanner" ?
| } catch (NumberFormatException e) { | ||
| System.out.println("Error! Please input a number"); | ||
| } finally{ | ||
| System.out.println(SEPARATOR); |
There was a problem hiding this comment.
Different errors are handled well here.
| */ | ||
| public static void handleUnmark(String command) { | ||
| try{ | ||
| int taskPosition = Integer.parseInt(command.substring(7)) - 1; |
There was a problem hiding this comment.
Maybe you could avoid the usage of the magic number, like the 7 here.
| System.out.println(SEPARATOR); | ||
| do { | ||
| try{ | ||
| if (command.startsWith("list")) { |
There was a problem hiding this comment.
Maybe you could store these starting Strings as String variables.
| * Creates a new ToDo and prints the new ToDo. | ||
| * | ||
| * @param command The command given from input | ||
| */ |
Add increment Level-6
No description provided.