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
4 changes: 4 additions & 0 deletions data/duke.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
D | 1 | something | 2089-09-11
T | 0 | read 30 pages of Dune
D | 0 | submit ip | 2022-03-04
E | 0 | HI lecture | 12 pm
195 changes: 185 additions & 10 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,204 @@
# User Guide
_Duke_ is an application designed for managing to-do lists, optimized for use via a __Command Line Interface (CLI)__.

````
Hello from
____ _
| _ \ _ _| | _____
| | | | | | | |/ / _ \
| |_| | |_| | < __/
|____/ \__,_|_|\_\___|

____________________________________________________________
Hello! I'm Duke
What can I do for you?
____________________________________________________________

````

## Features

### Feature-ABC
### Adding a deadline

Description of the feature.
Adds a deadline to the list with the date by which the deadline is due.

### Feature-XYZ
### Adding an event

Description of the feature.
Adds an event and when it's happening to the list.

## Usage
### Adding a general to-do task

Adds a todo task with a description with no other information required.

### Delete an item from the list

Deletes a task from the main list.

### List all tasks

List all items present in the list on the screen, while indicating what kind of task it is, whether it is done or not and any other information attached to the specific kind of task.

### Search for items in the list

### `Keyword` - Describe action
Searches for tasks that match the search string, and displays.

Describe the action and its outcome.
### Mark an item as done

Indicates that the task is done and reflects it when the tasks are printed on screen.

### Re-mark an item as not done yet

Un-marks the task and indicates it as not done again.

## Usage

### `todo` - add a to-do task

Example of usage:

`keyword (optional arguments)`
`todo read 30 pages of Dune`

Expected outcome:

```
____________________________________________________________
Got it. I've added this task:
[T][ ] read 30 pages of Dune
Now you have 3 tasks in the list.
____________________________________________________________
```
The output message shows that the task is added, and prints out the number of tasks that are now present in the list.

### `deadline` - add a deadline task

Takes a deadline's description and the due date in `yyyy-mm-dd` format, and adds the deadline to the list.

Example of usage:

`deadline submit ip /by 2022-03-04`

Expected outcome:

```
____________________________________________________________
Got it. I've added this task:
[D][ ] submit ip (by: Mar 4 2022)
Now you have 4 tasks in the list.
____________________________________________________________
```
The output shows that the deadline is added, and prints out the number of tasks that are now present in the list.

### `event` - add an event task

Takes an event's description and when the event is taking place using the `/at` keyword, and adds the event to the list.

Example of usage:

`event HI lecture /at 12 pm`

Expected outcome:

```
____________________________________________________________
Got it. I've added this task:
[D][ ] HI lecture (at: 12 pm)
Now you have 5 tasks in the list.
____________________________________________________________
```
The output shows that the event is added, and prints out the number of tasks that are now present in the list.

### `list` - display all items

Example of usage:

`list`

Expected outcome:

```
____________________________________________________________
1.[D][X] something (by: Sep 11 2089)
2.[T][ ] sljf
3.[T][ ] read 30 pages of Dune
4.[D][ ] submit ip (by: Mar 4 2022)
5.[D][ ] HI lecture (at: 12 pm)
____________________________________________________________
```
The output shows all the tasks currently in the program, and shows the kind of task it is and whether it is done or not.

- `[X]` indicates done and `[ ]` indicates not done.
- `[D]` indicates that the task is a deadline, `[E]` indicates events, and `[T]` indicates to-do tasks


### `mark` - mark an task as done

Marks a task using the task number.

Example of usage:

`mark 4`

Expected outcome:

```
____________________________________________________________
Nice! I've marked this task as done:
[D][X] submit ip (by: Mar 4 2022)
____________________________________________________________
```
The output shows that the task is marked as done and indicates it when the task is printed.

### `umark` - unmark a task as not done yet

Un-marks a task using the task number.

Example of usage:

`unmark 4`

Expected outcome:

```
____________________________________________________________
OK, I've marked this task as not done yet:
[D][ ] submit ip (by: Mar 4 2022)
____________________________________________________________
```
The output shows that the task is marked as done and indicates it when the task is printed.

### `delete` - deletes a task

Deletes a task using the task number.

Example of usage:

`delete 2`

Expected outcome:

Description of the outcome.
```
____________________________________________________________
Got it. I've removed this task:
[T][ ] sljf
Now you have 4 tasks in the list.
____________________________________________________________
```
The output shows that the task is removed from the list and indicates the remaining number of tasks.

### `find` - searches in the list

Searches inside the list by looking for the search string in the descriptions of all tasks.

Example of usage:

`find Dune`

Expected outcome:

```
expected output
____________________________________________________________
Here are the matching tasks in your list:
2.[T][ ] read 30 pages of Dune
____________________________________________________________
```

1 change: 1 addition & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
theme: jekyll-theme-minimal
10 changes: 0 additions & 10 deletions src/main/java/Duke.java

This file was deleted.

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: duke.Duke

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

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

public class Deadline extends Todo {
protected LocalDate by;
public String taskKind;

public Deadline(String description, LocalDate by) {
super(description);
this.by = by;
this.taskKind = "[D]";
}

@Override
public String toString(){
String indicator;
if (this.isDone){
indicator = "[X]";
} else indicator = "[ ]";
String message = "[D]" + indicator + description
+ " (by: " + getBy() + ")";
return message;
}
public void setBy(String by) {
this.by = LocalDate.parse(by);
}

public String getBy() {
return by.format(DateTimeFormatter.ofPattern("MMM d yyyy"));
}
}
21 changes: 21 additions & 0 deletions src/main/java/duke/Duke.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package duke;

import java.io.IOException;

/**
* Starts the program.
*/
public class Duke {

final static String FILE_NAME = "/Users/aimanimtiaz/software-engineering/ip/data/duke.txt";

/**
* Runs the main duke program using the Runner class.
*
* @param args arguments to run the program, can be left empty
* @throws IOException exception could be thrown if reading or writing from a file is not successful
*/
public static void main(String[] args) throws IOException {
Runner.run();
}
}
3 changes: 3 additions & 0 deletions src/main/java/duke/DukeIllegalDescription.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package duke;
public class DukeIllegalDescription extends Exception {
}
3 changes: 3 additions & 0 deletions src/main/java/duke/DukeIllegalKeyword.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package duke;
public class DukeIllegalKeyword extends Exception {
}
29 changes: 29 additions & 0 deletions src/main/java/duke/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package duke;

public class Event extends Todo {
public String taskKind;
protected String at;

public Event(String description, String at) {
super(description);
this.at = at;
this.taskKind = "[E]";
}

@Override
public String toString(){
String indicator;
if (this.isDone){
indicator = "[X]";
} else indicator = "[ ]";
String message = "[D]" + indicator + description
+ " (at: " + at + ")";
return message;
}
public void setAt(String at) {
this.at = at;
}
public String getAt() {
return at;
}
}
65 changes: 65 additions & 0 deletions src/main/java/duke/FileAccess.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package duke;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

/**
* Provides methods for storing to and loading from the storage file.
*/
public class FileAccess {

/**
* Reads all the existing tasks from a text file and adds them to the TaskList.
*
* @throws FileNotFoundException exception if the file does not exist
* @see Parser
* @see TaskList
*/
private static void readFromFile() throws FileNotFoundException {
File f = new File(Duke.FILE_NAME); // create a File for the given file path
Scanner s = new Scanner(f); // create a Scanner using the File as the source
while (s.hasNext()) {
Task task = Parser.lineToTask(s.nextLine());
TaskList.taskList.add(task);
}
}

/**
* Saves the entire TaskList to the given text file/
*
* @throws IOException exception if file cannot be written to
* @see Parser
* @see TaskList
*/
public static void saveToFile() throws IOException {
FileWriter fw = new FileWriter(Duke.FILE_NAME);
String line;
try {
for (Task task: TaskList.taskList){
line = Parser.taskToLine(task);
fw.write(line + System.lineSeparator());
}
fw.close();
} catch (IOException e) {
System.out.println("Something went wrong: " + e.getMessage());
}
}

/**
* Tries to read from file and prints a message if the file does not exist.
*/
public static void loadFromFile(){
try {
readFromFile();
} catch (FileNotFoundException e) {
System.out.println("File not found");
}
}




}
Loading