-
Notifications
You must be signed in to change notification settings - Fork 429
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
[Timothy Tay] iP #441
Open
tim0tay
wants to merge
31
commits into
nus-cs2103-AY2425S2:master
Choose a base branch
from
tim0tay:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,130
−17
Open
[Timothy Tay] iP #441
Changes from 14 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
68c58c1
Add Gradle support
03523ec
Bump gradle and lib version
Eclipse-Dominator 81a9c53
build.gradle: Prevent generating a second JAR file
aureliony ca65b31
Level-0: Rename, Greet, Exit
tim0tay 483d979
Level-1: Echo
tim0tay 13c489e
Level 2: Add, List
tim0tay 0eb6c4f
Level 3: Mark as Done
tim0tay 74dc814
Level 4: ToDos, Events, Deadlines
tim0tay 4ba37f8
A-TextUiTesting
tim0tay 31df729
Level 5: Handle Errors
tim0tay 7f04787
Level 6: Delete
tim0tay ea2fd5f
branch-Level-7
tim0tay 920d4a3
Merge branch 'branch-Level-7'
tim0tay e8f4512
branch-Level-8
tim0tay a402798
Merge branch 'branch-Level-8'
tim0tay 521c1c6
A-MoreOOP
tim0tay 283af29
Merge branch 'A-MoreOOP'
tim0tay 3c54be5
A-Packages
tim0tay 2990fbf
Merge branch 'refs/heads/A-Packages'
tim0tay 9d2d86c
Merge remote-tracking branch 'origin/add-gradle-support'
tim0tay 450b361
A-JUnit
tim0tay f4c0d13
Merge branch 'A-JUnit'
tim0tay 5a77176
A-JavaDoc
tim0tay 74e9265
Merge branch 'A-JavaDoc'
tim0tay a9f0858
A-CodingStandard
tim0tay ca148d1
Merge branch 'A-CodingStandard'
tim0tay a54b41c
Level-9: Find
tim0tay 4dae0b1
branch-Level-9
tim0tay 218bbbb
Merge branch 'branch-Level-9'
tim0tay 672fc8f
Level-10: GUI
tim0tay d2856f2
Merge branch 'Level-10'
tim0tay File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import java.time.LocalDate; | ||
|
||
public class AddDeadlineCommand extends Command { | ||
/** | ||
* The AddDeadlineCommand class represents the command to add a deadline task. | ||
*/ | ||
private static final String horizontalLine = "-------------------------------------------" + | ||
"-------------------------------------\n"; | ||
private final String taskDescription; | ||
private final LocalDate deadline; | ||
|
||
/** | ||
* Initialises a newly created AddDeadlineCommand object. | ||
* @param command the type of command | ||
* @param taskDescription the description of the task | ||
* @param deadline the deadline of the task | ||
*/ | ||
public AddDeadlineCommand(CommandType command, String taskDescription, LocalDate deadline) { | ||
super(command); | ||
this.taskDescription = taskDescription; | ||
this.deadline = deadline; | ||
} | ||
|
||
/** | ||
* Adds a deadline task to the list of tasks. | ||
* @param ui the user interface of the chatbot | ||
* @param storage the storage of tasks | ||
*/ | ||
@Override | ||
public void execute(Ui ui, Storage storage) { | ||
DeadlineTask newTask = new DeadlineTask(this.taskDescription, this.deadline); | ||
String added = storage.addToList(newTask); | ||
ui.print(horizontalLine + added + "\n" + horizontalLine); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import java.time.LocalDate; | ||
|
||
public class AddEventCommand extends Command { | ||
/** | ||
* The AddEventCommand class represents the command to add an event task. | ||
*/ | ||
private static final String horizontalLine = "--------------------------------------------------------------------------------\n"; | ||
private final String taskDescription; | ||
private final LocalDate from; | ||
private final LocalDate to; | ||
|
||
/** | ||
* Initialises a newly created AddEventCommand object. | ||
* @param command the type of command | ||
* @param taskDescription the description of the task | ||
* @param from the start date of the event | ||
* @param to the end date of the event | ||
*/ | ||
public AddEventCommand(CommandType command, String taskDescription, LocalDate from, LocalDate to) { | ||
super(command); | ||
this.taskDescription = taskDescription; | ||
this.from = from; | ||
this.to = to; | ||
} | ||
|
||
/** | ||
* Adds an event task to the list of tasks. | ||
* Prints out the confirmation message or the error message. | ||
* @param ui the user interface of the chatbot | ||
* @param storage the storage of tasks accumulated as the chatbot runs | ||
*/ | ||
@Override | ||
public void execute(Ui ui, Storage storage) { | ||
EventTask newTask = new EventTask(this.taskDescription, this.from, this.to); | ||
String added = storage.addToList(newTask); | ||
ui.print(horizontalLine + added + "\n" + horizontalLine); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
public class AddToDoCommand extends Command { | ||
/** | ||
* The AddToDoCommand class represents the command to add a to-do task. | ||
*/ | ||
private static final String horizontalLine = "--------------------------------------------------------------------------------\n"; | ||
private final String taskDescription; | ||
|
||
/** | ||
* Initialises a newly created AddToDoCommand object. | ||
* @param command the type of command | ||
* @param taskDescription the description of the task | ||
*/ | ||
public AddToDoCommand(CommandType command, String taskDescription) { | ||
super(command); | ||
this.taskDescription = taskDescription; | ||
} | ||
|
||
/** | ||
* Adds a to-do task to the list of tasks. | ||
* Prints out the confirmation message or the error message. | ||
* @param ui the user interface of the chatbot | ||
* @param storage the storage of tasks accumulated as the chatbot runs | ||
*/ | ||
@Override | ||
public void execute(Ui ui, Storage storage) { | ||
ToDoTask newTask = new ToDoTask(this.taskDescription); | ||
String added = storage.addToList(newTask); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps a more descriptive name instead of |
||
ui.print(horizontalLine + added + "\n" + horizontalLine); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
public abstract class Command { | ||
/** | ||
* The Command class represents commands that can be run by the chatbot. | ||
* To implement this class, extend this class and override the execute method. | ||
*/ | ||
private final CommandType command; | ||
|
||
public Command(CommandType command) { | ||
this.command = command; | ||
} | ||
|
||
/** | ||
* Executes the command specific to the object. | ||
* @param ui the user interface of the chatbot | ||
* @param storage the storage of tasks accumulated as the chatbot runs | ||
*/ | ||
public abstract void execute(Ui ui, Storage storage) throws InvalidTaskNumberException, NoDescriptionException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
public enum CommandType { | ||
LIST, MARK, UNMARK, TODO, DEADLINE, EVENT, DELETE, UNKNOWN | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import java.time.LocalDate; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
public class DeadlineTask extends Task { | ||
protected static final String type = "D | "; | ||
protected LocalDate deadline; | ||
|
||
public DeadlineTask(String description, LocalDate deadline) { | ||
super(description); | ||
this.deadline = deadline; | ||
} | ||
|
||
/** | ||
* Returns a string that visually indicates the status of the to-do item. | ||
* @return the string that represents the task type and status | ||
*/ | ||
@Override | ||
public String getStatusIcon() { | ||
return DeadlineTask.type + super.getStatusIcon(); | ||
} | ||
|
||
/** | ||
* Returns a string representation of the deadline. | ||
* @return the string that represents the deadline description | ||
*/ | ||
@Override | ||
public String toString() { | ||
return this.getStatusIcon() + super.getTaskDescription() + " by: " | ||
+ this.deadline.format(DateTimeFormatter.ofPattern("MMM dd yyyy")) + "\n"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
public class DeleteTaskCommand extends Command { | ||
/** | ||
* The DeleteTaskCommand class represents the command to delete a task from the chatbot. | ||
*/ | ||
private static final String horizontalLine = "--------------------------------------------------------------------------------\n"; | ||
private final int index; | ||
|
||
/** | ||
* Initialises a newly created DeleteTaskCommand object. | ||
* @param command the type of command | ||
* @param index the description of the task. | ||
*/ | ||
public DeleteTaskCommand(CommandType command, int index) { | ||
super(command); | ||
this.index = index; | ||
} | ||
|
||
/** | ||
* Deletes a specific task. | ||
* Prints out the confirmation message or the error message. | ||
* @param ui the user interface of the chatbot | ||
* @param storage the storage of tasks accumulated as the chatbot runs | ||
*/ | ||
@Override | ||
public void execute(Ui ui, Storage storage) throws InvalidTaskNumberException { | ||
String deleted = storage.deleteTask(this.index); | ||
ui.print(horizontalLine + deleted + "\n" + horizontalLine); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import java.time.LocalDate; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
public class EventTask extends Task { | ||
protected static final String type = "E | "; | ||
protected LocalDate from; | ||
protected LocalDate to; | ||
|
||
public EventTask(String description, LocalDate from, LocalDate to) { | ||
super(description); | ||
this.from = from; | ||
this.to = to; | ||
} | ||
|
||
/** | ||
* Returns a string that visually indicates the status of the to-do item. | ||
* @return the string that represents the task type and status | ||
*/ | ||
@Override | ||
public String getStatusIcon() { | ||
return EventTask.type + super.getStatusIcon(); | ||
} | ||
|
||
/** | ||
* Returns a string representation of the event. | ||
* @return the string that represents the event description | ||
*/ | ||
@Override | ||
public String toString() { | ||
return this.getStatusIcon() + super.getTaskDescription() | ||
+ " from: " + this.from.format(DateTimeFormatter.ofPattern("MMM dd yyyy")) | ||
+ " to: " + this.to.format(DateTimeFormatter.ofPattern("MMM dd yyyy")) + "\n"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
public class InvalidTaskNumberException extends ProphetException { | ||
protected String message; | ||
|
||
public InvalidTaskNumberException() { | ||
this.message = "Whoops! Invalid number. Please key in a valid integer\n"; | ||
} | ||
|
||
/** | ||
* Returns a string representation of the exception. | ||
* @return the string that represents the Prophet's exception | ||
*/ | ||
public String toString() { | ||
return this.message; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
public class ListCommand extends Command { | ||
/** | ||
* The ListCommand class represents a command to list all tasks in the chatbot. | ||
*/ | ||
private static final String horizontalLine = "--------------------------------------------------------------------------------\n"; | ||
|
||
/** | ||
* Initialises a newly created ListCommand object. | ||
* @param command the type of command | ||
*/ | ||
public ListCommand(CommandType command) { | ||
super(command); | ||
} | ||
|
||
/** | ||
* Prints out all current tasks. | ||
* @param ui the user interface of the chatbot | ||
* @param storage the storage of tasks | ||
*/ | ||
@Override | ||
public void execute(Ui ui, Storage storage) { | ||
String list = storage.enumerateList(); | ||
ui.print(horizontalLine + list + "\n" + horizontalLine); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
public class MarkCommand extends Command { | ||
/** | ||
* The MarkCommand class represents the command to mark a task as done. | ||
*/ | ||
private static final String horizontalLine = "--------------------------------------------------------------------------------\n"; | ||
private final int index; | ||
|
||
/** | ||
* Initialises a newly created MarkCommand object. | ||
* @param command the type of command | ||
* @param index the index of the task to be marked as done | ||
*/ | ||
public MarkCommand(CommandType command, int index) { | ||
super(command); | ||
this.index = index; | ||
} | ||
|
||
/** | ||
* Marks a specific task as done. | ||
* Prints out the confirmation message or the error message. | ||
* @param ui the user interface of the chatbot | ||
* @param storage the storage of tasks accumulated as the chatbot runs | ||
*/ | ||
@Override | ||
public void execute(Ui ui, Storage storage) { | ||
String marked = storage.markDone(index); | ||
ui.print(horizontalLine + marked + "\n" + horizontalLine); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
public class MarkNotDoneCommand extends Command { | ||
/** | ||
* The MarkNotDoneCommand class represents the command to mark a task as not done. | ||
*/ | ||
private static final String horizontalLine = "--------------------------------" + | ||
"------------------------------------------------\n"; | ||
private final int index; | ||
|
||
/** | ||
* Initialises a newly created MarkNotDoneCommand object. | ||
* @param command the type of command | ||
* @param index the description of the task | ||
*/ | ||
public MarkNotDoneCommand(CommandType command, int index) { | ||
super(command); | ||
this.index = index; | ||
} | ||
|
||
/** | ||
* Marks a specific task as not done. | ||
* Prints out the confirmation message or the error message. | ||
* @param ui the user interface of the chatbot | ||
* @param storage the storage of tasks accumulated as the chatbot runs | ||
*/ | ||
@Override | ||
public void execute(Ui ui, Storage storage) { | ||
String marked = storage.markNotDone(index); | ||
ui.print(horizontalLine + marked + "\n" + horizontalLine); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
public class NoDescriptionException extends ProphetException { | ||
protected String message; | ||
|
||
public NoDescriptionException() { | ||
this.message = "Part of your description is missing. Usage is as such: \n" + | ||
"todo description \nOR \ndeadline description /by when \nOR \nevent description /from when /to when\n"; | ||
} | ||
|
||
/** | ||
* Returns a string representation of the exception. | ||
* @return the string that represents the no description exception | ||
*/ | ||
public String toString() { | ||
return this.message; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 broke this long line so as to not make the line too long!