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
141 changes: 127 additions & 14 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,142 @@
# User Guide
# User Guide of Elvin

## Features
This is Elvin, the best personal task management system you will ever use!

### Feature-ABC
## Quick Start

Description of the feature.
1. Ensure that you have `Java 11` installed on your laptop or computer.
2. Download the latest version of the JAR file.
3. Move the file to a folder that you want to use for the application
4. Open up CLI and traverse until you reach your app folder.
5. Type in `java -jar "Elvin.jar"`.
6. The app will create a data folder and text file and it will close again.

### Feature-XYZ
## Features

Description of the feature.
### Add Todo : `todo`

## Usage
Add a todo task to the the list of tasks.

### `Keyword` - Describe action
**Format:** `todo DESCRIPTION`

Describe the action and its outcome.
Example:

Example of usage:
```
todo borrow book
```


### Add Deadline : `deadline`

Add a deadline task to the list of task with specific deadline.

**Format:** `deadline DESCRIPTION /by DEADLINE`


Example:

```
deadline homework /by Sunday
```


### Add Event : `event`

Add a event task to the list of task with a time period marked by from and to.

**Format:** `event DESCRIPTION /from START /to END`

Example:

```
event midterm exam /from 15:00 /to 17:00
```


### Delete Task : `delete`

Delete task from list of task based on index.

**Format:** `delete INDEX`

Example:

```
delete 2
```


### List Task : `list`

List all tasks in the list of tasks.

**Format:** `list`

Example:

`keyword (optional arguments)`
```
list
```


### Mark Task : `mark`

Mark a task as done based on index.

**Format:** `mark INDEX`

Example:

```
mark 2
```


### Unmark Task : `unmark`

Unmark a task as done based on index.

**Format:** `unmark INDEX`

Example:

```
unmark 5
```


### Find Task : `find`

List all tasks that contains the given string

**Format:** `find DESCRIPTION`

Example:

```
find book
```

### EXIT : `bye`

Exit the app

Expected outcome:
**Format:** `bye`

Description of the outcome.

Example:

```
expected output
bye
```

### Save Data
The data is saved in the hard disk automatically after any command that changes the data. There is no need to save manually.

### Edit Data
The data is edited in the hard disk automatically after any command that changes the data.
If you want to edit the data manually, you can use the app to edit it.

## FAQ
Q: How do I transfer my data to another Computer?
A: Install the app in the other computer and overwrite the empty data file it creates with the file that contains the data of your previous Elvin folder with same relative location.
33 changes: 33 additions & 0 deletions src/main/java/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
public class Deadline extends Task {
protected String by;

public Deadline(String description, String by) throws DukeException {
super(description);
if(!by.contains("by ")) {
throw new DukeException("☹ OOPS!!! The description of a deadline must contain \"by\" time.");
}else if(by.replace("by ", "").isBlank()) {
throw new DukeException("☹ OOPS!!! The time of a deadline cannot be empty.");
}
this.by = by.replace("by ", "");
}

/**
* Converts the Deadline object into a string.
*
* @return String format of the object.
*/
@Override
public String toString() {
return "[D]" + super.toString() + " (by: " + by + ")";
}

/**
* Converts the object into a string to be stored in file.
*
* @return String format of the object to be stored in file.
*/
@Override
public String toFile() {
return "D | " + super.toFile() + " | " + this.by;
}
}
10 changes: 0 additions & 10 deletions src/main/java/Duke.java

This file was deleted.

9 changes: 9 additions & 0 deletions src/main/java/DukeException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
public class DukeException extends Exception {
protected String LINE = "_______________________________________________";
public DukeException(String message) {
super(message);
System.out.println(LINE);
System.out.println(message);
System.out.println(LINE);
}
}
90 changes: 90 additions & 0 deletions src/main/java/Elvin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import java.util.ArrayList;
import java.util.Scanner;

public class Elvin {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
TaskList tasks = new TaskList();
Storage storage = new Storage();
Ui ui = new Ui();
Parser parser = new Parser();
storage.readFromFile(tasks);
ui.printGreet();
while(true) {
String input = scanner.nextLine();
ArrayList<String> parsedInput;
try {
parsedInput = parser.parse(input);
} catch(DukeException e) {
continue;
}
if(parsedInput.get(0).equals("bye")) {
break;
} else if(parsedInput.get(0).equals("list")) {
ui.printList(tasks);
} else if(parsedInput.get(0).equals("mark")) {
int index = Integer.parseInt(parsedInput.get(1));
try {
tasks.markTask(index);
storage.writeToFile(tasks);
ui.printMark(tasks.get(index));
} catch(IndexOutOfBoundsException e) {
ui.print("☹ OOPS!!! The index is out of bound.");
}
} else if(parsedInput.get(0).equals("unmark")) {
int index = Integer.parseInt(parsedInput.get(1));
try {
tasks.unmarkTask(index);
storage.writeToFile(tasks);
ui.printUnmark(tasks.get(index));
} catch(IndexOutOfBoundsException e) {
ui.print("☹ OOPS!!! The index is out of bound.");
}
} else if(parsedInput.get(0).equals("todo")) {
Todo todo;
try {
todo = new Todo(parsedInput.get(1));
} catch(DukeException e) {
continue;
}
tasks.addTask(todo);
storage.writeToFile(tasks);
ui.printAddition(todo, tasks.size());
} else if(parsedInput.get(0).equals("deadline")) {
Deadline deadline;
try {
deadline = new Deadline(parsedInput.get(1), parsedInput.get(2));
} catch (DukeException e) {
continue;
}
tasks.addTask(deadline);
storage.writeToFile(tasks);
ui.printAddition(deadline, tasks.size());
} else if(parsedInput.get(0).equals("event")) {
Event event;
try {
event = new Event(parsedInput.get(1), parsedInput.get(2), parsedInput.get(3));
} catch(DukeException e) {
continue;
}
tasks.addTask(event);
storage.writeToFile(tasks);
ui.printAddition(event, tasks.size());
} else if(parsedInput.get(0).equals("delete")) {
int index = Integer.parseInt(parsedInput.get(1));
try {
ui.printDeletion(tasks.get(index), tasks.size()-1);
tasks.deleteTask(index);
storage.writeToFile(tasks);
} catch(IndexOutOfBoundsException e) {
ui.print("☹ OOPS!!! The index is out of bound.");
}
} else if(parsedInput.get(0).equals("find")) {
TaskList temp = tasks.find(parsedInput.get(1));
ui.printFoundTasks(temp);
}
}
scanner.close();
ui.printExit();
}
}
38 changes: 38 additions & 0 deletions src/main/java/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
public class Event extends Task {
protected String by;
protected String from;
public Event(String description, String from, String by) throws DukeException {
super(description);
if(!from.contains("from ")) {
throw new DukeException("☹ OOPS!!! The description of a event must contain \"from\" time.");
} else if(!by.contains("to ")) {
throw new DukeException("☹ OOPS!!! The description of a event must contain \"to\" time.");
} else if(from.replace("from ", "").isBlank()){
throw new DukeException("☹ OOPS!!! The start time of a event cannot be empty.");
} else if(by.replace("to ", "").isBlank()) {
throw new DukeException("☹ OOPS!!! The end time of a event cannot be empty.");
}
this.from = from.replace("from ", "");
this.by = by.replace("to ", "");
}

/**
* Converts the Deadline object into a string.
*
* @return String format of the object.
*/
@Override
public String toString() {
return "[E]" + super.toString() + " (from: " + this.from + " to: " + this.by + ")";
}

/**
* Converts the object into a string to be stored in file.
*
* @return String format of the object to be stored in file.
*/
@Override
public String toFile() {
return "E | " + super.toFile() + " | " + this.from + " | " + this.by;
}
}
Loading