-
Notifications
You must be signed in to change notification settings - Fork 193
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
[Varun] iP #198
base: master
Are you sure you want to change the base?
[Varun] iP #198
Conversation
Add support for tracking todos, deadlines and events
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.
Excellent work! After some modifications, it'll become even more readable and clear :)
src/main/java/Event.java
Outdated
@@ -0,0 +1,14 @@ | |||
public class Event extends Task{ | |||
private static String SYMBOL = "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.
Could the name be more descriptive?
src/main/java/Duke.java
Outdated
while (true) { | ||
String command = input.nextLine(); | ||
|
||
// parse and handle commands |
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.
Do you think you can put this logic in a different method?
src/main/java/Duke.java
Outdated
String eventTime = parsedInput[1].strip(); | ||
TaskManager.addEvent(eventTitle, eventTime); | ||
} else { | ||
// handle invalid command |
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.
This comment is helpful :)
src/main/java/TaskManager.java
Outdated
@@ -0,0 +1,47 @@ | |||
public class TaskManager { | |||
private static int taskNo = 0; | |||
final private static int maxTasks = 100; |
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.
Perhaps a more informative name would be maxTasksNo to keep in line with taskNo, or name those two constants such that they sound similar
src/main/java/TaskManager.java
Outdated
addTask(todo); | ||
} | ||
|
||
static void addDeadline(String deadlineName, String deadlineDue) { |
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.
Perhaps for the second parameter, you can use the same name as in Deadline.java (in this case it is dueDate), or a similar one in style with deadlineName
src/main/java/Duke.java
Outdated
String command = input.nextLine(); | ||
|
||
// parse and handle commands | ||
if (command.equals(EXIT_CMD)) { |
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 the use of constants here! Makes it clear and easy to change
src/main/java/Duke.java
Outdated
// handle invalid command | ||
System.out.println("Invalid command! Please enter a valid command"); | ||
} | ||
} |
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 you could try to refactor the code to avoid long methods( above 30 LOC)
src/main/java/TaskManager.java
Outdated
Event event = new Event(eventName, eventTime); | ||
addTask(event); | ||
} | ||
|
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.
good use of refactoring to split the subtasks creation into 3 functions
src/main/java/Todo.java
Outdated
@@ -0,0 +1,12 @@ | |||
public class Todo extends Task { | |||
private static String SYMBOL = "T"; |
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 dont think it is a constant name , just a variable name but im not sure
src/main/java/TaskManager.java
Outdated
for (int i = 0; i < taskNo; ++i) { | ||
Task task = tasks[i]; | ||
System.out.printf("%d. %s\n", i + 1, task); | ||
} |
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.
should stick to using printf or println not both as it is confusing
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 it is a good implementation. Basically whether certain variables are constants is vague as capitalized variable name implies a constant which should be set as a final variable
src/main/java/Duke.java
Outdated
public static String EXIT_CMD = "bye"; | ||
public static String LIST_CMD = "list"; | ||
public static String DONE_CMD = "done"; | ||
public static String TODO_CMD = "todo"; | ||
public static String DEADLINE_CMD = "deadline"; | ||
public static String EVENT_CMD = "event"; |
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.
Perhaps you should make these variables final variables as well. From the naming convention used I am assuming you intend for these to be constants, but I may be misunderstanding something.
src/main/java/Deadline.java
Outdated
@@ -0,0 +1,14 @@ | |||
public class Deadline extends Task{ | |||
private static String SYMBOL = "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.
Perhaps this should be a final variable as I presume the SYMBOL is supposed to be a fixed constant
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.
@arvejw is correct, as seen in the coding standards or code quality guidelines. The final
keyword is to indicate that the String SYMBOL
will never change. You can take a look at all constants and make sure they adhere to this.
src/main/java/Duke.java
Outdated
String command = input.nextLine(); | ||
|
||
// parse and handle commands | ||
if (command.equals(EXIT_CMD)) { |
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.
As pointed out by others, very nice intuitive way of managing the various commands as the reader easily understands what command each code block carries out
src/main/java/Duke.java
Outdated
String parsedInput = command.split(" ")[1]; | ||
int taskNo = Integer.parseInt(parsedInput); | ||
TaskManager.markTaskNoAsDone(taskNo - 1); |
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.
Perhaps you might consider extracting out the execution of the commands into their own separate method
src/main/java/Event.java
Outdated
@@ -0,0 +1,14 @@ | |||
public class Event extends Task{ | |||
private static String SYMBOL = "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.
Similar to previous comments about constants, you can consider making this a final variable as its value should not be changing
src/main/java/Duke.java
Outdated
String eventTime = parsedInput[1].strip(); | ||
TaskManager.addEvent(eventTitle, eventTime); | ||
} else { | ||
// handle invalid command |
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.
good indentation of comment
src/main/java/Duke.java
Outdated
public class Duke { | ||
public static String EXIT_CMD = "bye"; |
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.
Good use of constants.
src/main/java/Duke.java
Outdated
String deadlineDue = parsedInput[1].strip(); | ||
TaskManager.addDeadline(deadlineTitle, deadlineDue); | ||
} else if (command.startsWith(EVENT_CMD)) { | ||
String [] parsedInput = command.replaceFirst(EVENT_CMD, "").split("/at "); |
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.
Plural form should be used on names representing a collection of objects.
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.
@yzhedwin is correct, following coding standards.
src/main/java/TaskManager.java
Outdated
if (taskNo < maxTasks) { | ||
tasks[taskNo] = task; | ||
taskNo++; | ||
|
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 think don't really need a new line
src/main/java/Duke.java
Outdated
} else if (command.startsWith(DONE_CMD)) { | ||
String parsedInput = command.split(" ")[1]; | ||
int taskNo = Integer.parseInt(parsedInput); | ||
TaskManager.markTaskNoAsDone(taskNo - 1); |
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.
Variable could be better named for less ambiguity. Overall good adherence to coding standard!
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.
Do complete the week's tasks as soon as possible. 👍
src/main/java/Deadline.java
Outdated
@@ -0,0 +1,14 @@ | |||
public class Deadline extends Task{ | |||
private static String SYMBOL = "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.
@arvejw is correct, as seen in the coding standards or code quality guidelines. The final
keyword is to indicate that the String SYMBOL
will never change. You can take a look at all constants and make sure they adhere to this.
src/main/java/Deadline.java
Outdated
@@ -0,0 +1,14 @@ | |||
public class Deadline extends Task{ |
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.
Perhaps there should be a space before the bracket? Similar for other classes.
public class Deadline extends Task{ | |
public class Deadline extends Task { |
src/main/java/AddTaskException.java
Outdated
@@ -0,0 +1,2 @@ | |||
public class AddTaskException extends DukeException{ |
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.
public class AddTaskException extends DukeException{ | |
public class AddTaskException extends DukeException { |
src/main/java/Duke.java
Outdated
public static String EXIT_CMD = "bye"; | ||
public static String LIST_CMD = "list"; | ||
public static String DONE_CMD = "done"; | ||
public static String TODO_CMD = "todo"; | ||
public static String DEADLINE_CMD = "deadline"; | ||
public static String EVENT_CMD = "event"; |
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.
Perhaps these commands being grouped together could have a common prefix? Following coding standards:
Associated constants should have a common prefix.
public static String EXIT_CMD = "bye"; | |
public static String LIST_CMD = "list"; | |
public static String DONE_CMD = "done"; | |
public static String TODO_CMD = "todo"; | |
public static String DEADLINE_CMD = "deadline"; | |
public static String EVENT_CMD = "event"; | |
public static final String CMD_EXIT = "bye"; | |
public static final String CMD_LIST = "list"; | |
public static final String CMD_DONE = "done"; | |
public static final String CMD_TODO = "todo"; | |
public static final String CMD_DEADLINE = "deadline"; | |
public static final String CMD_EVENT = "event"; |
src/main/java/DeadlineException.java
Outdated
@@ -0,0 +1,2 @@ | |||
public class DeadlineException extends DukeException{ |
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.
public class DeadlineException extends DukeException{ | |
public class DeadlineException extends DukeException { |
src/main/java/TaskManager.java
Outdated
public class TaskManager { | ||
private static int taskNo = 0; | ||
final private static int maxTasks = 100; | ||
final static Task[] tasks = new Task[maxTasks]; |
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.
Perhaps this should be private
, following the encapsulation paradigm of OOP?
final static Task[] tasks = new Task[maxTasks]; | |
private static final Task[] tasks = new Task[MAX_TASKS]; |
src/main/java/TaskManager.java
Outdated
final private static int maxTasks = 100; | ||
final static Task[] tasks = new Task[maxTasks]; | ||
|
||
static void addTask(Task task) { |
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 updating the modifiers for the methods in this class. The default scope of methods in Java is package-private. Having them be static
may not be advantageous as well, which you may learn later on.
src/main/java/TaskManager.java
Outdated
System.out.println("Here are the tasks in your list:"); | ||
for (int i = 0; i < taskNo; ++i) { | ||
Task task = tasks[i]; | ||
System.out.printf("%d. %s\n", i + 1, task); |
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.
This is not too big a deal (printf
vs println
), though you can consider simply sticking to print
(not printf
) as Java has its own handy toString
methods that can convert Integer
for you. I believe printf
may be a habit from C.
System.out.printf("%d. %s\n", i + 1, task); | |
System.out.println((i + 1) + ". " + task); |
src/main/java/TodoException.java
Outdated
@@ -0,0 +1,2 @@ | |||
public class TodoException extends DukeException{ |
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.
public class TodoException extends DukeException{ | |
public class TodoException extends DukeException { |
src/main/java/TaskManager.java
Outdated
final static Task[] tasks = new Task[maxTasks]; | ||
|
||
static void addTask(Task task) { | ||
if (taskNo < maxTasks) { |
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 can consider making the happy path prominent here.
# Conflicts: # src/main/java/duke/TaskManager.java
Add message parameter for InvalidCommand to throw DukeException with specified error message
Add LocalDate to Deadline and Event
# Conflicts: # src/main/java/duke/Parser.java
Add Find command
# Conflicts: # src/main/java/duke/task/Task.java
Update JavaDoc
No description provided.