Skip to content

Commit

Permalink
A-CodeQuality 💙
Browse files Browse the repository at this point in the history
  • Loading branch information
Yihe-Harry committed Feb 17, 2021
1 parent 458523f commit 39e6e1c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
19 changes: 18 additions & 1 deletion src/main/java/duke/task/TaskList.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public int getSize() {

/**
* get the number i task
* @param i index
*/
public Task get(int i) {
assert i >= 0 : "Getter error, pointer less than 0";
Expand All @@ -41,6 +42,9 @@ public Task get(int i) {

/**
* check whether is date format
* @param date String date
* @param pattern date pattern
* @return boolean of whether string match the pattern
*/
public boolean isDateFormat(String date, String pattern) {
SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
Expand All @@ -59,13 +63,17 @@ public boolean isDateFormat(String date, String pattern) {

/**
* add task to the list
* @param t task that being added
*/
public void add(Task t) {
task.add(t);
}

/**
* parser for add tasks
* @param userInput
* @param ui
* @return String that indicating the result
*/
public String add(String[] userInput, Ui ui) throws DukeException {
String reportString = " ";
Expand Down Expand Up @@ -111,6 +119,9 @@ public String add(String[] userInput, Ui ui) throws DukeException {

/**
* mark task as done
* @param inputIndex
* @param ui
* return String indicating the done option
*/
public String doneTask(String inputIndex, Ui ui) {
try {
Expand All @@ -134,6 +145,9 @@ public String doneTask(String inputIndex, Ui ui) {

/**
* delete task from list
* @param inputIndex the index of the task being deleted
* @param ui the ui for style printing
* @return string indicating the result of deletion
*/
public String deleteTask(String inputIndex, Ui ui) {
try {
Expand All @@ -154,8 +168,9 @@ public String deleteTask(String inputIndex, Ui ui) {

/**
* print out task
* @return tasks description in the list
*/
public String printTask(Ui ui) {
public String printTask() {
String taskList;
taskList = "Here is your current tasks\n";
for (int i = 1; i <= task.size(); ++i) {
Expand All @@ -166,6 +181,8 @@ public String printTask(Ui ui) {

/**
* check whether a task is in the list
* @param taskInfo
* @return foundTasks tasks with discriptions that match the string
*/
public List<Task> findTask(String taskInfo) {
List<Task> foundTasks = new ArrayList<>();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/duke/ui/Ui.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public String getResponse(String userInput, TaskList task, FileSaver fs) {
response = task.deleteTask(input[1], this);
break;
case LIST:
response = task.printTask(this);
response = task.printTask();
break;
case DONE:
response = task.doneTask(input[1], this);
Expand Down

0 comments on commit 39e6e1c

Please sign in to comment.