Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ bin/

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

data/
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ Prerequisites: JDK 17, update Intellij to the most recent version.

1. Open Intellij (if you are not in the welcome screen, click `File` > `Close Project` to close the existing project first)
1. Open the project into Intellij as follows:
1. Click `Open`.
1. Select the project directory, and click `OK`.
1. If there are any further prompts, accept the defaults.
1. Click `Open`.
1. Select the project directory, and click `OK`.
1. If there are any further prompts, accept the defaults.
1. Configure the project to use **JDK 17** (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:
Expand All @@ -21,4 +21,4 @@ Prerequisites: JDK 17, update Intellij to the most recent version.
| | | | | | | |/ / _ \
| |_| | |_| | < __/
|____/ \__,_|_|\_\___|
```
```
209 changes: 194 additions & 15 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,209 @@
# Duke User Guide
# TulipTask

// Update the title above to match the actual product name
## Overview

// Product screenshot goes here
TulipTask allows users to manage tasks, including to-dos, events, and deadlines. It provides a command-line interface where users can add, delete, mark task as done, and list tasks. The tasks are saved to a file so they persist across sessions.

// Product intro goes here
---

## Adding deadlines
## Features

// Describe the action and its outcome.
- **Add Tasks**
- **To-Do**: A basic task without any time constraints.
- **Deadline**: A task with a specific deadline.
- **Event**: A task that has a defined start and end time.

// Give examples of usage
- **Manage Tasks**
- Mark tasks as done or not done.
- Delete tasks from the task list.

Example: `keyword (optional arguments)`
- **File Storage**
- Tasks are saved to and loaded from a file, making them persistent between sessions.

// A description of the expected outcome goes here
- **Task Searching**
- You can search for tasks based on keywords in the task description.

---

## Commands

### 1. `todo <description>`
Adds a To-Do task to the task list.

- **Example**:
```
todo Read a book
```

### 2. `deadline <description> /by <due date>`
Adds a Deadline task to the task list.

- **Example**:
```
deadline Submit assignment /by Sunday
```

### 3. `event <description> /from <start time> /to <end time>`
Adds an Event task to the task list.

- **Example**:
```
event Project meeting /from Monday 2pm /to Monday 4pm
```

### 4. `list`
Displays all tasks in the list along with their statuses.

- **Example**:
```
list
```

### 5. `mark <task number>`
Marks a specific task as done based on its task number.

- **Example**:
```
mark 2
```

### 6. `unmark <task number>`
Marks a specific task as not done based on its task number.

- **Example**:
```
unmark 3
```

### 7. `delete <task number>`
Deletes a specific task based on its task number.

- **Example**:
```
delete 4
```

### 8. `find <keyword>`
Finds and lists tasks that contain the specified keyword in their description.

- **Example**:
```
find book
```

### 9. `save`
Manually saves the current task list to the file.

- **Example**:
```
save
```

### 10. `load`
Loads tasks from the file if they exist.

- **Example**:
```
load
```

### 11. `bye`
Exits the application, automatically saving all tasks to the file.

- **Example**:
```
bye
```

---

## Task Types

### 1. **To-Do Task**
- A basic task with no specific time or deadline.
- **Format**: `[T][status] description`

### 2. **Deadline Task**
- A task that must be completed by a specific deadline.
- **Format**: `[D][status] description (by: deadline)`

### 3. **Event Task**
- A task that occurs within a specific time range.
- **Format**: `[E][status] description (from: start time to: end time)`

### Status
- `X` means the task is done.
- ` ` means the task is not done.

---

## File Storage

- Tasks are saved in a file located at `./data/data.txt`.
- Tasks are loaded automatically when the application starts, if the file exists.
- If the data directory or file does not exist, they will be created automatically.

---

## Running the Application

1. **Compile and Run**:
- Ensure all the required classes (`Task`, `ToDo`, `Deadline`, `Event`, `TaskList`, `Ui`, `Storage`, `InputParser`) are compiled.
- Run the `Ui` class which provides the main interaction loop for the application.

2. **Interacting with the App**:
- Upon starting, you will be greeted with a welcome message, and you can enter commands as described above.

3. **Exiting**:
- Use the `bye` command to save all tasks and exit the application.

---

## Example Usage

```
expected output
```
Hello, I'm TulipTask
What can I do for you today?

> todo Read a book
Okay! I have added this task:
[T][ ] Read a book
You currently have 1 task in your list.

## Feature ABC
> deadline Submit assignment /by Sunday
Okay! I have added this task:
[D][ ] Submit assignment (by: Sunday)
You currently have 2 tasks in your list.

> event Project meeting /from Monday 2pm /to Monday 4pm
Okay! I have added this task:
[E][ ] Project meeting (from: Monday 2pm to: Monday 4pm)
You currently have 3 tasks in your list.

> list
Here are your current tasks:
1. [T][ ] Read a book
2. [D][ ] Submit assignment (by: Sunday)
3. [E][ ] Project meeting (from: Monday 2pm to: Monday 4pm)

> mark 1
Great job! I have marked this task as done:
[T][X] Read a book

> find assignment
Here are the matching tasks in your list:
[D][ ] Submit assignment (by: Sunday)

> bye
Bye! Hope to see you again soon :)
```

// Feature details
---

## Future Enhancements

## Feature XYZ
- **Task Editing**: Add functionality to modify existing tasks.
- **Recurring Tasks**: Implement support for tasks that repeat on a regular schedule.
- **Priority Levels**: Allow users to assign priority levels to tasks.

// Feature details
---
28 changes: 28 additions & 0 deletions src/main/java/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* The Deadline class represents a task that has a specific deadline.
* It extends the Task class by adding a due date (deadline) to the task.
*/
public class Deadline extends Task {
protected String by;

/**
* Constructs a Deadline task with a description and a deadline date.
*
* @param description The description of the task.
* @param by The deadline for the task.
*/
public Deadline(String description, String by) {
super(description);
this.by = by;
}

/**
* Returns a string representation of the deadline task.
* The format is [D] followed by the task description, status, and the deadline.
*
* @return A string in the format [D][status] description (by: deadline).
*/
public String toString() {
return String.format("[D]%s (by: %s)", super.toString(), this.by);
}
}
10 changes: 0 additions & 10 deletions src/main/java/Duke.java

This file was deleted.

31 changes: 31 additions & 0 deletions src/main/java/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* The Event class represents a task that occurs over a specific time period.
* It extends the Task class by adding a start time and an end time.
*/
public class Event extends Task {
protected String from;
protected String to;

/**
* Constructs an Event task with a description, start time, and end time.
*
* @param description The description of the event.
* @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);
this.from = from;
this.to = to;
}

/**
* Returns a string representation of the event task.
* The format is [E] followed by the task description, status, and the event's time period.
*
* @return A string in the format [E][status] description (from: start time to: end time).
*/
public String toString() {
return String.format("[E]%s (from: %s to: %s)", super.toString(), this.from, this.to);
}
}
58 changes: 58 additions & 0 deletions src/main/java/InputParser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import java.util.HashMap;

/**
* The InputParser class is responsible for parsing user input into commands and arguments.
* It takes a raw input string and splits it into meaningful components such as the command and its arguments.
*/
public class InputParser {
public static final String COMMAND = "command";
public static final String ARGUMENT = "argument";

/**
* Parses the user's input into a command and associated arguments.
* The first word in the input is considered the command, and the rest is treated as arguments.
* Arguments that start with "/" are treated as named arguments.
*
* @param input The raw input string from the user.
* @return A HashMap containing the parsed command and its arguments.
*/
public static HashMap<String, String> parseCommands(String input) {
HashMap<String, String> commandArguments = new HashMap<>();
String[] splitInput = input.split(" ");

// check if input is empty
if (splitInput.length == 0) {
commandArguments.put(InputParser.COMMAND, "");
return commandArguments;
}

// set first element as command
commandArguments.put(InputParser.COMMAND, splitInput[0]);

String argumentDescription = InputParser.ARGUMENT;
StringBuilder argument = new StringBuilder();

// parse remaining input
for (int i = 1; i < splitInput.length; i++) {
String arg = splitInput[i];

if (arg.startsWith("/")) {
if (!argumentDescription.isEmpty()) {
commandArguments.put(argumentDescription, argument.toString().strip());
}

argumentDescription = arg;
argument.setLength(0);
} else {
argument.append(" ").append(arg);
}
}

// add last argument
if (!argument.isEmpty()) {
commandArguments.put(argumentDescription, argument.toString().strip());
}

return commandArguments;
}
}
Loading