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
3d64ed6
Implement an initial skeletal version of the Duke that simply greets …
yapitsmejs Aug 22, 2021
daaef83
Implement a skeletal version of Duke that starts by greeting the user…
yapitsmejs Aug 22, 2021
4014037
Add the ability to store whatever text entered by the user and displa…
yapitsmejs Aug 23, 2021
a81bc62
Add the ability to mark tasks as done.
yapitsmejs Aug 23, 2021
cd250ac
Separate Task and Information classes
yapitsmejs Aug 26, 2021
aee5770
Add support for tracking three types of tasks. Change program persona…
yapitsmejs Sep 1, 2021
7bdb999
Correct spacing in response message. update ui-test input and expecte…
yapitsmejs Sep 1, 2021
b2ef7be
Teach Jarvis to deal with errors such as incorrect inputs entered by …
yapitsmejs Sep 6, 2021
d8af22f
Revert "Teach Jarvis to deal with errors such as incorrect inputs ent…
yapitsmejs Sep 6, 2021
b937e10
Teach Duke to deal with errors such as incorrect inputs entered by th…
yapitsmejs Sep 8, 2021
b1afac4
Merge branch 'branch-Level-5'
yapitsmejs Sep 8, 2021
f083420
Add support for deleting tasks from the list.
yapitsmejs Sep 15, 2021
3477bc0
Save the tasks in the hard disk automatically whenever the task list …
yapitsmejs Sep 16, 2021
2aca76a
Merge branch 'branch-Level-6'
yapitsmejs Sep 16, 2021
c729df8
Merge branch 'branch-Level-7'
yapitsmejs Sep 16, 2021
e0aa491
Resolved merge conflicts
yapitsmejs Sep 16, 2021
3a2629b
Give users a way to find a task by searching for a keyword. Refactor …
yapitsmejs Sep 27, 2021
123b746
Merge branch 'branch-Level-9'
yapitsmejs Sep 27, 2021
6e3a937
Add JavaDoc comments to the code.
yapitsmejs Sep 27, 2021
d4638a8
Merge branch 'branch-A-JavaDoc'
yapitsmejs Sep 27, 2021
4160b4a
Clean up Code. Fix bugs. Updated README.
yapitsmejs Sep 28, 2021
e4cb511
Update README.
yapitsmejs Sep 28, 2021
aae0f49
Update README
yapitsmejs Sep 28, 2021
dc02a7c
Update README
yapitsmejs Sep 28, 2021
c9c6b35
Update README
yapitsmejs Sep 28, 2021
43757a3
Update README
yapitsmejs Sep 28, 2021
685cadf
Fixed bugs. Fixed coding standards.
yapitsmejs Sep 28, 2021
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
Empty file added data/duke.txt
Empty file.
136 changes: 121 additions & 15 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,135 @@
# User Guide

## Features
Duke is a **desktop app for managing your tasks, optimized for use via a Command Line Interface** (CLI). If you can type
fast, Duke can get your task management done faster than traditional GUI apps. It is the perfect app for busy people!

### Feature-ABC
1. Features
1. Adding a todo: `todo`
2. Adding an event: `event`
3. Adding a deadline: `deadline`
4. List all tasks: `list`
5. Marking a task as done: `done`
6. Deleting a task: `delete`
7. Finding a task with a keyword: `find`
2. Command Summary

Description of the feature.
## Features

### Feature-XYZ

Description of the feature.
**Command format:**

## Usage

### `Keyword` - Describe action
* Words in `UPPER_CASE` are the parameters to be supplied by the user. (eg. `todo` `TASK_DESCRIPTION`, `TASK_DESCRIPTION` is
the description of the
task supplied by the user.)
* Extraneous parameters for commands that do not take in parameters (such as `list` and `bye`) is not acceptable.
e.g. if the command specifies `list 123`, there will be an error.

Describe the action and its outcome.

Example of usage:
**Adding a todo**

`keyword (optional arguments)`

Expected outcome:
Adds a todo to your list of tasks.

Description of the outcome.
format: `todo TASK_DESCRIPTION`

```
expected output
```
Example input:

`todo lunch`

`todo deliver parcel`


**Adding an Event**


Adds an event to your list of tasks.

format: `event TASK_DESCRIPTION /at TIME_DESCRIPTION`

Example input:

`event family dinner /at sunday`

`event concert /at friday night`


**Adding a Deadline**


Adds a deadline to your list of tasks.

format: `deadline TASK_DESCRIPTION /by TIME_DESCRIPTION`

Example input:

`deadline assignment /by sunday night`

`deadline complete report /by monday`


**Listing Tasks**


Shows a list of all tasks.

Format: `list`


**Mark Task as Done**


Marks the task with the corresponding number in the list as done.

Format: `done TASK_NUMBER`

Example input:

`done 1`


**Delete Task**


Deletes the task with the corresponding number in the list.

Format: `delete TASK_NUMBER`

Example input:

`delete 1`


**Find Task**


Finds all tasks containing user input keyword in their descriptions

Format: `find KEYWORD`

Example input:

`find lunch`


**Bye**


Exits the program.

Format: `bye`


## Command Summary


Action | Format, Examples
------ | ----------------
todo | `todo TASK_DESCRIPTION` eg. `todo deliver parcel`
event | `event TASK_DESCRIPTION /at TIME_DESCRIPTION` eg. `event concert /at friday night`
deadline | `deadline TASK_DESCRIPTION /by TIME_DESCRIPTION` eg. `deadline assignment /by sunday night`
list | `list`
done | `done TASK_NUMBER` eg. `done 1`
delete | `delete TASK_NUMBER` eg. `delete 1`
find | `find KEYWORD` eg. `find lunch`
bye | `bye`
26 changes: 26 additions & 0 deletions src/main/java/AddTask.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import java.io.IOException;

public class AddTask extends Command{
private Task task;
private Tasks tasks;
private Ui ui;
private Storage storage;
/**
* Constructor for command for user to add a new task. Task can be either a normal task, an Event or a Deadline
* @param tasks list of existing tasks for task to be added to
* @param task Task to be added. Either be a normal task, an Event or a Deadline
* @param ui Handles interaction with the user
* @param storage updates "data/duke.txt"
*/
public AddTask(Tasks tasks, Task task, Ui ui, Storage storage) {
this.tasks = tasks;
this.task = task;
this.ui = ui;
this.storage = storage;
}
public void execute() throws IOException {
tasks.add(task);
ui.add(task, tasks);
storage.writeToFile(tasks);
}
}
15 changes: 15 additions & 0 deletions src/main/java/Bye.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
public class Bye extends Command {
private Ui ui;

/**
* Constructor when user wants to close the application.
* @param ui Handles interaction with the user.
*/
public Bye(Ui ui) {
this.ui = ui;
}
public boolean isExit() {
ui.exit();
return true;
}
}
13 changes: 13 additions & 0 deletions src/main/java/Command.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import java.io.IOException;

/**
* Represents a command made by the user.
*/
public abstract class Command {
public void execute() throws IOException {

}
public boolean isExit() {
return false;
}
}
30 changes: 30 additions & 0 deletions src/main/java/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
public class Deadline extends Task{
protected String by;

/**
* Represents a Deadline added by the user.
*
* @param description Description of task with a deadline.
* @param by Description of the deadline of the task
*/
public Deadline(String description, String by) {
super(description);
this.by = by;
}

public String getTime() {
return this.by;
}

public void setBy(String by) {
this.by = by;
}

public String getType() {
return "D";
}

public String toString() {
return "[D]" + super.getStatus() + super.getDescription() + " (by:" + by + ")";
}
}
28 changes: 28 additions & 0 deletions src/main/java/Delete.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import java.io.IOException;

public class Delete extends Command{
private Tasks tasks;
private Task task;
private Ui ui;
private Storage storage;

/**
* Constructor for command for user to delete a task from the list.
* @param tasks list of all existing tasks
* @param index index of task to be deleted
* @param ui Handles interaction with user.
* @param storage updates "data/duke.txt" file
*/
public Delete(Tasks tasks, int index, Ui ui, Storage storage) {
this.tasks = tasks;
this.task = tasks.get(index);
this.ui = ui;
this.storage = storage;
}

public void execute() throws IOException {
ui.delete(task, tasks);
tasks.delete(task);
storage.writeToFile(tasks);
}
}
29 changes: 29 additions & 0 deletions src/main/java/Done.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import java.io.IOException;

public class Done extends Command {
private Tasks tasks;
private Task task;
private Ui ui;
private Storage storage;

/**
* Constructor for command when the user marks a task as done.
* @param tasks List of all existing tasks.
* @param index Index of task to be marked done
* @param ui Handles interaction with user.
* @param storage updates "data/duke.txt" file
*/
public Done(Tasks tasks, int index, Ui ui, Storage storage) {
tasks.get(index).markComplete();
this.tasks = tasks;
this.task = tasks.get(index);
this.ui = ui;
this.storage = storage;
}

public void execute() throws IOException {
ui.done(task, tasks);
task.markComplete();
storage.writeToFile(tasks);
}
}
57 changes: 50 additions & 7 deletions src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,53 @@
import java.util.Random;
import java.util.Scanner;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.FileNotFoundException;
import java.nio.file.Files;
import java.nio.file.Paths;

/**
* Duke is a friendly note-taking bot.
* Duke keeps track of all your tasks in a reader-friendly format,
* even after you close the application
*
* @author Yap Joon Siong
* @version 1.0
* Cool @since 2021-09-28
*/
public class Duke {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, you could consider adding more comments to describe what your methods or classes are doing.

public static void main(String[] args) {
String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
private static File save;
private Storage storage;
private Tasks tasks = new Tasks();
private Ui ui;

private Duke(String filePath) throws IOException {
ui = new Ui();
File directory = new File ("data");
if (!directory.exists()) {
directory.mkdir();
}
storage = new Storage(filePath);
tasks = storage.load();
}

private void run() throws IOException {
ui.greet();
boolean isExit = false;
while (!isExit) {
try {
String fullCommand = ui.readCommand();
Command c = Parser.parse(fullCommand, tasks, ui, storage);
c.execute();
isExit = c.isExit();
} catch (DukeException e) {
System.out.println(e.getMessage());
}
}
}

public static void main(String[] args) throws IOException {
new Duke("data/duke.txt").run();
}
}
5 changes: 5 additions & 0 deletions src/main/java/DukeException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public class DukeException extends Exception {
public DukeException(String message) {
super(message);
}
}
27 changes: 27 additions & 0 deletions src/main/java/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
public class Event extends Task{
protected String at;

/**
* Represents an Event made by the user.
*
* @param description Description of Event.
* @param at Description of when the event will take place.
*/
public Event (String description, String at) {
super(description);
this.at = at;
}

public void setAt(String at) {
this.at = at;
}
public String getTime() {
return this.at;
}
public String getType() {
return "E";
}
public String toString() {
return "[E]" + super.getStatus() + super.getDescription() + " (at:" + at + ")";
}
}
Loading