-
Notifications
You must be signed in to change notification settings - Fork 437
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
[Yuki Akizuki] iP #172
base: master
Are you sure you want to change the base?
[Yuki Akizuki] iP #172
Conversation
# Conflicts: # iP/out/production/iP/Duke.class # iP/src/Duke.java
# Conflicts: # iP/src/duke/Ui.java
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.
Very neat code! very easy to read
iP/src/duke/Deadline.java
Outdated
@@ -0,0 +1,32 @@ | |||
package duke; |
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 can consider having a empty new line to group your package/import statements
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 agree
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 second the suggestion made by @YangJiyu98
iP/src/duke/Duke.java
Outdated
|
||
} else { | ||
// invalid input | ||
if (!loading){ |
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 might have missed a whitespace here
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 agree
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 second that
iP/src/duke/Duke.java
Outdated
ui.showError(e.getMessage()); | ||
} | ||
|
||
} else if (instructionType.equals("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.
You might have missed a white space here
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 agree
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 second that
iP/src/duke/Duke.java
Outdated
/** | ||
* run todo app | ||
*/ |
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.
Not sure if this would be necessary as it is simple enough fro a reader to understand
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 your code is generally easy to read and follow, with inline comments to also improve readability which is good! :)
iP/src/duke/Duke.java
Outdated
@@ -1,6 +1,7 @@ | |||
package duke; |
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 can have a new empty line indentation after your package line before your import statements?
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 agree
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.
Repeated suggestion. I second this as well.
iP/src/duke/TaskList.java
Outdated
@@ -47,4 +47,14 @@ public Task getTask(int index) { | |||
Task task = taskList.get(index); | |||
return task; | |||
} | |||
|
|||
public ArrayList<Task> find(String keyword) { |
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 how you return your output as an ArrayList to be processed later instead of immediately returning a processed string since this could improve adaptability and extensibility of your program! 👍
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 agree
iP/src/duke/Ui.java
Outdated
|
||
public void showFoundTask(ArrayList<Task> foundTasks) { | ||
System.out.println("Here are the matching tasks in your list:"); | ||
int index = 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 it would be more readable if you had the for-loop in the form of:
for (int i = 1; i < foundTasks.size() + 1; i++) ?
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 that the current way is fine and I actually like it more
iP/src/duke/Duke.java
Outdated
@@ -1,6 +1,7 @@ | |||
package duke; |
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 agree
iP/src/duke/Deadline.java
Outdated
@@ -0,0 +1,32 @@ | |||
package duke; |
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 agree
iP/src/duke/Duke.java
Outdated
ui.showError(e.getMessage()); | ||
} | ||
|
||
} else if (instructionType.equals("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.
I agree
iP/src/duke/Duke.java
Outdated
|
||
} else { | ||
// invalid input | ||
if (!loading){ |
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 agree
iP/src/duke/Ui.java
Outdated
|
||
public void showFoundTask(ArrayList<Task> foundTasks) { | ||
System.out.println("Here are the matching tasks in your list:"); | ||
int index = 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.
I think that the current way is fine and I actually like it more
iP/src/duke/Duke.java
Outdated
tasks = new TaskList(); | ||
tasks = new TaskList(storage.load(this)); |
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 is a way of changing your code design so that you can initialise with just one line of code instead of calling the constructor twice?
iP/src/duke/Duke.java
Outdated
while (!isExit) { | ||
try { | ||
String fullCommand = ui.readCommand(); | ||
ui.showLine(); // show the divider line ("_______") |
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 can put your comment on top of the line of code instead of beside it?
Not really sure if this violates Java coding standard.
iP/src/duke/Duke.java
Outdated
// quit | ||
ui.showGoodBye(); | ||
System.exit(0); | ||
|
||
} else if (instructionType.equals("list")) { | ||
// list task | ||
ui.showListOfTask(tasks.taskList); | ||
|
||
} else if (instructionType.equals("done")) { | ||
// mark done | ||
// parse instruction | ||
int index = Parser.parseMarkDoneInstr(user_input); | ||
// execute | ||
Task chosenTask = tasks.getTask(index); | ||
chosenTask.markAsDone(); | ||
if (!loading){ | ||
ui.showMarkedDoneTask(chosenTask); | ||
} | ||
|
||
} else if (instructionType.equals("delete")) { | ||
// delete task | ||
// parse instruction | ||
int index = Parser.parseDeleteInstr(user_input); | ||
// execute | ||
Task chosenTask = tasks.getTask(index); | ||
tasks.deleteTask(index); | ||
if (!loading){ | ||
ui.showDeletedTask(chosenTask, tasks.taskList); | ||
} | ||
|
||
} else if (instructionType.equals("find")) { | ||
// find task | ||
// parse instruction | ||
String keyword = Parser.parseFindInstr(user_input); | ||
// execute | ||
ArrayList<Task> foundTasks = tasks.find(keyword); | ||
if (!loading){ | ||
ui.showFoundTask(foundTasks); | ||
} | ||
|
||
} else if (instructionType.equals("todo")) { | ||
// make todo | ||
try { | ||
// parse instruction | ||
String description = Parser.parseAddTodoInstr(user_input); | ||
// execute | ||
Task todo = new Todo(description); | ||
tasks.addTask(todo); | ||
if (!loading){ | ||
ui.showAddedTask(todo, tasks.taskList); | ||
} | ||
} catch (DukeException e) { | ||
ui.showError(e.getMessage()); | ||
} | ||
|
||
} else if (instructionType.equals("deadline")) { | ||
// make deadline | ||
try { | ||
// parse instruction | ||
HashMap<String, Object> parsedData = Parser.parseAddDeadlineInstr(user_input); | ||
String description = (String) parsedData.get("description"); | ||
LocalDate l_time = (LocalDate) parsedData.get("time"); | ||
// execute | ||
Task deadline = new Deadline(description, l_time); | ||
tasks.addTask(deadline); | ||
if (!loading) { | ||
ui.showAddedTask(deadline, tasks.taskList); | ||
} | ||
} catch (DukeException e) { | ||
ui.showError(e.getMessage()); | ||
} | ||
|
||
} else if (instructionType.equals("event")){ | ||
// make event | ||
try { | ||
// parse instruction | ||
HashMap<String, Object> parsedData = Parser.parseAddEventInstr(user_input); | ||
String description = (String) parsedData.get("description"); | ||
LocalDate l_time = (LocalDate) parsedData.get("time"); | ||
// execute | ||
Task event = new Event(description, l_time); | ||
tasks.addTask(event); | ||
if (!loading){ | ||
ui.showAddedTask(event, tasks.taskList); | ||
} | ||
} catch (DukeException e) { | ||
ui.showError(e.getMessage()); | ||
} | ||
|
||
} else { | ||
// invalid input | ||
if (!loading){ | ||
throw new DukeException("☹ OOPS!!! I'm sorry, but I don't know what that means :-("); | ||
} | ||
} | ||
|
||
// save Data for every user input | ||
Storage.save(tasks.taskList); | ||
} | ||
} |
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 this be extracted out? Any reasons why you chose to have the input processing method in Duke.java instead of a separate class?
iP/src/duke/Task.java
Outdated
*/ | ||
public class Task { | ||
protected String description; | ||
protected boolean isDone; |
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 how you named this member. It is very clear that its going to be a boolean!
iP/src/duke/TaskList.java
Outdated
@@ -47,4 +47,14 @@ public Task getTask(int index) { | |||
Task task = taskList.get(index); | |||
return task; | |||
} | |||
|
|||
public ArrayList<Task> find(String keyword) { |
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 agree
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 would suggest to gitignore build files, i.e. in this context, the directories iP/.idea
and iP/out
. The reason behind this is any changes to the code would change the files in these directories, and would create too many unnecessary changes in the git history.
iP/src/duke/Deadline.java
Outdated
@@ -0,0 +1,32 @@ | |||
package duke; |
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 second the suggestion made by @YangJiyu98
iP/src/duke/Deadline.java
Outdated
protected LocalDate deadline; | ||
|
||
/** | ||
* constructor of Deadline |
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 capitalize the beginning of JavaDoc comments? This applies to all other JavaDoc comments as well.
iP/src/duke/Duke.java
Outdated
@@ -1,6 +1,7 @@ | |||
package duke; |
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.
Repeated suggestion. I second this as well.
iP/src/duke/Duke.java
Outdated
import java.io.IOException; | ||
import java.time.LocalDate; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; |
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 group imports based on the packages and leave an empty line between groups?
iP/src/duke/Duke.java
Outdated
Command c = Parser.parse(fullCommand); | ||
c.execute(tasks, ui, storage); | ||
isExit = c.isExit(); | ||
*/ |
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.
Not part of the Java coding standard, but perhaps remove commented code that I would presume is unwanted?
iP/src/duke/Duke.java
Outdated
ui.showError(e.getMessage()); | ||
} | ||
|
||
} else if (instructionType.equals("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.
I second that
iP/src/duke/Duke.java
Outdated
|
||
} else { | ||
// invalid input | ||
if (!loading){ |
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 second that
iP/src/duke/Duke.java
Outdated
ui = new Ui(); | ||
storage = new Storage(filePath); | ||
try { | ||
// need empty tasks to load properly |
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.
From the java coding standards: "Logical units within a block should be separated by one blank line."
Consider leaving a line before the try block?
iP/src/duke/Duke.java
Outdated
// parse instruction | ||
HashMap<String, Object> parsedData = Parser.parseAddEventInstr(user_input); | ||
String description = (String) parsedData.get("description"); | ||
LocalDate l_time = (LocalDate) parsedData.get("time"); |
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 name could be more descriptive.
iP/src/duke/Parser.java
Outdated
static HashMap<String, Object> parseAddDeadlineInstr(String user_input) throws DukeException { | ||
// check if input is valid | ||
if (user_input.split(" ", 2).length == 1) { | ||
throw new DukeException("☹ OOPS!!! The description of a deadline cannot be empty."); | ||
} | ||
String task = user_input.split(" ", 2)[1]; | ||
if (task.split(" /by ", 2).length < 2) { | ||
throw new DukeException("☹ OOPS!!! The description and time is required for deadline"); | ||
} | ||
// get data | ||
String description = task.split(" /by ", 2)[0]; | ||
String time = task.split(" /by ")[1]; | ||
LocalDate l_time = LocalDate.parse(time); | ||
HashMap<String, Object> parsedData = new HashMap<String, Object>(){ | ||
{ put("description", description); put("time", l_time); } | ||
}; | ||
return parsedData; | ||
} |
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 block is generally abit chaotic, perhaps add in line breaks to separate different logical units?
iP/src/duke/Ui.java
Outdated
} | ||
|
||
/** | ||
* show welcome message when app is started |
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.
Javadocs:
- "show" should be "Shows"
- add a full stop after the function description
before: root = CS2103 > iP(redundant folder) > folders after: root = CS2103 > folders
Merge A-Assertions branch to master branch
# Conflicts: # src/main/java/duke/Duke.java # src/main/java/duke/Parser.java
Branch a code quality branch to master branch
No description provided.