Skip to content

Commit fbf0014

Browse files
Merge branch 'branch-Level-9' to master branch
2 parents e7eda6e + ac0f9f1 commit fbf0014

4 files changed

Lines changed: 143 additions & 45 deletions

File tree

data/saveFile.txt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@ T @ 0 @ dishes
22
D @ 1 @ submission @ 2020-06-06
33
E @ 0 @ play soccer @ 2020-03-04
44
T @ 1 @ dishes
5-
D @ 0 @ submission @ 2020-06-06
6-
E @ 0 @ play soccer @ 2020-03-04
7-
T @ 0 @ dishes
8-
D @ 0 @ submission @ 2020-06-06
9-
D @ 0 @ submission @ 2020-06-06
10-
E @ 0 @ play soccer @ 2020-03-04
5+
D @ 0 @ another submission @ 2020-06-06
6+
E @ 0 @ play table tennis @ 2020-03-04
117
T @ 0 @ dishes
12-
D @ 0 @ submission @ 2020-06-06
13-
E @ 0 @ play soccer @ 2020-03-04
8+
D @ 0 @ another submission @ 2020-06-06
9+
E @ 0 @ play table tennis @ 2020-03-04

src/main/java/MyDuke.java

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@ static void deadlineChecker(String[] inputArr) throws NoDeadlineException, NoDat
129129
+ "eg, deadline return book /by 2020-01-01");
130130
}
131131
}
132+
static void finderChecker(String[] inputArr) throws NoKeywordException {
133+
if (inputArr.length == 1) {
134+
throw new NoKeywordException(
135+
"Paikia Bot: you want to find what task, limpeh need more information ah. "
136+
+ "input 'find <keyword>. eg, find party");
137+
}
138+
}
132139
}
133140

134141
/**
@@ -280,6 +287,31 @@ void handleInput() {
280287
});
281288
}
282289
break;
290+
case "find":
291+
try {
292+
MyDuke.finderChecker(getParsedInput());
293+
String keyword = this.input.split(" ", 2)[1];
294+
List<Task> searchResultList = new ArrayList<>();
295+
for (Task t : tasks.getTaskList()) {
296+
if (t.info.contains(keyword)) {
297+
searchResultList.add(t);
298+
}
299+
}
300+
int searchResultCounter = 1;
301+
String[] tempSearchResultArr = new String[100];
302+
if (searchResultList.isEmpty()) { // improved implementation in case list is empty, gives a clear output
303+
ui.showListEmptyMsg();
304+
} else {
305+
for (Task t : searchResultList) { // changed String s to Task t
306+
tempSearchResultArr[searchResultCounter - 1] = searchResultCounter + ". " + t.toString();
307+
searchResultCounter++;
308+
}
309+
ui.printSearchResultList(keyword, tempSearchResultArr);
310+
}
311+
} catch (NoKeywordException e) {
312+
ui.printErrorMsg(e.getMessage());
313+
}
314+
break;
283315
default:
284316
ui.showInputError();
285317
}
@@ -466,7 +498,17 @@ String getInput(Scanner sc) {
466498
void print(String[] sArr) {
467499
System.out.println(DASH);
468500
for (String s : sArr) {
469-
// Level-2 adjustments
501+
if (s != null) {
502+
System.out.println(s);
503+
}
504+
}
505+
System.out.println(DASH);
506+
}
507+
508+
void print(String description, String[] sArr) {
509+
System.out.println(DASH);
510+
System.out.println(description);
511+
for (String s : sArr) {
470512
if (s != null) {
471513
System.out.println(s);
472514
}
@@ -553,14 +595,15 @@ void showByeMsg() {
553595
void printTasksInList(String[] tasksArr) {
554596
print(tasksArr);
555597
}
598+
599+
void printSearchResultList(String keyword, String[] tasksArr) {
600+
print("Paikia Bot: dis is your search result for '" + keyword + "'", tasksArr);
601+
}
556602
}
557603

558-
<<<<<<< HEAD
559604
/**
560605
* Represents a Task that contains its information/description and a done/not-done status
561606
*/
562-
=======
563-
>>>>>>> branch-A-CodingStandard
564607
class Task {
565608
String info;
566609
boolean isDone;
@@ -728,6 +771,12 @@ class NoDeadlineException extends MyDukeException {
728771
}
729772
}
730773

774+
class NoKeywordException extends MyDukeException {
775+
NoKeywordException(String s) {
776+
super(s);
777+
}
778+
}
779+
731780
class NoDateException extends MyDukeException {
732781
NoDateException(String s) {
733782
super(s);

text-ui-test/EXPECTED.TXT

Lines changed: 81 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,52 @@
11
____________________________________________________________
22
Pai Kia Bot: Eh harlo! Call me Pai Kia Bot.
3-
Pai Kia Bot: I cannot find ur input file sia, could be becuz
4-
1) u never create file because u r new user, in that case, just continue using this program and i will create the folder and save file for u in the directory [root]/data
5-
2) ur saveFile.txt is not in the correct directory, pls input bye and shift the file to [root]/data
6-
3) ur input file is not named saveFile.txt, pls input 'bye' and rename ur input file
7-
Pai Kia Bot: What help you want?
3+
____________________________________________________________
4+
____________________________________________________________
5+
Pai Kia Bot: Got ur input file, baik la
6+
____________________________________________________________
7+
____________________________________________________________
8+
Pai Kia Bot: how u want me to help u?
9+
____________________________________________________________
10+
You: list
11+
____________________________________________________________
12+
1. [T][ ] dishes
13+
2. [D][X] submission (JUN 06 2020)
14+
3. [E][ ] play soccer (MAR 04 2020)
15+
4. [T][X] dishes
16+
5. [D][ ] another submission (JUN 06 2020)
17+
6. [E][ ] play table tennis(MAR 04 2020)
818
____________________________________________________________
919
You: todo dishes
1020
____________________________________________________________
1121
Paikia Bot: ok i just help u added this todo -- [T][ ] dishes
12-
Paikia Bot: now u got 1 item(s) in your list ah
22+
Paikia Bot: now u got 7 item(s) in your list ah
23+
____________________________________________________________
24+
You: deadline another submission /by June 6th
1325
____________________________________________________________
14-
You: deadline submission /by June 6th
26+
Paikia Bot: oi your date input got format error cannot parse sial: by June 6th
27+
Paikia Bot: the format should be liddis: yyyy-mm-dd, eg. 2020-03-02
1528
____________________________________________________________
16-
Paikia Bot: ok i just help u added this deadline -- [D][ ] submission (by June 6th)
17-
Paikia Bot: now u got 2 item(s) in your list ah
29+
You: deadline another submission /by 2020-06-06
1830
____________________________________________________________
19-
You: event play soccer /at Aug 6th 2-4pm
31+
Paikia Bot: ok i just help u added this event -- [D][ ] another submission (JUN 06 2020)
32+
Paikia Bot: now u got 8 item(s) in your list ah
2033
____________________________________________________________
21-
Paikia Bot: ok i just help u added this event -- [E][ ] play soccer (at Aug 6th 2-4pm)
22-
Paikia Bot: now u got 3 item(s) in your list ah
34+
You: event play table tennis /at 2020-03-04
35+
____________________________________________________________
36+
Paikia Bot: ok i just help u added this event -- [E][ ] play table tennis (MAR 04 2020)
37+
Paikia Bot: now u got 9 item(s) in your list ah
2338
____________________________________________________________
2439
You: list
2540
____________________________________________________________
2641
1. [T][ ] dishes
27-
2. [D][ ] submission (by June 6th)
28-
3. [E][ ] play soccer (at Aug 6th 2-4pm)
42+
2. [D][X] submission (JUN 06 2020)
43+
3. [E][ ] play soccer (MAR 04 2020)
44+
4. [T][X] dishes
45+
5. [D][ ] another submission (JUN 06 2020)
46+
6. [E][ ] play table tennis(MAR 04 2020)
47+
7. [T][ ] dishes
48+
8. [D][ ] another submission (JUN 06 2020)
49+
9. [E][ ] play table tennis (MAR 04 2020)
2950
____________________________________________________________
3051
You: done
3152
____________________________________________________________
@@ -37,37 +58,43 @@ Paikia Bot: the number that you inputted is invalid leh (more than the total num
3758
____________________________________________________________
3859
You: done 4
3960
____________________________________________________________
40-
Paikia Bot: the number that you inputted is invalid leh (more than the total number of tasks or less than 1), try again pls ah
61+
Paikia Bot: ok i just help u checked this task as done -- [T][X] dishes
4162
____________________________________________________________
4263
You: done 2
4364
____________________________________________________________
44-
Paikia Bot: ok i just help u checked this task as done -- [D][X] submission (by June 6th)
65+
Paikia Bot: ok i just help u checked this task as done -- [D][X] submission (JUN 06 2020)
4566
____________________________________________________________
4667
You: list
4768
____________________________________________________________
4869
1. [T][ ] dishes
49-
2. [D][X] submission (by June 6th)
50-
3. [E][ ] play soccer (at Aug 6th 2-4pm)
70+
2. [D][X] submission (JUN 06 2020)
71+
3. [E][ ] play soccer (MAR 04 2020)
72+
4. [T][X] dishes
73+
5. [D][ ] another submission (JUN 06 2020)
74+
6. [E][ ] play table tennis(MAR 04 2020)
75+
7. [T][ ] dishes
76+
8. [D][ ] another submission (JUN 06 2020)
77+
9. [E][ ] play table tennis (MAR 04 2020)
5178
____________________________________________________________
5279
You: todo
5380
____________________________________________________________
5481
Paikia Bot: you want to add what todo task, limpeh need more information ah. input 'todo <info>. eg, todo read book
5582
____________________________________________________________
5683
You: deadline
5784
____________________________________________________________
58-
Paikia Bot: you want to add what deadline task, limpeh need more information ah. input 'deadline <info> <date>. eg, deadline return book /by 10 Aug
85+
Paikia Bot: you want to add what deadline task, limpeh need more information ah. input 'deadline <info> <date>. eg, deadline return book /by 2020-01-01
5986
____________________________________________________________
6087
You: deadline return another submission
6188
____________________________________________________________
62-
Paikia Bot: i dun see any date inputs leh. to add date input, use '/<date>'. eg, deadline return book /by 10 Aug
89+
Paikia Bot: i dun see any date inputs leh. to add date input, use '/YYYY-MM-DD'. eg, deadline return book /by 2020-01-01
6390
____________________________________________________________
6491
You: event
6592
____________________________________________________________
66-
Paikia Bot: you want to add what event task, limpeh need more information ah. input 'event <info> /<date>. eg, event bookfest /at 24 Aug 1pm
93+
Paikia Bot: you want to add what event task, limpeh need more information ah. input 'event <info> /YYYY-MM-DD. eg, event bookfest /at 2020-08-24
6794
____________________________________________________________
6895
You: event another play basketball
6996
____________________________________________________________
70-
Paikia Bot: i dun see any date inputs leh. to add date input, use '/<date>'. eg, event bookfest /at 24 Aug 1pm
97+
Paikia Bot: i dun see any date inputs leh. to add date input, use '/YYYY-MM-DD'. eg, event bookfest /at 2020-08-24
7198
____________________________________________________________
7299
You: lmao
73100
____________________________________________________________
@@ -76,8 +103,14 @@ ____________________________________________________________
76103
You: list
77104
____________________________________________________________
78105
1. [T][ ] dishes
79-
2. [D][X] submission (by June 6th)
80-
3. [E][ ] play soccer (at Aug 6th 2-4pm)
106+
2. [D][X] submission (JUN 06 2020)
107+
3. [E][ ] play soccer (MAR 04 2020)
108+
4. [T][X] dishes
109+
5. [D][ ] another submission (JUN 06 2020)
110+
6. [E][ ] play table tennis(MAR 04 2020)
111+
7. [T][ ] dishes
112+
8. [D][ ] another submission (JUN 06 2020)
113+
9. [E][ ] play table tennis (MAR 04 2020)
81114
____________________________________________________________
82115
You: delete
83116
____________________________________________________________
@@ -93,16 +126,34 @@ Paikia Bot: the number that you inputted is invalid leh (more than the total num
93126
____________________________________________________________
94127
You: delete 1
95128
____________________________________________________________
96-
Paikia Bot: ok i just help u deleted this task -- [T][ ] dishes
97-
Paikia Bot: now u got 2 item(s) in your list ah
129+
Paikia Bot: the number that you inputted is invalid leh (more than the total number of tasks or less than 1), try again pls ah
98130
____________________________________________________________
99131
You: list
100132
____________________________________________________________
101-
1. [D][X] submission (by June 6th)
102-
2. [E][ ] play soccer (at Aug 6th 2-4pm)
133+
1. [T][ ] dishes
134+
2. [D][X] submission (JUN 06 2020)
135+
3. [E][ ] play soccer (MAR 04 2020)
136+
4. [T][X] dishes
137+
5. [D][ ] another submission (JUN 06 2020)
138+
6. [E][ ] play table tennis(MAR 04 2020)
139+
7. [T][ ] dishes
140+
8. [D][ ] another submission (JUN 06 2020)
141+
9. [E][ ] play table tennis (MAR 04 2020)
142+
____________________________________________________________
143+
You: find play
144+
____________________________________________________________
145+
Paikia Bot: dis is your search result for 'play'
146+
1. [E][ ] play soccer (MAR 04 2020)
147+
2. [E][ ] play table tennis(MAR 04 2020)
148+
3. [E][ ] play table tennis (MAR 04 2020)
149+
____________________________________________________________
150+
You: find table tennis
151+
____________________________________________________________
152+
Paikia Bot: dis is your search result for 'table tennis'
153+
1. [E][ ] play table tennis(MAR 04 2020)
154+
2. [E][ ] play table tennis (MAR 04 2020)
103155
____________________________________________________________
104156
You: bye
105157
____________________________________________________________
106-
Pai Kia Bot: Leave so soon ah? Limpeh sleep first, if got no issue don't disturb me.
158+
Pai Kia Bot: Leave so soon ah? Ok can limpeh help u save your list in [root]/data as saveFile.txt, i go sleep first
107159
____________________________________________________________
108-
Something went wrong: git\data\saveFile.txt (The system cannot find the path specified)

text-ui-test/input.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
list
22
todo dishes
3-
deadline submission /by June 6th
4-
deadline submission /by 2020-06-06
5-
event play soccer /at 2020-03-04
3+
deadline another submission /by June 6th
4+
deadline another submission /by 2020-06-06
5+
event play table tennis /at 2020-03-04
66
list
77
done
88
done 0
@@ -21,4 +21,6 @@ delete 0
2121
delete 10
2222
delete 1
2323
list
24+
find play
25+
find table tennis
2426
bye

0 commit comments

Comments
 (0)