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

[Yen Pin Hsuan] iP #97

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

Conversation

ypinhsuan
Copy link

No description provided.

damithc and others added 30 commits July 23, 2020 23:27
# Conflicts:
#	src/main/java/Duke.java
# Conflicts:
#	src/main/java/duke/Duke.java
#	src/main/java/duke/Storage.java
#	src/main/java/duke/task/Deadline.java
#	src/main/java/duke/task/Event.java
#	src/main/java/duke/task/Task.java
#	src/main/java/duke/task/ToDo.java
# Conflicts:
#	src/main/java/duke/Parser.java
#	src/main/java/duke/TaskList.java
#	src/main/java/duke/task/Task.java
Copy link

@lettuceman4 lettuceman4 left a comment

Choose a reason for hiding this comment

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

I really really like reading your code! Very easy to understand and OOP hehe I learnt a lot!

Comment on lines 90 to 92
public static ToDo parseTodo(String input) throws DukeException {
if (input.equals("")) {
throw new DukeException("Oops! Todo cannot be empty");

Choose a reason for hiding this comment

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

I'm a bit confused here... maybe can change the variable "input" to "detail" like in the parse method because for some reason i assumed the input is the whole string ><

Comment on lines 107 to 110
if (arr.length == 1 || arr[0].trim().equals("")) {
throw new DukeException("Oops! You need to include both detail and time.");
}
String detail = arr[0].trim();

Choose a reason for hiding this comment

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

I think maybe can factor our the arr[0].trim() a bit earlier here?

Comment on lines 48 to 65
case BYE:
return new ByeCommand();
case LIST:
return new ListCommand();
case DONE:
return new DoneCommand(parseNumber(detail));
case TODO:
return new TodoCommand(parseTodo(detail));
case EVENT:
return new EventCommand(parseEvent(detail));
case DEADLINE:
return new DeadlineCommand(parseDeadline(detail));
case DELETE:
return new DeleteCommand(parseNumber(detail));
case FIND:
return new FindCommand(detail.trim());
default:
throw new DukeException("Oops! I'm sorry, but I don't know what that means");

Choose a reason for hiding this comment

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

I like this part!!!! So neat! Can I learn from you? :")

Comment on lines 48 to 71
while (buffReader.ready()) {
String savedTask = buffReader.readLine();
String type = savedTask.substring(0, 1);
switch (type) {
case "T":
list.add(new ToDo(savedTask.substring(4).trim(), savedTask.substring(2, 3).equals("T")));
break;
case "D":
String deadlineDetails = savedTask.substring(4);
String[] deadlineArr = deadlineDetails.split("/by");
Deadline deadline = new Deadline(
deadlineArr[0].trim(),
savedTask.substring(2, 3).equals("T"),
LocalDateTime.parse(deadlineArr[1].trim()));
list.add(deadline);
break;
case "E":
String eventDetails = savedTask.substring(4);
String[] eventArr = eventDetails.split("/at");
Event event = new Event(
eventArr[0].trim(),
savedTask.substring(2, 3).equals("T"),
LocalDateTime.parse(eventArr[1].trim()));
list.add(event);

Choose a reason for hiding this comment

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

Maybe this part can be abstracted into another method? like 1 method to read the file and another to convert the read data to actual objects.

Comment on lines 75 to 76
List<Task> filteredList = list.stream()
.filter(t -> t.getDetails().contains(keyword))

Choose a reason for hiding this comment

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

This is so clever! I used for loop guess now I have to change 👍

Comment on lines 81 to 84
while (iterator.hasNext()) {
count++;
result += " " + count + ". " + iterator.next().toString() + "\n";
}

Choose a reason for hiding this comment

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

This part maybe can consider abstracting it into another method (convertListToString or something) because it can be reused (in list() for example) I think?

* @param storage Storage object which handles storing of data.
* @param ui Ui that interact with user.
*/
public abstract void execute(TaskList taskList, Storage storage, Ui ui);

Choose a reason for hiding this comment

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

Command pattern! Nice!

Comment on lines 99 to 100
* @param input The deadline details given by user.
* @return A Deadline with the input given.

Choose a reason for hiding this comment

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

Should there be an empty line between 98 and 99?

Choose a reason for hiding this comment

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

and other javadoc with description and params too 👍

Choose a reason for hiding this comment

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

also maybe the description should start with Returns instead of Return?

} catch (IOException e) {
e.printStackTrace();
}

Choose a reason for hiding this comment

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

perhaps this space here can let go?

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.

None yet

2 participants