Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Edly Irsyad] iP #195

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2ca6058
Add Increment: Level-0
edlyIrsyad Aug 19, 2021
10ba1da
Add Level - 1
edlyIrsyad Aug 31, 2021
b90d4e3
Add Level-2
edlyIrsyad Aug 31, 2021
eca446a
Level-3
edlyIrsyad Aug 31, 2021
168beaa
Add A-CodingStandard
edlyIrsyad Aug 31, 2021
f4b4949
Add Level-4
edlyIrsyad Sep 2, 2021
5ac4a58
Add A-CodeQuality
edlyIrsyad Sep 2, 2021
5618bca
Add Level-5
edlyIrsyad Sep 7, 2021
5cbca39
Add A-Packages
edlyIrsyad Sep 7, 2021
a2306a9
Add A-Exceptions
edlyIrsyad Sep 7, 2021
72a0b53
Add Test Commit
edlyIrsyad Sep 7, 2021
54bcd53
Add Another Test Commit
edlyIrsyad Sep 7, 2021
5edf6d7
Merge branch 'branch-Level-5'
edlyIrsyad Sep 7, 2021
40728f4
Add Level-6
edlyIrsyad Sep 14, 2021
0957d93
Add A-Collections
edlyIrsyad Sep 14, 2021
c695218
Add Level-7
edlyIrsyad Sep 14, 2021
540ecd5
Add minor change
edlyIrsyad Sep 14, 2021
03ddc96
Merge branch 'branch-Level-6'
edlyIrsyad Sep 14, 2021
1bd6a31
Merge branch 'branch-Level-7'
edlyIrsyad Sep 14, 2021
705b2fb
Add A-Jar
edlyIrsyad Sep 16, 2021
e9ce696
Add A-MoreOOP
edlyIrsyad Sep 28, 2021
682547b
Add Level-9
edlyIrsyad Sep 28, 2021
ffcb230
Add A-JavaDoc
edlyIrsyad Sep 28, 2021
d89c914
Add A-UserGuide
edlyIrsyad Oct 1, 2021
40f25b2
Add branch-A-JavaDoc
edlyIrsyad Oct 1, 2021
9f2e73e
Add Ui updates
edlyIrsyad Oct 1, 2021
d9556fc
Merge pull request #1 from edlyIrsyad/branch-Level-9
edlyIrsyad Oct 1, 2021
6e8a540
Change Headings
edlyIrsyad Oct 5, 2021
79954e0
Change Task Details
edlyIrsyad Oct 5, 2021
23e3fb1
Set theme jekyll-theme-merlot
edlyIrsyad Oct 5, 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
7 changes: 7 additions & 0 deletions data/dukeData.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[T] [ ] list
[T] [ ] bathe
[T] [ ] bathe list
[T] [ ] math
[T] [ ] math test
[T] [ ] english test
[D] [ ] testing
155 changes: 141 additions & 14 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,156 @@
# User Guide

# Duke User Guide
Welcome to Duke, your very own command line task scheduler! In this user guide, you can find out how to use Duke.
## Features

### Feature-ABC
### Track your tasks!
- Add your tasks to our database
- Check tasks off when you've completed them
- Never miss another task ever!

### 3 different types of tasks
- Todo: Simple description, no deadline/ time
- Deadlines: Description with deadline to be completed by
- Events: Description with the date and time of the event

## List of commands

### 1. `todo` - Adds a Todo task to the database

- Briefly describe the Todo task after typing `todo`

#### Example of usage:

`todo clean kitchen`

#### Expected outcome:
```
Got it. I've added this task:
[T][ ] clean kitchen
Now you have 1 tasks in your list.
```
#### Description of the outcome.
- The first box shows that the task is of the Todo type, represented by a 'T'
- The next box is empty, showing that the task has not been completed yet
- If there is a cross 'X' in it, the task has been completed



Description of the feature.
### 2. `deadline` - Adds a Deadline task to the database
- Briefly describe the Deadline task after typing `deadline`
- Then type `/by`, followed by the deadline of the Deadline task

### Feature-XYZ
#### Example of usage:

Description of the feature.
`deadline finish assignment /by tonight`

#### Expected outcome:
```
Got it. I've added this task:
[D][ ] finish assignment by: tonight
Now you have 2 tasks in your list.
```
#### Description of the outcome.
- The first box shows that the task is of the Deadline type, represented by a 'D'
- The next box is empty, showing that the task has not been completed yet
- If there is a cross 'X' in it, that would mean that the task has been completed
- After the Deadline description, the deadline of the task will be displayed
- In this case, the deadline is tonight

## Usage

### `Keyword` - Describe action
### 3. `event` - Adds an Event task to the database
- Briefly describe the Event task after typing `event`
- Then type `/at`, followed by the date and time of the Event task

Describe the action and its outcome.
#### Example of usage:

`event CS2113T exam /at 31 Feb 2021`

#### Expected outcome:
```
Got it. I've added this task:
[E][ ] CS2113T exam at: 31 Feb 2021
Now you have 3 tasks in your list.
```
#### Description of the outcome.
- The first box shows that the task is of the Event type, represented by an 'E'
- The next box is empty, showing that the task has not been completed yet
- If there is a cross 'X' in it, that would mean that the task has been completed
- After the Event description, the date and time of the task will be displayed
- In this case, the date and time is 31 Feb 2021

Example of usage:

`keyword (optional arguments)`
### 4. `list` - Prints a list of all tasks that have been added

Expected outcome:
#### Example of usage:

Description of the outcome.
`list`

#### Expected outcome:
```
Here are the tasks in your list:
1. [T][ ] clean kitchen
2. [D][ ] finish assignment by: tonight
3. [E][ ] CS2113T exam at: 31 Feb 2021
```
expected output
#### Description of the outcome.
- The tasks that have been added are numbered sequentially


### 5. `done` - Indicate to Duke that you have completed a task
- After typing `done`, type the index of the task you have completed

#### Example of usage:

`done 1`

#### Expected outcome:
```
Nice! I've marked this task as done:
[T][X] clean kitchen
```
#### Description of the outcome.
- The second box will have an 'X' to indicate that it is checked



### 6. `find` - Prints all the tasks that match the keyword you give it
- After typing `find`, type the keyword of the tasks you are searching for
#### Example of usage:

`find finish`

#### Expected outcome:
```
Here are the matching tasks in your list:
1. [D][ ] finish assignment by: tonight
```
#### Description of the outcome.
- Since the word 'finish' appears in the above task, it will be displayed



### 7. `delete` - Removes a task from the database
- After typing `delete`, type the index of the task you want to delete
#### Example of usage:

`delete 1`

#### Expected outcome:
```
Noted. I've removed this task:
[T][X] clean kitchen
Now you have 2 tasks in the list.
```



### 8. `bye` - Exits Duke

#### Example of usage:

`bye`

#### Expected outcome:
```
Byebye! Hope to see you again soon!
```
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-merlot
21 changes: 21 additions & 0 deletions src/main/java/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Class inheriting from Task that has a description and deadline attribute
*/
public class Deadline extends Task{
protected String by;

public Deadline(String description, String by) {
super(description);
this.by = by.substring(by.indexOf(" ") + 1);
}

@Override
public String getDescription() {
return description + "(by: " + by + ")";
}

@Override
public String getSymbol() {
return "D"; // mark Deadlines with a "D"
Copy link

Choose a reason for hiding this comment

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

Consider removing the comment since the code is self-explanatory.

}
}
18 changes: 12 additions & 6 deletions src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
/**
* <h1>Track Your Tasks!</h1>
* * The Duke program keeps track of your tasks by categorising them
* * into ToDos, Deadlines and Events and giving you the tools to
* * organise them
* * <p>
* *
* * @author Edly Irsyad
* * @version 0.2
*/
public class Duke {
public static void main(String[] args) {
String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
Ui.welcome();
Parser.parse();
}
}
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 @@
/**
* Class representing the DukeException
*/
public class DukeException extends Exception{
}
21 changes: 21 additions & 0 deletions src/main/java/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Class inheriting from Task that has a description and date/time attribute
*/
public class Event extends Task{
protected String eventDateTime;

public Event(String description, String eventDateTime) {
super(description);
this.eventDateTime = eventDateTime.substring(eventDateTime.indexOf(" ") + 1);
}

@Override
public String getDescription() {
return description + "(at: " + eventDateTime + ")";
}

@Override
public String getSymbol() {
return "E"; // mark Events with an "E"
}
}
77 changes: 77 additions & 0 deletions src/main/java/Parser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import java.io.IOException;
import java.util.Scanner;

/**
* Continually parses through the user's commands then determines the next course of action by calling the appropriate class
*/
public class Parser {
public static void parse() {
String toBeWritten = null;
String dukeDataPath = "C:\\Users\\edly1\\Documents\\ip\\data\\dukeData.txt";
Scanner in = new Scanner(System.in);
boolean isContinueLoop = true;

while(isContinueLoop){
String userIn = in.nextLine();
String userCommand = userIn.contains(" ") ? userIn.substring(0, userIn.indexOf(" ")): userIn;
String userCommandDetails = userIn.contains(" ") ? userIn.substring(userIn.indexOf(" ") + 1): "invalid";

switch (userCommand) {
case "todo":
toBeWritten = TaskList.addToDo(userCommandDetails, toBeWritten);
try {
if (toBeWritten != null) {
Storage.writeToFile(dukeDataPath, toBeWritten + System.lineSeparator());
}
} catch (IOException e) {
System.out.println("Something went wrong: " + e.getMessage());
}
break;
case "deadline":
toBeWritten = TaskList.addDeadline(userCommandDetails, toBeWritten);
try {
if (toBeWritten != null) {
Storage.writeToFile(dukeDataPath, toBeWritten + System.lineSeparator());
}
} catch (IOException e) {
System.out.println("Something went wrong: " + e.getMessage());
}
break;
case "event":
toBeWritten = TaskList.addEvent(userCommandDetails, toBeWritten);
try {
if (toBeWritten != null) {
Storage.writeToFile(dukeDataPath, toBeWritten + System.lineSeparator());
}
} catch (IOException e) {
System.out.println("Something went wrong: " + e.getMessage());
}
break;

case "list":
TaskList.list();
break;

case "done":
TaskList.done(userIn);
break;

case "find":
TaskList.find(userCommandDetails);
break;

case "delete":
TaskList.delete(userIn);
break;

case "bye":
Ui.farewell();
isContinueLoop = false;
break;
default:
Ui.invalidCommand(userIn);
break;
}
}
}
}
19 changes: 19 additions & 0 deletions src/main/java/Storage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import java.io.FileWriter;
import java.io.IOException;

/**
* Saves tasks in the target file
*/
public class Storage {
/**
* Writes Task description and details into the file
*
* @param filePath Location of the target file to be written to with respect to the C-drive
* @param textToAdd Message to be written to the target file
*/
public static void writeToFile(String filePath, String textToAdd) throws IOException {
FileWriter fw = new FileWriter(filePath, true);
fw.write(textToAdd);
fw.close();
}
}
24 changes: 24 additions & 0 deletions src/main/java/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Abstract class representing the general structure of a Task
*/
public class Task {
protected String description;
protected boolean isDone;

public Task(String description) {
this.description = description;
this.isDone = false;
}

public String getDescription() {
return description;
}

public String getSymbol() {
return " "; // mark Tasks with a " "
}

public String getStatusIcon() {
return (isDone ? "X" : " "); // mark done task with X
}
}
Loading