Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
e1b96e2
add greeting
kktai1512 Jan 21, 2022
9a88290
refactored level_0
kktai1512 Jan 26, 2022
f35f63d
add greet echo exit, and abstracted out print with divider
kktai1512 Jan 26, 2022
ca00879
add list ability using arraylist
kktai1512 Jan 26, 2022
212f360
add toggle complete
kktai1512 Jan 26, 2022
47cce8f
add todo, deadline and event subclass (level 4)
kktai1512 Feb 2, 2022
85f8d73
add automated testing
kktai1512 Feb 2, 2022
bebd84d
abstract run function from main, clean up code, fix event toString typo
kktai1512 Feb 2, 2022
66cb637
abstract out task related things to TaskManager class
kktai1512 Feb 8, 2022
ff54efb
add error handling
kktai1512 Feb 9, 2022
1bfe6b6
add DukeException class
kktai1512 Feb 9, 2022
1da8e96
Merge branch 'branch-Level-5'
kktai1512 Feb 9, 2022
2e14be2
add to packages
kktai1512 Feb 9, 2022
38c3895
Merge branch 'add-package'
kktai1512 Feb 9, 2022
0a80df8
add delete task function
kktai1512 Feb 12, 2022
4732cce
add file writer and reader
kktai1512 Feb 15, 2022
676c634
complete filereader
kktai1512 Feb 16, 2022
76c50b1
merge level 7
kktai1512 Feb 16, 2022
63ce6a0
add more oop- parser, ui, command, storage
kktai1512 Mar 1, 2022
f64e5e9
change deadline of Deadline to by, time of Event to on
kktai1512 Mar 2, 2022
6fdb78a
add date/time
kktai1512 Mar 2, 2022
f304d13
add find functionality
kktai1512 Mar 2, 2022
318d046
add date and time
kktai1512 Mar 2, 2022
c9546db
Merge pull request #1 from kktai1512/branch-Level-8
kktai1512 Mar 2, 2022
4c0e6d8
merge from master
kktai1512 Mar 2, 2022
b6adc88
Merge pull request #2 from kktai1512/branch-Level-9
kktai1512 Mar 2, 2022
921bb7f
add javadoc for taskmanager and storage
kktai1512 Mar 2, 2022
550f812
Update README.md
kktai1512 Mar 2, 2022
04944b6
add more javadocs
kktai1512 Mar 3, 2022
b7d0ed6
change to autosave everytine tasks has changed
kktai1512 Mar 4, 2022
b1e1f7e
change such that task doesnt accept nameless / wrong name
kktai1512 Mar 4, 2022
52e2312
check for style
kktai1512 Mar 4, 2022
05026dc
check for style
kktai1512 Mar 4, 2022
d4a94ac
remove checkstyle
kktai1512 Mar 4, 2022
8579519
Merge pull request #3 from kktai1512/branch-A-JavaDoc
kktai1512 Mar 4, 2022
d6bef1e
allow non alphanumeric name, disallow / in taskName
kktai1512 Mar 4, 2022
424ec24
allow non alphanumeric name, disallow / in taskName
kktai1512 Mar 4, 2022
75b13f8
Update README.md
kktai1512 Mar 4, 2022
816230c
change readme.md
kktai1512 Mar 4, 2022
7ffb9af
change readme.md
kktai1512 Mar 4, 2022
b2c7657
Update README.md
kktai1512 Mar 4, 2022
c170780
Update README.md
kktai1512 Mar 4, 2022
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ bin/

/text-ui-test/ACTUAL.txt
text-ui-test/EXPECTED-UNIX.TXT

checkstyle.xml
2 changes: 2 additions & 0 deletions Duke.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1. [T][ ] `
2. [D][ ] ` (by: 99)
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ Prerequisites: JDK 11, update Intellij to the most recent version.

1. Open Intellij (if you are not in the welcome screen, click `File` > `Close Project` to close the existing project first)
1. Open the project into Intellij as follows:
1. Click `Open`.
1. Select the project directory, and click `OK`.
1. If there are any further prompts, accept the defaults.
1. Click `Open`.
1. Select the project directory, and click `OK`.
1. If there are any further prompts, accept the defaults.
1. Configure the project to use **JDK 11** (not other versions) as explained in [here](https://www.jetbrains.com/help/idea/sdk.html#set-up-jdk).<br>
In the same dialog, set the **Project language level** field to the `SDK default` option.
3. After that, locate the `src/main/java/Duke.java` file, right-click it, and choose `Run Duke.main()` (if the code editor is showing compile errors, try restarting the IDE). If the setup is correct, you should see something like the below as the output:
Expand All @@ -21,4 +21,4 @@ Prerequisites: JDK 11, update Intellij to the most recent version.
| | | | | | | |/ / _ \
| |_| | |_| | < __/
|____/ \__,_|_|\_\___|
```
```
144 changes: 128 additions & 16 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,141 @@
# User Guide

## Features

### Feature-ABC
# Welcome to Duke!
Duke is a CLI-based todo application.
# Getting started
After running the JAR file, an output file named "Duke.txt" will be created in the same directory of the JAR. Output will be saved into the file before the program exits, and the file will be reread the next time Duke runs.

Description of the feature.
To run the file, from the terminal, go to the same directory as your Duke.jar file, and run the command `java -jar Duke.jar`

### Feature-XYZ

Description of the feature.
# Features and usage
| Notation | Meaning |
|--|--|
| [T] | todo |
| [D] | deadline|
| [E] | event |
| [ ] | incomplete task
| [X] | completed task

## Usage

### `Keyword` - Describe action

Describe the action and its outcome.

Example of usage:
## Add
There are three types of tasks to be added. Namely, todo, deadline and event.
### Todo

`keyword (optional arguments)`
To add a todo, command should be typed in the format
`todo (taskname)`
Example of a valid input:
`todo get groceries`

Expected outcome:
Sample usage:

Description of the outcome.
todo buy groceries
____________________________________________________________
Got it. I've added this task:
[T][ ] buy groceries
Now you have 1 task in the list.
____________________________________________________________



### Event / Deadline

To add an event or a deadline, command should be typed in the format `event (taskname) /(dd-MM-yyyy HH:mm)` or
`event (taskname) /(additional info)`

:white_check_mark: Sample usage with valid input:


deadline cs2113t project /tomorrow
____________________________________________________________
Got it. I've added this task:
[D][ ] cs2113t project (by: tomorrow)
Now you have 2 tasks in the list.
____________________________________________________________
event Mark's birthday party /07-03-2022 22:00
____________________________________________________________
Got it. I've added this task:
[E][ ] Mark's birthday party (on: Mar 07 2022 22:00)
Now you have 3 tasks in the list.
____________________________________________________________



:x: Example of a invalid input:

deadline hello /
event /




## List
To list all the tasks, simply type
`list`


Sample usage:

list
____________________________________________________________
1. [T][ ] buy groceries
2. [D][ ] cs2113t project (by: tomorrow)
3. [E][ ] Mark's birthday party (on: Mar 07 2022 22:00)
____________________________________________________________

## Delete
To delete a task, type in the command `delete (task number)`

Sample usage:

delete 2
____________________________________________________________
Noted. I've removed this task:
[D][ ] cs2113t project (by: tomorrow)
Now you have 2 tasks in the list.
____________________________________________________________




## Mark/Unmark
To mark the task as completed, type in `mark (task number)`.
Similarly, type in `unmark (task number)` to mark the task as incomplete.

Sample usage:

mark 1
____________________________________________________________
[T][X] buy groceries
____________________________________________________________
unmark 1
____________________________________________________________
[T][ ] buy groceries
____________________________________________________________

## Find
To find task(s) containing a specific keyword, type in `find (keyword)`

Sample usage:

find groceries
____________________________________________________________
Here are the matching tasks in your list:
1. [T][ ] buy groceries
____________________________________________________________

## Bye
To exit the program, simply type "bye". The program terminates and the current state of the tasks is saved into "Duke.txt".

Sample usage:

bye
____________________________________________________________
Bye. Hope to see you again soon!
____________________________________________________________




```
expected output
```
64 changes: 57 additions & 7 deletions src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,60 @@
import java.io.IOException;

import duke.command.Command;
import duke.exception.DukeException;
import duke.parser.Parser;
import duke.storage.Storage;
import duke.task.TaskManager;
import duke.ui.Ui;

public class Duke {
public static void main(String[] args) {
String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);

//fields

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This comment is not very helpful in providing further explanation on how the variable is used. It can be omitted.

private TaskManager taskManager;
private Ui ui;
private Storage storage;

//methods

/**
* Creates a Duke Object
* @param filePath filePath of the input/output file
*/
public Duke(String filePath) {
ui = new Ui();
storage = new Storage(filePath);
try {
taskManager = new TaskManager();
taskManager.setTasks(storage.readFile());
} catch (DukeException e) {
ui.showError(e);
}
}

/**
* Runs the main function
*/
public void run() {
ui.hello();
boolean isExit = false;
while (!isExit) {
try {
String fullCommand = ui.readCommand();
Command c = Parser.parse(fullCommand);
if (c != null) {
c.execute(taskManager, ui, storage);
isExit = c.isExit();
}
} catch (DukeException e) {
ui.showError(e);
}
}

Ui.printWithDivider("Bye. Hope to see you again soon!");

}

public static void main(String[] args) throws IOException {
new Duke ("./Duke.txt").run();
}
}
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

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

import duke.exception.DukeException;
import duke.storage.Storage;
import duke.task.TaskManager;
import duke.ui.Ui;

public class AddCommand extends Command {

private String commandType;
private String taskName;
private String addInfo;

/**
* Command for "add" operations (add todo, event or deadline)
* @param commandType todo, event or deadline
* @param taskName name of task
* @param addInfo additional information
*/
public AddCommand(String commandType, String taskName, String addInfo) {
this.taskName = taskName;
this.commandType = commandType;
this.addInfo = addInfo;
}

@Override
public void execute(TaskManager taskManager, Ui ui, Storage storage) throws DukeException {
taskManager.addTask(this.commandType, this.taskName, this.addInfo);
storage.writeFile(taskManager.toString());
}
}
9 changes: 9 additions & 0 deletions src/main/java/duke/command/ByeCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package duke.command;

public class ByeCommand extends Command {

@Override
public boolean isExit() {
return true;
}
}
24 changes: 24 additions & 0 deletions src/main/java/duke/command/Command.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package duke.command;
import duke.exception.DukeException;
import duke.storage.Storage;
import duke.task.TaskManager;
import duke.ui.Ui;

public abstract class Command {

/**
* Executes the command
*
* @param taskManager TaskManager instance in charge of calling the correct method
* @param ui Ui instance in charge to print
* @param storage Storage instance for writing files
* @throws DukeException
*/
public void execute(TaskManager taskManager, Ui ui, Storage storage) throws DukeException {

}

public boolean isExit(){
return false;
}
}
21 changes: 21 additions & 0 deletions src/main/java/duke/command/DeleteCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package duke.command;

import duke.exception.DukeException;
import duke.storage.Storage;
import duke.task.TaskManager;
import duke.ui.Ui;

public class DeleteCommand extends Command {

private int taskNumber;
public DeleteCommand(int taskNumber) {
this.taskNumber = taskNumber;
}

@Override
public void execute(TaskManager taskManager, Ui ui, Storage storage) throws DukeException {
taskManager.deleteTask(this.taskNumber);
storage.writeFile(taskManager.toString());

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

import duke.storage.Storage;
import duke.task.TaskManager;
import duke.ui.Ui;

public class FindCommand extends Command {

private String keyword;


public FindCommand(String keyword) {
this.keyword = keyword;
}

@Override
public void execute(TaskManager taskManager, Ui ui, Storage storage) {
TaskManager relatedTaskManager = taskManager.findTask(this.keyword);
if (relatedTaskManager.getNumOfTasks() == 0) {
Ui.printWithDivider("Sorry, task(s) containing the word " + this.keyword +" not found.");
}
else {
Ui.printWithDivider( "Here are the matching tasks in your list: \n"
+ relatedTaskManager);
}

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

import duke.storage.Storage;
import duke.task.TaskManager;
import duke.ui.Ui;

public class ListCommand extends Command {

@Override
public void execute(TaskManager taskManager, Ui ui, Storage storage) {
Ui.printWithDivider(taskManager.toString());
}
}
Loading