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

[Lim Yee Kian] iP #154

Open
wants to merge 98 commits into
base: master
Choose a base branch
from
Open
Changes from 6 commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
68c58c1
Add Gradle support
May 24, 2020
03523ec
Bump gradle and lib version
Eclipse-Dominator Aug 5, 2023
81a9c53
build.gradle: Prevent generating a second JAR file
aureliony Jul 16, 2024
c671da2
Restore reverse commit files
yeekian Aug 22, 2024
0e4f6ac
Chatbot: rename Duke to Mel
yeekian Aug 22, 2024
06ecd08
Chatbot: add echo
yeekian Aug 28, 2024
250b001
Chatbot: add indentation
yeekian Aug 28, 2024
a6b1399
List class: implement add item and print full list function
yeekian Aug 28, 2024
22b8ba2
Chatbot: store text and print list function
yeekian Aug 28, 2024
be71189
Task class: add class
yeekian Aug 28, 2024
0f5d58b
List class: mark and unmark tasks in list as done
yeekian Aug 28, 2024
86a1b52
Chatbot: use List class function to mark and unmark tasks as done
yeekian Aug 28, 2024
907e5a9
Chatbot: Follow coding standard
yeekian Aug 28, 2024
1839a79
Task class: rename getStatusIcon function to getDoneStatusIcon
yeekian Sep 2, 2024
ba587a8
Todo class: add class
yeekian Sep 2, 2024
e9a03bd
Deadline class: add class
yeekian Sep 2, 2024
d6e75cb
Event class: add class
yeekian Sep 2, 2024
4e31adb
List class: modify addItem method
yeekian Sep 2, 2024
100da0c
Mel: Refactor line prints
yeekian Sep 2, 2024
3a22ebe
Refactor List.java and Mel.java
yeekian Sep 3, 2024
27dd198
List: Handle error for non-integer input index for mark and unmark
yeekian Sep 3, 2024
217305f
Implement automated text UI testing
yeekian Sep 3, 2024
549b2e2
List class: remove trailing spaces
yeekian Sep 3, 2024
eede782
List: refactor addItem method for readability
yeekian Sep 5, 2024
4fb8933
List class: refactor code for readability
yeekian Sep 5, 2024
f4e2b51
Revert "List class: refactor code for readability"
yeekian Sep 5, 2024
0dfc0b9
List class: remove unused print functions
yeekian Sep 5, 2024
00ebd29
Chatbot: insert ASCII name art
yeekian Sep 5, 2024
c45aaea
Update expected test output
yeekian Sep 5, 2024
b00c2e1
Remove unused line variable
yeekian Sep 10, 2024
46f5cc7
Update test cases
yeekian Sep 10, 2024
9b2fbc5
Manage empty description and date field exceptions
yeekian Sep 10, 2024
fd7f8b8
Organize into packages
yeekian Sep 10, 2024
39e9e70
Revert "Organize into packages"
yeekian Sep 10, 2024
3beef46
Reapply "Organize into packages"
yeekian Sep 10, 2024
d412248
List: add invalid input message for delete
yeekian Sep 17, 2024
cf5bf1e
Update test case
yeekian Sep 17, 2024
2935e81
Add delete helper functions except for delete function
yeekian Sep 17, 2024
b839ee1
List: implement list as ArrayList
yeekian Sep 17, 2024
a5dfd42
Remove unused code
yeekian Sep 17, 2024
9c43b41
List: implement delete using ArrayList functions
yeekian Sep 17, 2024
d581a01
Add save function
yeekian Sep 17, 2024
9d2789c
Update test case
yeekian Sep 17, 2024
cb3bbb9
Merge branch 'branch-Level-6'
yeekian Sep 17, 2024
0496687
Merge branch 'branch-Level-7'
yeekian Sep 17, 2024
3c182c9
Change file path to be relative
yeekian Sep 18, 2024
f63d039
Update .gitignore to ignore data file
yeekian Sep 19, 2024
ac3870d
Extract out closely related Ui code as a class
yeekian Sep 28, 2024
a771dd7
Extract out closely related Storage code as a class
yeekian Sep 28, 2024
c6dac60
Extract out closely related Parser code as a class
yeekian Sep 28, 2024
8f85047
Remove unused import statements
yeekian Sep 28, 2024
e852f3e
Move printTaskUnmarkedMessage to Ui class
yeekian Sep 28, 2024
8ec7c4a
Refactor code to extract out closely related code as TaskList class
yeekian Sep 28, 2024
b8f0ca7
Merge branch 'branch-A-MoreOOP'
yeekian Sep 28, 2024
1e461c0
Store and print deadline date and times
yeekian Sep 28, 2024
dd88dd5
Add find task function
yeekian Sep 28, 2024
e243b9d
Fix task description extraction
yeekian Sep 28, 2024
3640c38
Update test case
yeekian Sep 28, 2024
1992924
Add JavaDoc comments to the code
yeekian Sep 28, 2024
22c7af4
Add JavaDoc comments to the code
yeekian Sep 28, 2024
64dc240
Merge pull request #1 from yeekian/branch-Level-8
yeekian Sep 28, 2024
0571f7b
Merge branch 'master' of https://github.com/yeekian/ip
yeekian Sep 28, 2024
515584b
Merge branch 'master' of https://github.com/yeekian/ip into branch-Le…
yeekian Sep 28, 2024
8aa6556
Merge pull request #2 from yeekian/branch-Level-9
yeekian Sep 28, 2024
5bdabce
Merge branch 'master' of https://github.com/yeekian/ip
yeekian Sep 28, 2024
5bc41e2
Merge branch 'master' of https://github.com/yeekian/ip into branch-A-…
yeekian Sep 28, 2024
513ffd1
Merge pull request #3 from yeekian/branch-A-JavaDoc
yeekian Sep 28, 2024
8711a86
Merge branch 'master' of https://github.com/yeekian/ip
yeekian Sep 28, 2024
ba46c30
Update expected result of test cases
yeekian Sep 30, 2024
cd2c10a
Merge branch 'master' of https://github.com/yeekian/ip into branch-A-…
yeekian Sep 30, 2024
efcc5d8
Modify code to use storage object instead of static
yeekian Sep 30, 2024
d3d4402
Modify code to use Ui as object instead of static
yeekian Sep 30, 2024
5360463
Refactor code to incorporate TaskList class
yeekian Sep 30, 2024
8da4dee
Merge branch 'branch-branch-A-MoreOOP' into branch-A-MoreOOP
yeekian Sep 30, 2024
624e13d
Merge branch 'branch-A-MoreOOP'
yeekian Sep 30, 2024
4837084
Allow different deadline date inputs with optional time
yeekian Oct 7, 2024
d18519e
Merge branch 'branch-Level-8'
yeekian Oct 7, 2024
8151868
Refactor code to coding standards
yeekian Oct 7, 2024
2b55f75
Handle error from list file
yeekian Oct 7, 2024
90e95e4
Update expected output from test
yeekian Oct 7, 2024
6807512
Use switch-case instead of if-else
yeekian Oct 7, 2024
8df1fc0
Merge branch 'branch-Refactor'
yeekian Oct 7, 2024
43a012a
Update expected output for test cases
yeekian Oct 8, 2024
3ff8f25
Add user guide
yeekian Oct 8, 2024
7079d20
Merge branch 'branch-A-UserGuide'
yeekian Oct 8, 2024
ef57610
Merge branch 'master' of https://github.com/yeekian/ip into branch-Le…
yeekian Oct 8, 2024
0d6e9fc
Allow find to be case-insensitive
yeekian Oct 8, 2024
1090e23
Update README
yeekian Oct 8, 2024
66e0871
Update expected test case output
yeekian Oct 8, 2024
649a07b
Merge branch 'branch-Level-9'
yeekian Oct 8, 2024
cc6885a
Add command summary in README
yeekian Oct 8, 2024
13b4d16
Update README
yeekian Oct 8, 2024
a66af8e
Merge branch 'master' of https://github.com/yeekian/ip into branch-A-…
yeekian Oct 8, 2024
2e6938d
Add quick start guide to UserGuide
yeekian Oct 8, 2024
7f17c31
Merge branch 'branch-A-UserGuide'
yeekian Oct 8, 2024
fac5ac2
Refactor UserGuide
yeekian Oct 8, 2024
fddd94f
Merge branch 'branch-A-UserGuide'
yeekian Oct 8, 2024
b8ecc8c
Modify Storage class to pass smoke test
yeekian Oct 13, 2024
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
28 changes: 28 additions & 0 deletions src/main/java/main/List.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package main;

import exception.EmptyDescriptionException;
import task.*;

import java.util.ArrayList;
@@ -99,4 +100,31 @@ public String getFormattedTasks() {
}
return outputString;
}

public void findItem(String line) {
try {
String findDescription = Parser.extractFindDescription(line);
ArrayList<Task> matchedArrayList = new ArrayList<>(itemArrayList); // Safe copy of the original list

int i = 0;
while (i < matchedArrayList.size()) {
Task t = matchedArrayList.get(i);

if (!t.getDescription().contains(findDescription)) {
matchedArrayList.remove(t);
} else {
i += 1;
}
}

System.out.println("\tHere are the matching tasks in your list:");
int j = 0;
for (Task a: matchedArrayList) {
System.out.println("\t" + (j + 1) + "." + a);
j += 1;
}
} catch (EmptyDescriptionException e) {
Ui.printFindDescriptionEmptyMessage();
}
}
}
34 changes: 25 additions & 9 deletions src/main/java/main/Parser.java
Original file line number Diff line number Diff line change
@@ -44,6 +44,9 @@ public static void getUserInput(Scanner in, String listFilePath, List userList)
Ui.printHorizontalLine();
Storage.saveListToFile(listFilePath, userList);

} else if (isFind(line)) {
userList.findItem(line);
Ui.printHorizontalLine();
} else {
userList.addItem(line);
Ui.printHorizontalLine();
@@ -69,30 +72,34 @@ private static boolean isBye(String line) {
return line.equals("bye");
}

private static boolean isMark(String line) {
return line.length() >= (MARK_WORD_LEN + INPUT_SPACE_BUFFER) && line.substring(0, 4).equals("mark");
public static boolean isMark(String line) {
return line.startsWith("mark ");
}

public static boolean isUnmark(String line) {
return line.startsWith("unmark ");
}

private static boolean isUnmark(String line) {
return line.length() >= (UNMARK_WORD_LEN + INPUT_SPACE_BUFFER) && line.substring(0, 6).equals("unmark");
public static boolean isDelete(String line) {
return line.startsWith("delete ");
}

private static boolean isDelete(String line) {
return line.length() >= (DELETE_WORD_LEN + INPUT_SPACE_BUFFER) && line.substring(0, 6).equals("delete");
public static boolean isFind(String line) {
return line.startsWith("find ");
}

public static boolean isValidEvent(String line) {
return line.startsWith("event") &&
return line.startsWith("event ") &&
line.contains(EVENT_FROM_KEYWORD) &&
line.contains(EVENT_TO_KEYWORD);
}

public static boolean isValidDeadline(String line) {
return line.startsWith("deadline") && line.contains(DEADLINE_BY_KEYWORD);
return line.startsWith("deadline ") && line.contains(DEADLINE_BY_KEYWORD);
}

public static boolean isTodo(String line) {
return line.startsWith("todo");
return line.startsWith("todo ");
}

public static String extractTodoDescription(String line) throws EmptyDescriptionException {
@@ -104,6 +111,15 @@ public static String extractTodoDescription(String line) throws EmptyDescription
return todoDescription;
}

public static String extractFindDescription(String line) throws EmptyDescriptionException {
String findDescription;
findDescription = line.replaceFirst("find", "").trim();

taskDescriptionNotEmpty(findDescription);

return findDescription;
}

public static String extractDeadlineDescription(String line) throws EmptyDescriptionException {
String deadlineDescription;
final int indexOfDeadlinePrefix = line.indexOf("/by");
1 change: 0 additions & 1 deletion src/main/java/main/TaskList.java
Original file line number Diff line number Diff line change
@@ -76,7 +76,6 @@ public static LocalDateTime convertDeadlineDateAsLocalDateTime(String deadlineDa
return LocalDateTime.parse(deadlineDate, inputFormatter);
}


public static LocalDateTime getDeadlineDateAsLocalDateTimeFromFile(String deadlineDate) {
DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("MMM dd yyyy, h:mm a");
return LocalDateTime.parse(deadlineDate, inputFormatter);
4 changes: 4 additions & 0 deletions src/main/java/main/Ui.java
Original file line number Diff line number Diff line change
@@ -48,6 +48,10 @@ public static void printTaskDescriptionEmptyMessage() {
System.out.println("\tError: The task description cannot be empty.");
}

public static void printFindDescriptionEmptyMessage() {
System.out.println("\tError: The find description cannot be empty.");
}

public static void printAddedMessage(ArrayList<Task> itemArrayList, Task task) {
System.out.println("\tGot it. I've added this task:");
System.out.println("\t " + task);
8 changes: 7 additions & 1 deletion text-ui-test/EXPECTED.TXT
Original file line number Diff line number Diff line change
@@ -103,7 +103,13 @@
________________________________________

________________________________________
Error: The task description cannot be empty.
Invalid command format:
todo <task name>
deadline <deadline name> /by <deadline>
event <event name> /from <start date/time> /end <end date/time>
mark <task index>
unmark <task index>
delete <task index>
________________________________________

________________________________________