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

[Bernard Wan De Yuan] iP #461

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
d839859
Add Gradle support
May 24, 2020
f38a22a
Level-1
bernardwan Aug 20, 2021
b98c16f
Level-2
bernardwan Aug 20, 2021
feac61e
Level-3
bernardwan Aug 20, 2021
83381b8
Level-4
bernardwan Aug 20, 2021
3c1011c
Added automated text UI testing
bernardwan Aug 25, 2021
7551481
Implemented Level-5, updated test cases
bernardwan Aug 25, 2021
2565300
Implemented Level-6. updated tests
bernardwan Aug 25, 2021
5ff4233
Implemented Level-7
bernardwan Aug 26, 2021
0266c78
Implemented Level-8
bernardwan Aug 26, 2021
33921a6
Merge branch 'branch-Level-8'
bernardwan Aug 26, 2021
48d97f1
Updated tests
bernardwan Aug 26, 2021
09721a2
Resolved conflict errors
bernardwan Aug 26, 2021
e4d0342
Refactor code to make it more OOP
bernardwan Aug 27, 2021
c3e9b99
Organise into package
bernardwan Aug 28, 2021
6db07e9
Add Junit tests
bernardwan Aug 28, 2021
fe6833c
Create JAR File
bernardwan Aug 28, 2021
5f6bf33
Add Javadocs
bernardwan Aug 31, 2021
9dbf7dd
Tweak code to follow coding standard
bernardwan Aug 31, 2021
06609b4
Implement Level-9 Find feature
bernardwan Aug 31, 2021
d093898
Merge branch 'branch-A-CodingStandard'
bernardwan Aug 31, 2021
d2d6805
Merge branch 'branch-Level-9'
bernardwan Aug 31, 2021
bcefd1c
Fix minor javadocs errors
bernardwan Aug 31, 2021
679bfa8
Merge remote-tracking branch 'origin/add-gradle-support'
bernardwan Sep 3, 2021
341051c
Add Gradle to project
bernardwan Sep 4, 2021
5dcd832
Add ability to use checkstyle
bernardwan Sep 4, 2021
62293f6
Add GUI
bernardwan Sep 5, 2021
c786acd
Modify config for proper Gradle usage
bernardwan Sep 5, 2021
9d41498
Add Assert statements
bernardwan Sep 9, 2021
e710891
Check code for code quality and clean up code
bernardwan Sep 9, 2021
f787e9d
Merge pull request #1 from bernardwan/branch-A-Assertions
bernardwan Sep 9, 2021
879b551
Merge branch 'master' into branch-A-CodeQuality
bernardwan Sep 9, 2021
558ea60
Merge pull request #2 from bernardwan/branch-A-CodeQuality
bernardwan Sep 9, 2021
fceed2d
Implement B-DoWithinPeriodTasks
bernardwan Sep 9, 2021
fd12c10
Refactor code
bernardwan Sep 16, 2021
a57ca3c
Add User Guide
bernardwan Sep 16, 2021
d45e077
Rename boolean variable
bernardwan Sep 16, 2021
6e830cf
Improve GUI
bernardwan Sep 16, 2021
4714d9b
Handle some exceptions and change font
bernardwan Sep 17, 2021
0d11fb8
Update README.md
bernardwan Sep 17, 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
1 change: 0 additions & 1 deletion data/duke.txt

This file was deleted.

1 change: 0 additions & 1 deletion src/main/java/duke/Command/ExitCommand.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package duke.Command;

import duke.Command.Command;
import duke.Storage;
import duke.TaskList;
import duke.Ui;
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/duke/Command/FindCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package duke.Command;

import duke.*;

Choose a reason for hiding this comment

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

I think you should import package by package, for example import duke.TaskList rather than using import duke.*


import java.util.ArrayList;

public class FindCommand extends Command{
String keyword;

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

@Override
public void execute(TaskList tasks, Ui ui, Storage storage) throws DukeException {
ArrayList<Task> list = tasks.getList();
list.removeIf(task -> !task.getDescription().contains(this.keyword));
if (list.size() == 0) {
ui.print("No matching tasks found.");
} else {
ui.print(list.size() + " matching task(s):");
ui.print(new TaskList(list).allTasks());
}
}

@Override
public boolean isExit() {
return false;
}
}
6 changes: 0 additions & 6 deletions src/main/java/duke/DukeException.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,4 @@ public class DukeException extends Exception{
public DukeException(String errorMessage) {
super(errorMessage);
}

public class InvalidInputException extends DukeException {
public InvalidInputException(String errorMessage) {
super(errorMessage);
}
}
}
11 changes: 9 additions & 2 deletions src/main/java/duke/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,15 @@ public static Command parse(String input) throws DukeException{
throw new DukeException("Sorry, please enter an integer after 'delete'. (e.g. delete 2)");
}
return new DeleteCommand(index);
}
else {
} else if (first_word.equals("find")){
String remaining;
try {
remaining = input.split(" ", 2)[1];
} catch (ArrayIndexOutOfBoundsException e) {
throw new DukeException("Sorry, please enter a keyword after 'find'.");
}
return new FindCommand(remaining);
} else {
String remaining;
try {
remaining = input.split(" ", 2)[1];
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/duke/TaskList.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ public void addTask(Task task) {
list.add(task);
}

/**
* Returns a copy of the list
* @return ArrayList copy containing all of the tasks
*/
public ArrayList<Task> getList() {
ArrayList<Task> list = (ArrayList<Task>) this.list.clone();
return list;
}

public Task getTask(int index) throws DukeException {
Task task;
try {
Expand Down
3 changes: 3 additions & 0 deletions text-ui-test/EXPECTED.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Added: [E][ ] project meeting (at: 3 December 2021)
There are 3 tasks in the list
Added: [D][ ] return book (by: 3 December 2021)
There are 4 tasks in the list
2 matching task(s):
1. [T][ ] borrow book
2. [D][ ] return book (by: 3 December 2021)
Marked as done:
return book (by: 3 December 2021)
Sorry, I don't understand what that means. :(
Expand Down
1 change: 1 addition & 0 deletions text-ui-test/input.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ todo borrow book
event dinner with friends at 2021-12-03
event project meeting at 2021-12-03
deadline return book by 2021-12-03
find book
done 4
smth blah blah
todo
Expand Down