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

[Timothy Tay] iP #441

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
68c58c1
Add Gradle support
May 24, 2020
03523ec
Bump gradle and lib version
Eclipse-Dominator Aug 5, 2023
81a9c53
build.gradle: Prevent generating a second JAR file
aureliony Jul 16, 2024
ca65b31
Level-0: Rename, Greet, Exit
tim0tay Jan 24, 2025
483d979
Level-1: Echo
tim0tay Jan 24, 2025
13c489e
Level 2: Add, List
tim0tay Jan 24, 2025
0eb6c4f
Level 3: Mark as Done
tim0tay Jan 24, 2025
74dc814
Level 4: ToDos, Events, Deadlines
tim0tay Jan 24, 2025
4ba37f8
A-TextUiTesting
tim0tay Jan 24, 2025
31df729
Level 5: Handle Errors
tim0tay Jan 24, 2025
7f04787
Level 6: Delete
tim0tay Jan 24, 2025
ea2fd5f
branch-Level-7
tim0tay Feb 4, 2025
920d4a3
Merge branch 'branch-Level-7'
tim0tay Feb 4, 2025
e8f4512
branch-Level-8
tim0tay Feb 4, 2025
a402798
Merge branch 'branch-Level-8'
tim0tay Feb 4, 2025
521c1c6
A-MoreOOP
tim0tay Feb 4, 2025
283af29
Merge branch 'A-MoreOOP'
tim0tay Feb 4, 2025
3c54be5
A-Packages
tim0tay Feb 4, 2025
2990fbf
Merge branch 'refs/heads/A-Packages'
tim0tay Feb 4, 2025
9d2d86c
Merge remote-tracking branch 'origin/add-gradle-support'
tim0tay Feb 4, 2025
450b361
A-JUnit
tim0tay Feb 4, 2025
f4c0d13
Merge branch 'A-JUnit'
tim0tay Feb 4, 2025
5a77176
A-JavaDoc
tim0tay Feb 4, 2025
74e9265
Merge branch 'A-JavaDoc'
tim0tay Feb 4, 2025
a9f0858
A-CodingStandard
tim0tay Feb 4, 2025
ca148d1
Merge branch 'A-CodingStandard'
tim0tay Feb 4, 2025
a54b41c
Level-9: Find
tim0tay Feb 5, 2025
4dae0b1
branch-Level-9
tim0tay Feb 5, 2025
218bbbb
Merge branch 'branch-Level-9'
tim0tay Feb 5, 2025
672fc8f
Level-10: GUI
tim0tay Feb 10, 2025
d2856f2
Merge branch 'Level-10'
tim0tay Feb 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/main/java/AddDeadlineCommand.java
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 = "-------------------------------------------" +
Copy link

@soonami69 soonami69 Feb 4, 2025

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!

"-------------------------------------\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);
}
}
38 changes: 38 additions & 0 deletions src/main/java/AddEventCommand.java
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);
}
}
30 changes: 30 additions & 0 deletions src/main/java/AddToDoCommand.java
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);

Choose a reason for hiding this comment

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

Perhaps a more descriptive name instead of added would be better?

ui.print(horizontalLine + added + "\n" + horizontalLine);
}
}
18 changes: 18 additions & 0 deletions src/main/java/Command.java
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;
}
3 changes: 3 additions & 0 deletions src/main/java/CommandType.java
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
}
31 changes: 31 additions & 0 deletions src/main/java/DeadlineTask.java
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";
}
}
29 changes: 29 additions & 0 deletions src/main/java/DeleteTaskCommand.java
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);
}
}
10 changes: 0 additions & 10 deletions src/main/java/Duke.java

This file was deleted.

34 changes: 34 additions & 0 deletions src/main/java/EventTask.java
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";
}
}
15 changes: 15 additions & 0 deletions src/main/java/InvalidTaskNumberException.java
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;
}
}
25 changes: 25 additions & 0 deletions src/main/java/ListCommand.java
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);
}
}
29 changes: 29 additions & 0 deletions src/main/java/MarkCommand.java
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);
}
}
30 changes: 30 additions & 0 deletions src/main/java/MarkNotDoneCommand.java
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);
}
}
16 changes: 16 additions & 0 deletions src/main/java/NoDescriptionException.java
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;
}
}
Loading