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

[John Benedict] iP #14

Open
wants to merge 57 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
556af3f
Add Gradle support
May 24, 2020
1a08237
Level 1. Greet, Echo, Exit
johnbenedictyan Aug 16, 2022
4684662
Level 2. Add, List
johnbenedictyan Aug 16, 2022
0c3b836
Level 3. Mark as Done
johnbenedictyan Aug 16, 2022
563d353
Level 4. ToDos, Events, Deadlines
johnbenedictyan Aug 16, 2022
75ffbe7
Test using the I/O redirection technique
johnbenedictyan Aug 16, 2022
42c6669
Level 5. Handle Errors
johnbenedictyan Aug 16, 2022
f1efa27
A-Exceptions
johnbenedictyan Aug 16, 2022
2e0dfc5
Level 6. Delete
johnbenedictyan Aug 16, 2022
3eaaa9e
A-Enums
johnbenedictyan Aug 16, 2022
3ea20b7
Refactor greeting functions
johnbenedictyan Aug 16, 2022
ee86507
Refactor task control flow with new task controller class
johnbenedictyan Aug 16, 2022
075ed42
Refactor code
johnbenedictyan Aug 16, 2022
7bc87fc
Refactor code
johnbenedictyan Aug 16, 2022
a1b132a
Add javadoc
johnbenedictyan Aug 16, 2022
ade32cb
Refactor folder structure
johnbenedictyan Aug 16, 2022
aada865
Level 7. Save
johnbenedictyan Aug 22, 2022
812c48f
Level 8. Dates and Times
johnbenedictyan Aug 23, 2022
63cb852
Merge remote-tracking branch 'upstream/add-gradle-support'
johnbenedictyan Aug 24, 2022
df388ea
A-Gradle
johnbenedictyan Aug 24, 2022
351bea5
A-Packages
johnbenedictyan Aug 24, 2022
961e2a2
A-MoreOOP
johnbenedictyan Aug 25, 2022
26a9e28
A-JUnit
johnbenedictyan Aug 27, 2022
df12bfd
A-JUnit
johnbenedictyan Aug 27, 2022
9c47fc4
A-JavaDoc
johnbenedictyan Aug 27, 2022
2ae11e1
A-CodingStandard
johnbenedictyan Aug 27, 2022
e8c70a9
Level 9. Find
johnbenedictyan Aug 27, 2022
0d47ec9
Merge branch-A-CodingStandard into master.
johnbenedictyan Aug 27, 2022
b9cef36
Merge branch-Level-9 into master.
johnbenedictyan Aug 27, 2022
50fe134
A-CheckStyle
johnbenedictyan Aug 30, 2022
5669425
Level 10. GUI
johnbenedictyan Aug 30, 2022
f3545a1
A-Varargs
johnbenedictyan Sep 1, 2022
87ae671
A-Assertions
johnbenedictyan Sep 5, 2022
cd9e60a
A-CodeQuality
johnbenedictyan Sep 9, 2022
5ff07e0
A-Streams
johnbenedictyan Sep 9, 2022
9e33d5a
Merge pull request #3 from johnbenedictyan/branch-A-CodeQuality
johnbenedictyan Sep 9, 2022
94b7687
Merge pull request #2 from johnbenedictyan/branch-A-Streams
johnbenedictyan Sep 9, 2022
3ba60a1
Deconflict merge
johnbenedictyan Sep 9, 2022
a74a0ee
Merge pull request #1 from johnbenedictyan/branch-A-Assertions
johnbenedictyan Sep 9, 2022
82a8dc5
Add github workflow
johnbenedictyan Sep 9, 2022
be0b419
Generate Javadocs
johnbenedictyan Sep 9, 2022
92ed8d1
C-Sort
johnbenedictyan Sep 9, 2022
f261e0a
Add ability to display help task
johnbenedictyan Sep 10, 2022
c9e1a52
Implement Better UI
johnbenedictyan Sep 12, 2022
8688724
Style Javadocs
johnbenedictyan Sep 12, 2022
5d4febf
Implement Duke Personality
johnbenedictyan Sep 12, 2022
c95f555
Improve testing and parser
johnbenedictyan Sep 13, 2022
ece159b
Update github pages configuration
johnbenedictyan Sep 13, 2022
34e6186
Fix test indentation
johnbenedictyan Sep 13, 2022
a047a99
Remove ui picture
johnbenedictyan Sep 13, 2022
494bc6c
Upload ui picture
johnbenedictyan Sep 13, 2022
0f84726
Rename ui picture
johnbenedictyan Sep 13, 2022
e1008ef
Rename ui picture
johnbenedictyan Sep 13, 2022
1d885de
Update github page config file
johnbenedictyan Sep 13, 2022
768719b
Add a User Guide
johnbenedictyan Sep 14, 2022
29647bd
Fix gradle for release
johnbenedictyan Sep 14, 2022
cbccb22
Fix storage file creation and access
johnbenedictyan Sep 16, 2022
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
12 changes: 3 additions & 9 deletions src/main/java/duke/Duke.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@
import duke.commands.ErrorCommand;
import duke.commands.ExitCommand;
import duke.commands.tasks.BaseTaskCommand;
import duke.exceptions.IncorrectArgumentException;
import duke.exceptions.InvalidDateTimeException;
import duke.exceptions.InvalidTaskSpecificationException;
import duke.exceptions.MissingArgumentException;
import duke.exceptions.NoCommandException;
import duke.exceptions.UnknownCommandException;
import duke.exceptions.ParseException;
import duke.parser.Parser;
import duke.storage.Storage;
import duke.tasklist.TaskList;
Expand Down Expand Up @@ -69,8 +65,7 @@ private void runCommandLoopUntilExitCommand() {
String userCommandText = ui.getUserCommand();
try {
command = parser.parse(userCommandText);
} catch (MissingArgumentException | InvalidDateTimeException | InvalidTaskSpecificationException
| IncorrectArgumentException | UnknownCommandException | NoCommandException e) {
} catch (NoCommandException | ParseException e) {
command = new ErrorCommand(e.getMessage());
}
CommandResult result = runCommand(command);
Expand Down Expand Up @@ -158,8 +153,7 @@ public String getResponse(String text) {
BaseCommand command;
try {
command = parser.parse(text);
} catch (MissingArgumentException | InvalidDateTimeException | InvalidTaskSpecificationException
| IncorrectArgumentException | UnknownCommandException | NoCommandException e) {
} catch (NoCommandException | ParseException e) {
command = new ErrorCommand(e.getMessage());
}
CommandResult result = runCommand(command);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/duke/commands/ExitCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* ExitCommand Class
*/
public class ExitCommand implements BaseCommand {
public static final String COMMAND_WORD = "exit";

@Override
public CommandResult execute() {
String successMessage = "Thank you for using aladdin services!\n";
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/duke/commands/tasks/AddDeadlineCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package duke.commands.tasks;

import duke.commands.CommandResult;
import duke.domain.Deadline;

public class AddDeadlineCommand extends BaseTaskCommand {
public static final String COMMAND_WORD = "deadline";
public static final String SUBCOMMAND_WORD = " by ";
private final Deadline deadline;
private String successMessage = "This task has been successfully added!\n";

public AddDeadlineCommand(Deadline deadline) {
this.deadline = deadline;
}

@Override
public CommandResult execute() {
this.taskList.addTask(deadline);
successMessage = String.format("%s%s%s", successMessage, "\n", deadline);
return new CommandResult(super.formatOutputString(successMessage));
}

}
23 changes: 23 additions & 0 deletions src/main/java/duke/commands/tasks/AddEventCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package duke.commands.tasks;

import duke.commands.CommandResult;
import duke.domain.Event;

public class AddEventCommand extends BaseTaskCommand {
public static final String COMMAND_WORD = "event";
public static final String SUBCOMMAND_WORD = " at ";
private final Event event;
private String successMessage = "This task has been successfully added!\n";

public AddEventCommand(Event event) {
this.event = event;
}

@Override
public CommandResult execute() {
this.taskList.addTask(event);
successMessage = String.format("%s%s%s", successMessage, "\n", event);
return new CommandResult(super.formatOutputString(successMessage));
}

}
31 changes: 0 additions & 31 deletions src/main/java/duke/commands/tasks/AddTaskCommand.java

This file was deleted.

22 changes: 22 additions & 0 deletions src/main/java/duke/commands/tasks/AddTodoCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package duke.commands.tasks;

import duke.commands.CommandResult;
import duke.domain.Todo;

public class AddTodoCommand extends BaseTaskCommand {
public static final String COMMAND_WORD = "todo";
private final Todo todo;
private String successMessage = "This task has been successfully added!\n";

public AddTodoCommand(Todo todo) {
this.todo = todo;
}

@Override
public CommandResult execute() {
this.taskList.addTask(todo);
successMessage = String.format("%s%s%s", successMessage, "\n", todo);
return new CommandResult(super.formatOutputString(successMessage));
}

}
8 changes: 5 additions & 3 deletions src/main/java/duke/commands/tasks/DeleteTaskCommand.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
package duke.commands.tasks;

import duke.commands.CommandResult;
import duke.domain.Task;
import duke.domain.task.Task;
import duke.domain.task.TaskIndex;
import duke.exceptions.TaskNotFoundException;

/**
* DeleteTaskCommand class
*/
public class DeleteTaskCommand extends BaseTaskCommand {
public static final String COMMAND_WORD = "delete";
private String successMessage = "This task has been successfully deleted!\n";
private String errorMessage = "An error occurred when deleting this task:\n";
private final int taskIndex;
private final TaskIndex taskIndex;

/**
*
*/
public DeleteTaskCommand(Integer taskIndex) {
public DeleteTaskCommand(TaskIndex taskIndex) {
this.taskIndex = taskIndex;
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/duke/commands/tasks/FindTaskCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Find Task Command Class
*/
public class FindTaskCommand extends BaseTaskCommand {
public static final String COMMAND_WORD = "find";
private final String searchTerm;
private String successMessage = "Here are the matching tasks:\n";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* ListTasksAfterCommand class
*/
public class ListTasksAfterCommand extends ListTasksCommand {
public static final String SUBCOMMAND_WORD = "/after ";
private final LocalDateTime dateTime;
private String successMessage = "Here are your tasks:\n";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* ListTasksBeforeCommand class
*/
public class ListTasksBeforeCommand extends ListTasksCommand {
public static final String SUBCOMMAND_WORD = "/before ";
private final LocalDateTime dateTime;
private String successMessage = "Here are your tasks:\n";

Expand Down
1 change: 1 addition & 0 deletions src/main/java/duke/commands/tasks/ListTasksCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* ListTasksCommand Class
*/
public class ListTasksCommand extends BaseTaskCommand {
public static final String COMMAND_WORD = "list";
private String successMessage = "Here are your tasks:\n";

@Override
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/duke/commands/tasks/MarkTaskCommand.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
package duke.commands.tasks;

import duke.commands.CommandResult;
import duke.domain.Task;
import duke.domain.task.Task;
import duke.domain.task.TaskIndex;
import duke.exceptions.TaskNotFoundException;

/**
* MarkTaskCommand Class
*/
public class MarkTaskCommand extends BaseTaskCommand {
public static final String COMMAND_WORD = "mark";
private String successMessage = "This task has been successfully marked!\n";
private String errorMessage = "An error occurred when marking this task:\n";
private final Integer taskIndex;
private final TaskIndex taskIndex;

/**
*
*/
public MarkTaskCommand(Integer taskIndex) {
public MarkTaskCommand(TaskIndex taskIndex) {
this.taskIndex = taskIndex;
}

Expand Down
8 changes: 5 additions & 3 deletions src/main/java/duke/commands/tasks/UnmarkTaskCommand.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
package duke.commands.tasks;

import duke.commands.CommandResult;
import duke.domain.Task;
import duke.domain.task.Task;
import duke.domain.task.TaskIndex;
import duke.exceptions.TaskNotFoundException;

/**
* UnmarkTaskCommand class
*/
public class UnmarkTaskCommand extends BaseTaskCommand {
public static final String COMMAND_WORD = "unmark";
private String successMessage = "This task has been successfully unmarked!\n";
private String errorMessage = "An error occurred when unmarking this task:\n";
private final Integer taskIndex;
private final TaskIndex taskIndex;

/**
*
*/
public UnmarkTaskCommand(Integer taskIndex) {
public UnmarkTaskCommand(TaskIndex taskIndex) {
this.taskIndex = taskIndex;
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/duke/data/tasks.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
T@@@0@@@read book@@@$_$
T@@@0@@@ buy book@@@$_$
T@@@0@@@ read book@@@$_$
2 changes: 2 additions & 0 deletions src/main/java/duke/domain/Deadline.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.time.LocalDateTime;
import java.util.Objects;

import duke.domain.task.Task;

/**
* The type Deadline.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/duke/domain/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.time.LocalDateTime;
import java.util.Objects;

import duke.domain.task.Task;

/**
* The type Event.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/duke/domain/Todo.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.util.Objects;

import duke.domain.task.Task;

/**
* The type Todo.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package duke.domain;
package duke.domain.task;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.Objects;

import duke.domain.Deadline;
import duke.domain.Event;
import duke.domain.Todo;
import duke.exceptions.InvalidDateTimeException;
import duke.exceptions.InvalidTaskSpecificationException;

Expand Down
17 changes: 17 additions & 0 deletions src/main/java/duke/domain/task/TaskDescription.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package duke.domain.task;

public class TaskDescription {
public static final String MESSAGE_CONSTRAINTS = "Names should only contain alphanumeric characters and spaces, and it should not be blank";

public static final String VALIDATION_REGEX = "[\\p{Alnum}][\\p{Alnum} ]*";

public final String taskDescription;

public TaskDescription(String description) {
taskDescription = description;
}

public static boolean isValid(String test) {
return test.matches(VALIDATION_REGEX);
}
}
30 changes: 30 additions & 0 deletions src/main/java/duke/domain/task/TaskIndex.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package duke.domain.task;

import duke.exceptions.TaskIndexOutOfBoundsException;

public class TaskIndex {
private final int zeroBasedTaskIndex;

private TaskIndex(int zeroBasedTaskIndex) {
if (zeroBasedTaskIndex < 0) {
throw new TaskIndexOutOfBoundsException();
}
this.zeroBasedTaskIndex = zeroBasedTaskIndex;
}

public int getZeroBased() {
return zeroBasedTaskIndex;
}

public int getOneBased() {
return zeroBasedTaskIndex + 1;
}

public static TaskIndex fromZeroBased(int zeroBasedTaskIndex) {
return new TaskIndex(zeroBasedTaskIndex);
}

public static TaskIndex fromOneBased(int oneBasedTaskIndex) {
return new TaskIndex(oneBasedTaskIndex - 1);
}
}
4 changes: 2 additions & 2 deletions src/main/java/duke/exceptions/NoCommandException.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class NoCommandException extends DukeException {
/**
* No command found exception constructor.
*/
public NoCommandException(String errorString) {
super(errorString);
public NoCommandException() {
super("Please enter a command");
}
}
7 changes: 7 additions & 0 deletions src/main/java/duke/exceptions/ParseException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package duke.exceptions;

public class ParseException extends DukeException {
public ParseException(String errorString) {
super(errorString);
}
}
20 changes: 20 additions & 0 deletions src/main/java/duke/exceptions/TaskIndexOutOfBoundsException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package duke.exceptions;

public class TaskIndexOutOfBoundsException extends RuntimeException {
public TaskIndexOutOfBoundsException() {
super("Index is out of range");
}

public TaskIndexOutOfBoundsException(String s) {
super(s);
}

public TaskIndexOutOfBoundsException(int index) {
super("Index out of range: " + index);
}

public TaskIndexOutOfBoundsException(long index) {
super("Index out of range: " + index);
}

}
Loading