Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7e3eb8d
Level-0
Jamarcus111 Jan 31, 2024
b246b61
Level-0, deleting Duke
Jamarcus111 Jan 31, 2024
4e8d3b2
level1
Jamarcus111 Jan 31, 2024
774fee3
level2
Jamarcus111 Jan 31, 2024
583d937
Level3
Jamarcus111 Jan 31, 2024
776bbad
restructure the code into OOP style,separate the functionality
Jamarcus111 Feb 11, 2024
4ff88d1
checked coding standard and quality
Jamarcus111 Feb 15, 2024
a59c96e
add function to handle exception
Jamarcus111 Feb 16, 2024
78c3ec6
Modifed exception handlers.
Jamarcus111 Feb 16, 2024
195a073
Merge branch 'branch-Level-5'
Jamarcus111 Feb 16, 2024
bf630f3
Cleaned some unnecessary comments
Jamarcus111 Feb 16, 2024
1195965
Merged branch-Level-5 into main branch
Jamarcus111 Feb 16, 2024
6f480ed
Implement Level-6: Add support for deleting tasks
Jamarcus111 Feb 23, 2024
f575da9
Implement Level-7
Jamarcus111 Feb 23, 2024
25281d9
Merge branch 'branch-Level-6'
Jamarcus111 Feb 23, 2024
4cde7f8
solved merge conflict
Jamarcus111 Feb 23, 2024
d5c4f4f
more-oop
Jamarcus111 Mar 4, 2024
8dfd01e
checked coding standard and quality
Jamarcus111 Mar 4, 2024
c28e998
Merge pull request #1 from Jamarcus111/branch-Level-9
Jamarcus111 Mar 4, 2024
da4cb5e
checked coding standard and quality
Jamarcus111 Mar 4, 2024
33b8043
Merge pull request #2 from Jamarcus111/branch-A-JavaDoc
Jamarcus111 Mar 4, 2024
fb94eb6
checked coding standard and quality
Jamarcus111 Mar 4, 2024
00b0a4c
checked coding standard and quality
Jamarcus111 Mar 4, 2024
e8ab793
Update README.md
Jamarcus111 Jun 26, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ bin/

/text-ui-test/ACTUAL.TXT
text-ui-test/EXPECTED-UNIX.TXT

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Duke project template
# Ma project template

This is a project template for a greenfield Java project. It's named after the Java mascot _Duke_. Given below are instructions on how to use it.

Expand All @@ -13,7 +13,7 @@ Prerequisites: JDK 11, update Intellij to the most recent version.
1. If there are any further prompts, accept the defaults.
1. Configure the project to use **JDK 11** (not other versions) as explained in [here](https://www.jetbrains.com/help/idea/sdk.html#set-up-jdk).<br>
In the same dialog, set the **Project language level** field to the `SDK default` option.
3. After that, locate the `src/main/java/Duke.java` file, right-click it, and choose `Run Duke.main()` (if the code editor is showing compile errors, try restarting the IDE). If the setup is correct, you should see something like the below as the output:
3. After that, locate the `src/main/java/Ma.java` file, right-click it, and choose `Run Ma.main()` (if the code editor is showing compile errors, try restarting the IDE). If the setup is correct, you should see something like the below as the output:
```
Hello from
____ _
Expand All @@ -22,3 +22,4 @@ Prerequisites: JDK 11, update Intellij to the most recent version.
| |_| | |_| | < __/
|____/ \__,_|_|\_\___|
```
The specific instructions for this task manager program is under docs.README.md
4 changes: 4 additions & 0 deletions data/duke.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
T | 1 | 2
T | 1 | read book
D | 0 | askdfsoief as kjsa lf | SFJ
T | 1 | readbook
147 changes: 131 additions & 16 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,144 @@
# User Guide
# TaskManager

## Features
TaskManager is a simple yet powerful Java application designed to help users manage their tasks efficiently. It allows users to add, delete, mark tasks as done or not done, and find tasks by searching for keywords.

### Feature-ABC
## Features

Description of the feature.
- **Add Tasks**: Users can add three types of tasks - todos, deadlines, and events.
- **Delete Tasks**: Users can delete tasks they no longer need.
- **Mark Tasks**: Users can mark tasks as done or not done.
- **Find Tasks**: Users can search for tasks by keywords.
- **List Tasks**: Users can view all their tasks at any time.

### Feature-XYZ
## Getting Started
## Adding a task
### Type of task
- Todo
- Deadline
- Event

Description of the feature.
### Prompt
- Todo: todo {task description}

## Usage
_e.g. adding task todo `read book`_
```
todo read book
```

### `Keyword` - Describe action
- Deadline: deadline {task description} /by {date}

Describe the action and its outcome.
_e.g. adding task deadline `return book` before `2021-09-17`_
```
deadline return book /by 2021-09-17
```

Example of usage:
- Event: event {task description} from {date} to {date}

`keyword (optional arguments)`
_e.g. adding task event `project meeting` from `2021-09-17` to `2021-09-18`_
```
event project meeting from 2021-09-17 to 2021-09-18
```
### Expected output for all adding tasks
Got it. I've added this task:
[D][ ] return book (by: 2021-09-17)
> Note: the following e.g. for each command will be using the output of the above prompt

Expected outcome:
## Listing all tasks
### Prompt
- list

Description of the outcome.
_e.g. listing all tasks_
```
list
```
### Expected output

```
expected output
```
Here are the tasks in your list:
1. [T][ ] read book
2. [D][ ] return book (by: Sep 17 2021)
3. [E][ ] project meeting (from: Sep 17 2021 to: Sep 18 2021)


## Deleting a task
### prompt
- delete {task number}

_e.g. deleting 3_
```
delete 3
```
### Expected output

Noted. I've removed this task: {task number}
this can be verified by listing all tasks:

list
Here are the tasks in your list:
1. [T][ ] read book
2. [D][ ] return book (by: Sep 17 2021)


## Marking a task as done
### Prompt
- mark {task name}

_e.g. marking task 1 as done_
```
mark read book
```
### Expected output

Nice! I've marked this task as done: {task name}
this can be verified by listing or finding tasks:
```
list
Here are the tasks in your list:
1. [T][X] read book
2. [D][ ] return book (by: Sep 17 2021)
3. [E][ ] project meeting (from: Sep 17 2021 to: Sep 18 2021)
```

- unmark {task name}

_e.g. unmarking read book_
```
unmark read book
```
### Expected output
```
unmarked
I've unmarked this task as done: {task name}
```
this can be verified by listing all tasks:
```
list
Here are the tasks in your list:
1. [T][ ] read book
2. [D][ ] return book (by: Sep 17 2021)
3. [E][ ] project meeting (from: Sep 17 2021 to: Sep 18 2021)
```

## Finding a task
### prompt
- find {keyword}

e.g. finding tasks related to `book`
```
find book
```
### Expected output
Here are the matching tasks in your list:
1. [T][ ] read book
2. [D][ ] return book (by: Sep 17 2021)

## Exit Program
### prompt
- bye

### Expected output
```
Bye. Hope to see you again soon!
```
### Prerequisites

- Java 11 or above.
60 changes: 60 additions & 0 deletions src/main/java/CommandParser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* CommandParser is responsible for interpreting and executing commands
* input by the user. It acts as a controller that directs user commands
* to appropriate actions on the task list.
*/
public class CommandParser {
private final TaskList taskList;
private final Ui ui;

/**
* Constructs a CommandParser with the specified task list and UI.
*
* @param taskList the task list to be manipulated based on user commands.
* @param ui the UI object for interacting with the user.
*/
public CommandParser(TaskList taskList, Ui ui) {
this.taskList = taskList;
this.ui = ui;
}

/**
* Parses and executes a user input command. Supported commands include
* adding, deleting, marking, unmarking tasks, and finding tasks by keywords.
* It also handles listing all tasks and exiting the application.
*
* @param userInput the full user input command to be parsed and executed.
*/
public void parseCommand(String userInput) {
try {
if (userInput.trim().isEmpty()) {
ui.showError("The input cannot be empty!");
} else if (userInput.equalsIgnoreCase("list")) {
taskList.listTasks();
} else if (userInput.startsWith("delete")) {
int taskIndex = Integer.parseInt(userInput.split(" ")[1]) - 1; // Get task index
taskList.deleteTask(taskIndex);
} else if (userInput.startsWith("mark")) {
int taskIndex = Integer.parseInt(userInput.split(" ")[1]) - 1; // Get task index
taskList.markTaskAsDone(taskIndex);
} else if (userInput.startsWith("unmark")) {
int taskIndex = Integer.parseInt(userInput.split(" ")[1]) - 1; // Get task index
taskList.markTaskAsNotDone(taskIndex);
} else if (userInput.startsWith("find")) {
String keyword = userInput.substring(5); // Assume "find " is followed by a keyword
taskList.findTask(keyword);
} else if (!userInput.startsWith("todo") && !userInput.startsWith("deadline")
&& !userInput.startsWith("event") && !userInput.startsWith("find")) {
ui.showError("OOPS!!! I'm sorry, but I don't know what that means :-(");
} else {
taskList.addTask(userInput);
}
} catch (HandleException he) {
ui.showError(he.getMessage());
} catch (NumberFormatException nfe) {
ui.showError("OOPS!!! The task number is invalid.");
} catch (ArrayIndexOutOfBoundsException aioobe) {
ui.showError("OOPS!!! It seems like the command is not complete.");
}
}
}
40 changes: 40 additions & 0 deletions src/main/java/DeadLine.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Represents a deadline task with a specific due date.
* A {@code DeadLine} object encapsulates the details of a task that needs to be done before a specific date.
*/
public class DeadLine extends Task {
protected String by; // The due date of the deadline task.

/**
* Constructs a {@code DeadLine} with the specified task description and due date.
*
* @param description The description of the deadline task.
* @param by The due date of the task.
*/
public DeadLine(String description, String by) {
super(description); // Call the superclass constructor to set the task description.
this.by = by; // Set the due date of the deadline task.
}

/**
* Returns the string representation of the deadline task in a format suitable for file storage.
* The format is "D | isDone | description | by", where "D" indicates a deadline task.
*
* @return A string representation of the deadline task for file storage.
*/
@Override
public String toFileFormat() {
return String.format("D | %d | %s | %s", isDone ? 1 : 0, description, by);
}

/**
* Returns the string representation of the deadline task, including its status (done or not done),
* description, and due date.
*
* @return A string representation of the deadline task, including status, description, and due date.
*/
@Override
public String toString() {
return "[D]" + super.toString() + " (by: " + this.by + ")";
}
}
10 changes: 0 additions & 10 deletions src/main/java/Duke.java

This file was deleted.

44 changes: 44 additions & 0 deletions src/main/java/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* Represents an event task with a start and end time.
* An {@code Event} object encapsulates the details of a task that occurs over a period defined by a start and end time.
*/
public class Event extends Task {
protected String from; // The start time of the event.
protected String to; // The end time of the event.

/**
* Constructs an {@code Event} with the specified task description, start time, and end time.
*
* @param description The description of the event task.
* @param from The start time of the event.
* @param to The end time of the event.
*/
public Event(String description, String from, String to) {
super(description); // Call the superclass constructor to set the task description.
this.from = from; // Set the start time of the event.
this.to = to; // Set the end time of the event.
}

/**
* Returns the string representation of the event task in a format suitable for file storage.
* The format is "E | isDone | description | from to to", where "E" indicates an event task.
*
* @return A string representation of the event task for file storage.
*/
@Override
public String toFileFormat() {
return String.format("E | %d | %s | %s to %s", isDone ? 1 : 0, description, from, to);
}

/**
* Returns the string representation of the event task, including its status (done or not done),
* description, and the period over which it occurs (from start time to end time).
*
* @return A string representation of the event task, including status, description, and period.
*/
@Override
public String toString() {
return "[E]" + super.toString() + " (from: " + this.from + " to: " + this.to + ")";
}
}

20 changes: 20 additions & 0 deletions src/main/java/HandleException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Represents a custom exception class for handling errors specific to the application.
* {@code HandleException} is used to encapsulate user-related errors, providing
* more context and control over error handling within the application.
*/
public class HandleException extends Exception {

/**
* Constructs a new {@code HandleException} with the specified detail message.
* The detail message is saved for later retrieval by the {@link #getMessage()} method.
*
* @param message the detail message. The detail message is saved for later retrieval
* by the {@link #getMessage()} method.
*/
public HandleException(String message) {
super(message);
}
}


3 changes: 3 additions & 0 deletions src/main/java/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: TaskManager

Loading