Skip to content

Commit cf1a113

Browse files
authored
Merge pull request #16 from raymondge/A-release
fix bugs
2 parents dccd5d6 + f4f47a6 commit cf1a113

File tree

6 files changed

+80
-26
lines changed

6 files changed

+80
-26
lines changed

build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ repositories {
1212

1313
dependencies {
1414
implementation 'junit:junit:4.12'
15+
implementation 'org.junit.jupiter:junit-jupiter:5.4.2'
16+
implementation 'org.junit.jupiter:junit-jupiter:5.4.2'
1517
String javaFxVersion = '11'
1618

1719
implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'win'

docs/README.md

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,37 @@
11
# User Guide for duke bot
2-
3-
## Features
4-
5-
### Say bye to duke `bye`
2+
1. [Features](#1-features)<br>
3+
1.1 [Say bye to duke: `bye`](#11-say-bye-to-duke-bye)<br>
4+
1.2 [Find a task: `find`](#12-find-a-task-find)<br>
5+
1.3 [Delete a task: `delete` ](#13-delete-a-task-delete)<br>
6+
1.4 [Create a todo task: `todo`](#14-create-a-todo-task-todo)<br>
7+
1.5 [Create a deadline task: `deadline`](#15-create-a-deadline-task-deadline)<br>
8+
1.6 [Create a event task: `event`](#16-create-a-event-task-event)<br>
9+
1.7 [List your tasks: `list`](#17-list-your-tasks-list)<br>
10+
1.8 [Find out statistics: `stats`](#18-find-out-statistics-stats)<br>
11+
1.9 [Says hi to duke: `hi`](#19-says-hi-to-duke-hi)<br>
12+
2.0 [Mark your task done: `done`](#20-mark-your-task-done-done)<br>
13+
2. [Command Summary](#2-command-summary)
14+
## 1. Features
15+
16+
### 1.1 Say bye to duke `bye`
617

718
Exit the program.
819

920
Input instruction:
1021

1122
`bye`
1223

13-
### Find a task `find`
24+
### 1.2 Find a task `find`
1425

15-
Find the expected task with given index in the task list.
26+
Find the expected task with given keyword.
1627

1728
Input instruction:
1829

19-
`find` + `index`
30+
`find` + `keyword`
2031

2132
Example of usage: find 1
2233

23-
### Delete a task `delete`
34+
### 1.3 Delete a task `delete`
2435

2536
Delete the expected task with given index in the task list.
2637

@@ -30,7 +41,7 @@ Input instruction:
3041

3142
Example of usage: delete 1
3243

33-
### Create a todo task `todo`
44+
### 1.4 Create a todo task `todo`
3445

3546
Create a task that you are going to do and store in the tasklist.
3647

@@ -40,7 +51,7 @@ Input instruction:
4051

4152
Example of usage: todo play games
4253

43-
### Create a deadline task `deadline`
54+
### 1.5 Create a deadline task `deadline`
4455

4556
Create a task with a deadline
4657

@@ -50,7 +61,7 @@ Input instruction:
5061

5162
Example of usage: deadline finish homework /by 2020-05-12
5263

53-
### Create a event task `event`
64+
### 1.6 Create a event task `event`
5465

5566
Create an event
5667

@@ -60,7 +71,7 @@ Input instruction:
6071

6172
Example of usage: event celebrate holiday /at 2020-05-12
6273

63-
### List your tasks `list`
74+
### 1.7 List your tasks `list`
6475

6576
Show the list of tasks
6677

@@ -70,7 +81,7 @@ Input instruction:
7081

7182
Example of usage: list
7283

73-
### Find out statistics `stats`
84+
### 1.8 Find out statistics `stats`
7485

7586
Show the number of task completed
7687

@@ -80,7 +91,7 @@ Input instruction:
8091

8192
Example of usage: stats
8293

83-
### Says hi to duke `hi`
94+
### 1.9 Says hi to duke `hi`
8495

8596
Greet the bot and it will greet you back
8697

@@ -90,7 +101,7 @@ Input instruction:
90101

91102
Example of usage: hi
92103

93-
### Mark your task done `done`
104+
### 2.0 Mark your task done `done`
94105

95106
Mark your task done
96107

@@ -100,6 +111,20 @@ Input instruction:
100111

101112
Example of usage: done 1
102113

114+
## 2. Command summary
115+
116+
Action | Format, Examples
117+
--------|------------------
118+
**Find Task** | `find keyword` <br> e.g.,`find homework`
119+
**Delete Task** | `delete index`<br> e.g.,`delete 1`
120+
**Todo Task** | `todo description` <br> e.g., `doto play games`
121+
**Deadline Task** | `deadline description /by YYYY-MM-DD` <br> e.g., `deadline finish homework /by 2020-05-12`
122+
**Event Task** | `event description /at YYYY-MM-DD` <br> e.g., `event celebrate holiday /at 2020-05-12`
123+
**List Task** | `list` <br>
124+
**Stats** | `stats` <br>
125+
**Done** | `done index ` <br> e.g., `done 1`
126+
**Bye** | `bye`<br>
127+
103128
//@@author dcchan98-reused
104129
//Reused from https://github.com/dcchan98/ip/blob/master/src/main/java/Storage.java with minor modification
105130

src/main/java/Parser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public String uiResponse(TaskList tasks, UI ui,String uiInput) {
7171
throw new InvalidEventException();
7272
}
7373
try {
74-
String[] tempString = textMessage.substring(7).split(" /at ");
74+
String[] tempString = textMessage.substring(6).split(" /at ");
7575
Event newEvent = new Event(tempString[0], false, LocalDate.parse(tempString[1]));
7676
response += tasks.addTask(newEvent);
7777
} catch (Exception e) {

src/main/java/TaskList.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ public String findTask(String keyword) {
2525

2626
}
2727

28+
if (listOfFoundItems.size() == 0) {
29+
return "No matching task is found!";
30+
}
31+
2832
int iterator = 1;
2933
output += "Here are the matching tasks in your list:\n";
3034

@@ -53,6 +57,9 @@ public String addTask(Task myTask) {
5357
* @return the String for task deleted.
5458
*/
5559
public String deleteTask(int index) {
60+
if (this.tasks.size() <= index) {
61+
return "The index you entered is too large!";
62+
}
5663
assert this.tasks.size() > index;
5764
Task myTask = this.tasks.get(index);
5865
this.tasks.remove(index);

src/test/java/DukeTest.java

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/test/java/ParserTest.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import org.junit.jupiter.api.Test;
2+
3+
import static org.junit.Assert.assertEquals;
4+
5+
public class ParserTest {
6+
7+
@Test
8+
public void testParseDeadLine() {
9+
UI ui = new UI();
10+
TaskList tasks = new TaskList();
11+
String respond = "added: [D][" + "\u2718" + "] finish homework (by: May 12 2020)";
12+
try {
13+
assertEquals(respond, new Parser().uiResponse(tasks,ui,"deadline finish homework /by 2020-05-12"));
14+
} catch (Exception e) {
15+
System.out.println(e);
16+
}
17+
}
18+
19+
@Test
20+
public void testParseEvent() {
21+
UI ui = new UI();
22+
TaskList tasks = new TaskList();
23+
String respond = "added: [E][" + "\u2718" + "] finish homework (at: 12 May 2020)";
24+
try {
25+
assertEquals(respond, new Parser().uiResponse(tasks,ui,"event finish homework /at 2020-05-12"));
26+
} catch (Exception e) {
27+
System.out.println(e);
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)