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

[Jiale Sun] iP #265

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
81177c6
Add Increment: Level 0. Greet
Jiale-Sun Sep 15, 2021
a2179d6
Add Increment: Level 1. Greet, Echo, Exit
Jiale-Sun Sep 15, 2021
7bd305c
Add Increment: Level 2. Add, List
Jiale-Sun Sep 15, 2021
68a97b0
Add Increment: Level 3. Mark as Done
Jiale-Sun Sep 15, 2021
4335f3b
Modify the code: Coding standard and personalisation
Jiale-Sun Sep 15, 2021
e594f38
Add Increment: Level 4. ToDos, Events, Deadlines
Jiale-Sun Sep 16, 2021
7606c59
Add files: Automated Text UI Testing
Jiale-Sun Sep 29, 2021
93666c0
Modify the code: Improve code quality
Jiale-Sun Sep 29, 2021
fffc681
Add Increment: Level 5. Handle Errors
Jiale-Sun Sep 30, 2021
c2663e1
Modify the code: Coding standard and format
Jiale-Sun Sep 30, 2021
b446637
Merge branch 'branch-Level-5'
Jiale-Sun Sep 30, 2021
58104bb
A-Packages: Organize into Packages
Jiale-Sun Sep 30, 2021
461d957
Further divide classes into packages
Jiale-Sun Sep 30, 2021
a3f56f7
Merge branch 'branch-A-Packages'
Jiale-Sun Sep 30, 2021
3b551ae
Add Increment: Level 6. Delete
Jiale-Sun Sep 30, 2021
3a5cd94
Add Increment: Level 7. Save
Jiale-Sun Oct 1, 2021
6a970e0
Merge branch 'branch-Level-7'
Jiale-Sun Oct 1, 2021
5f966fa
Resolve the conflicts of branch 6 & 7
Jiale-Sun Oct 1, 2021
1977182
Modified the code before making the OOP increment
Jiale-Sun Oct 1, 2021
a6b1181
Make the code more OOP
Jiale-Sun Oct 3, 2021
3e382bc
Add Increment: Level 9. Find
Jiale-Sun Oct 3, 2021
81c854a
Revert "Add Increment: Level 9. Find"
Jiale-Sun Oct 3, 2021
af72749
Add-Increment: Level 9.Find
Jiale-Sun Oct 3, 2021
e3668cf
Merge branch 'branch-Level-9'
Jiale-Sun Oct 3, 2021
59808e6
Add a User Guide and update the files
Jiale-Sun Oct 3, 2021
5f09724
Fixed all errors in the files and added JavaDoc comments
Jiale-Sun Oct 7, 2021
0b664bf
Merge branch 'branch-A-JavaDoc'
Jiale-Sun Oct 7, 2021
3f4dded
Updated UG.
Jiale-Sun Oct 7, 2021
cb6235d
Deleted wrongly located UG.
Jiale-Sun Oct 7, 2021
9b551fd
Set theme jekyll-theme-architect
Jiale-Sun Oct 7, 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
24 changes: 0 additions & 24 deletions README.md

This file was deleted.

82 changes: 67 additions & 15 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,81 @@
# User Guide

## Features
Duke is a CLI task-managing app to help you and make your life easier.

### Feature-ABC
##Quick Start
1. Ensure you have Java 11 or above installed in your computer.
2. Download the latest Duke JAR file from github.
3. Locate the JAR file into a folder which you will run it from.
4. Navigate to this folder using CLI and run the command `java -jar ip.jar`
5. You can now start using Duke by typing the features command directly!

Description of the feature.
## Features

### Feature-XYZ
### Showing all tasks: `list`

Description of the feature.
Shows all tasks in the task list.

## Usage
* Format: `list`

### `Keyword` - Describe action
### Finding a task: `find`

Describe the action and its outcome.
Finds a task in the task list.

Example of usage:
* Format: `find TASK`
* Example: `find study`

`keyword (optional arguments)`
### Marking a task as done: `done`

Expected outcome:
Marks the task as done.

Description of the outcome.
* Format: `done TASK_INDEX`
* TASK_INDEX is a positive number which refer to the task.
* Example: `done 1`

```
expected output
```
### Deleting a task: `delete`

Deletes a task from the task list.

* Format: `delete TASK_INDEX`
* TASK_INDEX is a positive number which refer to the task.
* Example: `delete 1`

### Recording a deadline task: `deadline`

Adds a deadline task into the task list.

* Format: `deadline TASK_NAME /by TASK_TIME`
* Example: `deadline sleep /by 11p.m.`

### Recording a event task: `event`

Adds a event task into the task list.

* Format: `event TASK_NAME /at TASK_TIME`
* Example: `event eat /at 11a.m.`

### Recording a todo task: `todo`

Adds a todo task into the task list.

* Format: `todo TASK_NAME`
* Example: `todo study`

### Exiting the program: `bye`

Exits the program.

* Format: `bye`

## Command Summary

Action | Format & Example
-------|-----------------
Show all tasks|`list`
Find a task|`find TASK` (eg. `find work`)
Mark a task as done|`done TASK_INDEX` (eg. `done 1`)
Delete a task|`delete TASK_INDEX` (eg. `delete 1`)
Record a deadline task| `deadline deadline TASK_NAME /by TASK_TIME` (eg. `deadline sleep /by 11p.m.`)
Record a event task|`event TASK_NAME /at TASK_TIME` (eg. `event eat /at 11a.m.`)
Record a todo task| `todo TASK_NAME` (eg. `todo study`)
Exit the program|`bye`
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-architect
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

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

import java.util.Scanner;

/**
* Shows the main class of Duke.
*/
public class Duke {

public static void main(String[] args) {
UI.printWelcomeMessage();
String lineInput;
Storage.getFromFile();
do {
Scanner input = new Scanner(System.in);
lineInput = input.nextLine();
Parser.parseInput(lineInput);
UI.printBreaker();
} while (!lineInput.equals("bye"));
UI.printByeMessage();
}
}
8 changes: 8 additions & 0 deletions src/main/java/duke/DukeExceptions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package duke;

public class DukeExceptions extends Exception{

public DukeExceptions(String errorMessage) {
super(errorMessage);
}
}
50 changes: 50 additions & 0 deletions src/main/java/duke/Parser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package duke;

import duke.task.*;

/**
* Formats the inputs to pass to different methods.
*/
public class Parser {

/**
* Formats the input sent from the user and pass it to different methods accordingly.
*
* @param lineInput The line input from the user.
*/
public static void parseInput(String lineInput) {
boolean printMessage = true;
String[] arrayInput = lineInput.split(" ");
String userCommand = arrayInput[0];
try {
switch (userCommand) {
case "list":
TaskList.showTask();
break;
case "done":
int doneIndex = Integer.parseInt(arrayInput[1]);
TaskList.doneTask(doneIndex, printMessage);
break;
case "find":
TaskList.searchTask(arrayInput);
break;
case "event":
case "todo":
case "deadline":
TaskList.recordTask(userCommand, lineInput, printMessage);
break;
case "delete":
String deleteIndex = arrayInput[1];
TaskList.deleteTask(deleteIndex);
break;
case "bye":
break;
default:
System.out.println("OOPS!!! Sorry, but I do not understand:(");
break;
}
} catch (ArrayIndexOutOfBoundsException | NumberFormatException | StringIndexOutOfBoundsException e) {
System.out.println("OOPS!!! Please enter a valid input:(");
}
}
}
71 changes: 71 additions & 0 deletions src/main/java/duke/Storage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package duke;

import java.util.Scanner;

import java.io.IOException;

import java.io.File;
import java.io.FileWriter;

import java.util.ArrayList;

import duke.task.*;

/**
* Reads from a text file and writes to the file to store tasks.
*/
public class Storage {

/**
* Gets the task list from the file.
*/
public static void getFromFile() {
try {
File file = new File("src/main/java/duke/data/task.txt");
file.createNewFile();
Scanner updateInput = new Scanner(file);
boolean printMessage = false;
int taskNumber = 1;
while (updateInput.hasNext()) {
String[] arrayInput = updateInput.nextLine().split("\\|");
switch (arrayInput[0]) {
case "D ":
TaskList.recordTask("deadline", "deadline" + arrayInput[2], printMessage);
break;
case "E ":
TaskList.recordTask("event", "event" + arrayInput[2], printMessage);
break;
case "T ":
TaskList.recordTask("todo", "todo" + arrayInput[2], printMessage);
break;
}
if (arrayInput[1].equals(" 1 ")) {
TaskList.doneTask(taskNumber, printMessage);
}
taskNumber++;
}
} catch (IOException e) {
System.out.println("There is no saved file:( but I will create a new one for you:)");
}
}

/**
* Saves the task list to the file.
*
* @param listInput The task list to be saved.
* @param taskNumber The integer total number of tasks in the list.
*/
public static void saveToFile(ArrayList<Task> listInput, int taskNumber) {
try {
FileWriter file = new FileWriter("src/main/java/duke/data/task.txt");
for (int i = 0; i < taskNumber; i++) {
String numberStatus = ((listInput.get(i).getTaskStatus().equals("[X] "))? "1" : "0");
String stringToSave = listInput.get(i).getTaskType() + " | " + numberStatus + " | " + listInput.get(i).getTaskDescription() + "\n";
file.write(stringToSave);
}
file.close();
} catch (IOException e) {
System.out.println("There is no valid file:(");
}
}
}
Loading