Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
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 data/AMY.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
T | 0 | bye
T | 1 | helloo
180 changes: 167 additions & 13 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,183 @@
# User Guide
# AMY User Guide

AMY is a text based Java app for managing your daily
tasks. Given below is the features list and your user guide.

## Features

### Feature-ABC
Here is your features list:

+ **todo**, **event**,
+ **deadline**, **mark**,
+ **unmark**, **delete**,
+ **find**, **list**, **bye**

Users can use these features to handle their tasks

### ToDo

Adds a new task to do in the task list.

#### Usage

**Format**: todo [task]

**Examples**

+ `todo finish my homework`

**Expected Output**:

Description of the feature.
```
+ Got it. I've added this task:
+ [T][ ] [finish my homework]
```

### Deadline

Adds a new task with deadline to do in the task list.

#### Usage

### Feature-XYZ
**Format**: deadline [task] /by [deadline]

**Example**

+ `deadline finish my homework /by Sunday`

**Expected Output**:

```
+ Got it. I've added this task: <br>
+ [D][ ] [finish my homework] (by: [Sunday])
```

### Event

Adds a new Event to the task list.

#### Usage

**Format**: event [task] /from [start] /to [end]

**Example**

+`finish homework /from 12:00 /to 18:00`

**Expected Output**:

```
+ Got it. I've added this task:
+ [E][ ] [finish homework] (from: [12:00] to: [18:00])
```

### List

Lists all tasks in the task list.

#### Usage

**Format**: list

**Expected Output**:

```
1. [D][ ] [task] (by: [Deadline])
2. [T][ ] [task]
```

Description of the feature.
### Mark Task

Mark the task as done in the task list.

#### Usage

**Format**: mark [TASK INDEX]

**Example**

+ `mark 1`

**Expected Output**:

```
+ Nice! I've marked this task as done:
+ [T][X] [finish homework]
```
### Unmark

Mark the task as not done in the task list.

#### Usage

**Format**: unmark [index]

**Example**

+ ```unmark 1```

**Expected Output**:

```
+ Nice! I've marked this task as not done.
+ [T][ ] [task]
```

### Delete Task

Delete a task from the task list.

#### Usage

**Format**: delete [index]

**Example**

+ ```delete 2```

**Expected Output**:

```
Noted. I've removed this task:
[task]
Now you have [#] tasks in your list.
```

### Find Task

Find tasks from the task list using either description or timing.

#### Usage

**Format**: find [keyword]

**Example**

+ ```find /description exam```
+ ```find /time 21-04-2021 14:30```

**Expected Output**:

```
Here are the matching tasks in your list:
+ [index]. [task]
+ [index]. [task]
```

## Usage
### bye

### `Keyword` - Describe action
Exit from the application.

Describe the action and its outcome.
#### Usage

Example of usage:
**Format**: bye

`keyword (optional arguments)`
**Example**

Expected outcome:
+ ```bye```

Description of the outcome.
**Expected Output**:

```
expected output
+ Bye. Hope to see you again soon!
```
19 changes: 19 additions & 0 deletions src/main/java/AMY/AMY.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package AMY;

public class AMY {

/**
* Runs the whole program when prompted by the main
*/
public static void run() {
Ui.welcomeMessage();
Storage.loadTasksFromFile();
Parser.manageInput();
Storage.saveTasksToFile();
Ui.byMessage();
}

public static void main(String[] args) {
run();
}
}
4 changes: 4 additions & 0 deletions src/main/java/AMY/Exceptions/EmptyDeadlineException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package AMY.Exceptions;

public class EmptyDeadlineException extends Exception{
}
4 changes: 4 additions & 0 deletions src/main/java/AMY/Exceptions/EmptyDeleteException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package AMY.Exceptions;

public class EmptyDeleteException extends Exception{
}
4 changes: 4 additions & 0 deletions src/main/java/AMY/Exceptions/EmptyEventException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package AMY.Exceptions;

public class EmptyEventException extends Exception {
}
4 changes: 4 additions & 0 deletions src/main/java/AMY/Exceptions/EmptyFindException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package AMY.Exceptions;

public class EmptyFindException extends Exception {
}
4 changes: 4 additions & 0 deletions src/main/java/AMY/Exceptions/EmptyInput.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package AMY.Exceptions;

public class EmptyInput extends Exception {
}
4 changes: 4 additions & 0 deletions src/main/java/AMY/Exceptions/EmptyMarkException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package AMY.Exceptions;

public class EmptyMarkException extends Exception{
}
4 changes: 4 additions & 0 deletions src/main/java/AMY/Exceptions/EmptyToDoException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package AMY.Exceptions;

public class EmptyToDoException extends Exception {
}
4 changes: 4 additions & 0 deletions src/main/java/AMY/Exceptions/EmptyUnmarkException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package AMY.Exceptions;

public class EmptyUnmarkException extends Exception {
}
139 changes: 139 additions & 0 deletions src/main/java/AMY/Parser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
package AMY;

import AMY.Exceptions.EmptyDeadlineException;
import AMY.Exceptions.EmptyDeleteException;
import AMY.Exceptions.EmptyEventException;
import AMY.Exceptions.EmptyInput;
import AMY.Exceptions.EmptyMarkException;
import AMY.Exceptions.EmptyToDoException;
import AMY.Exceptions.EmptyUnmarkException;
import AMY.Exceptions.EmptyFindException;

import AMY.command.Deadline;
import AMY.command.Event;
import AMY.command.Todo;

import java.util.Scanner;

public class Parser {

public static final String LINE = "____________________________________________________________";

public static void drawLine() {
System.out.println(LINE);
}

/**
* Throw exceptions when exceptions are encountered to avoid an error
* @param userInput the user input
* @throws EmptyInput when the input is empty, the exception is thrown
* @throws EmptyToDoException when the todo command is empty, the exception is thrown
* @throws EmptyMarkException when the mark is command empty, the exception is thrown
* @throws EmptyUnmarkException when the unmark command is empty, the exception is thrown
* @throws EmptyDeadlineException when the deadline command is empty, the exception is thrown
* @throws EmptyEventException when the event command is empty, the exception is thrown
* @throws EmptyDeleteException when the delete command is empty, the exception is thrown
*/
public static void manageException(String userInput) throws EmptyInput, EmptyToDoException,
EmptyMarkException, EmptyUnmarkException, EmptyDeadlineException, EmptyEventException,
EmptyDeleteException, EmptyFindException {

Scanner input = new Scanner(userInput);
String command;
if (!input.hasNext()) {
throw new EmptyInput();
} else {
command = input.next();
}
if (command.equals("todo") && !input.hasNext()) {
throw new EmptyToDoException();
}
if (command.equals("mark") && !input.hasNext()) {
throw new EmptyMarkException();
}
if (command.equals("unmark") && !input.hasNext()) {
throw new EmptyUnmarkException();
}
if (command.equals("deadline") && !input.hasNext()) {
throw new EmptyDeadlineException();
}
if (command.equals("event") && !input.hasNext()) {
throw new EmptyEventException();
}
if (command.equals("delete") && !input.hasNext()) {
throw new EmptyDeleteException();
}
if (command.equals("find") && !input.hasNext()) {
throw new EmptyFindException();
}
}

/**
* Manage input when input is given to follow order
*/
public static void manageInput() {
Scanner scanner = new Scanner(System.in);
while (true) {
String userInput = scanner.nextLine(); // Read user input
System.out.println(LINE);
try {
manageException(userInput);
if (userInput.equals("bye")) {
break; // Exit the loop if the user enters "bye"
} else if (userInput.equals("list")) {
TaskList.listTasks(); // list tasks
} else if (userInput.startsWith("mark")) {
// Extract the task index from the user input
int taskIndex = Integer.parseInt(userInput.substring(5).trim());
TaskList.markTaskAsDone(taskIndex);
} else if (userInput.startsWith("unmark")) {
// Extract the task index from the user input
int taskIndex = Integer.parseInt(userInput.substring(7).trim());
TaskList.unmarkTask(taskIndex);
} else if (userInput.startsWith("todo")) {
String description = userInput.substring(5).trim();
Todo todo = new Todo(description);
TaskList.addToList(todo);
} else if (userInput.startsWith("deadline")) {
int inputIndex = userInput.indexOf(" /by ");
String description = userInput.substring("deadline ".length(), inputIndex);
String by = userInput.substring(inputIndex + " /by ".length());
TaskList.addToList(new Deadline(description, by));
} else if (userInput.startsWith("event")) {
String[] parts = userInput.substring(5).split("/from");
String description = parts[0].trim();
String[] dateTimeParts = parts[1].split("/to");
String from = dateTimeParts[0].trim();
String to = dateTimeParts[1].trim();
Event event = new Event(description, from, to);
TaskList.addToList(event);
} else if (userInput.startsWith("delete")) {
int taskIndex = Integer.parseInt(userInput.substring(7).trim());
TaskList.deleteTask(taskIndex);
} else if (userInput.startsWith("find")) {
String keyword = userInput.substring(5).trim();
TaskList.findTasks(keyword);
}else {
System.out.println("Invalid command. Please try again.");
}
} catch (EmptyInput exception) {
System.out.println("☹ OOPS!!! The description cannot be empty.");
} catch (EmptyToDoException exception) {
System.out.println("☹ OOPS!!! The description of a todo cannot be empty.");
} catch (EmptyMarkException exception) {
System.out.println("☹ OOPS!!! The description of a mark cannot be empty.");
} catch (EmptyUnmarkException exception) {
System.out.println("☹ OOPS!!! The description of an unmark cannot be empty.");
} catch (EmptyDeadlineException exception) {
System.out.println("☹ OOPS!!! The description of a deadline cannot be empty.");
} catch (EmptyEventException exception) {
System.out.println("☹ OOPS!!! The description of an event cannot be empty.");
} catch (EmptyDeleteException exception) {
System.out.println("☹ OOPS!!! The description of an delete cannot be empty.");
} catch (EmptyFindException exception){
System.out.println("☹ OOPS!!! The description of an find cannot be empty.");
}
drawLine();
}
}
}
Loading