Skip to content

Commit

Permalink
Fix tagging functionality
Browse files Browse the repository at this point in the history
The tagging method only tagged the task temporarily. Needed it such that
tag was a permanent addition to the task
  • Loading branch information
Haris-Irfan committed Sep 20, 2024
1 parent a63ad8f commit 7b8e920
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 36 deletions.
Binary file modified data/tasks.txt
Binary file not shown.
56 changes: 28 additions & 28 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The chatbot will provide the following response if it has successfully added the

> Got it. I've added this task:
>
> [T] [ ] task
> [T] [ ] task []
>
> Now you have 2 tasks in the list.
Expand All @@ -47,7 +47,7 @@ The chatbot will provide the following response if it has successfully added the

> Got it. I've added this task:
>
> [D] [ ] task (by: Dec 5 2024 1800)
> [D] [ ] task (by: Dec 5 2024 1800) []
>
> Now you have 2 tasks in the list.
Expand All @@ -60,13 +60,13 @@ following command:
For example if the user had inputted the following command:

> event task /from 2024-12-05 1800 /to 2024-12-06 1800
> event task /from 2024-12-05 1800 /to 2024-12-06 1800 []
The chatbot will provide the following response if it has successfully added the task to the task list.

> Got it. I've added this task:
>
> [E] [ ] task (from: Dec 5 2024 1800 to: Dec 6 2024 1800)
> [E] [ ] task (from: Dec 5 2024 1800 to: Dec 6 2024 1800) []
>
> Now you have 3 tasks in the list.
Expand All @@ -81,9 +81,9 @@ This is done by inputting the following command>
Using the previous inputs from the adding tasks section calling this command would display the following

> Here are the tasks in your list:
> 1. [T] [ ] task
> 2. [D] [ ] task (by: Dec 5 2024 1800)
> 3. [E] [ ] task (from: Dec 5 2024 1800 to: Dec 6 2024 1800)
> 1. [T] [ ] task ] []
> 2. [D] [ ] task (by: Dec 5 2024 1800) []
> 3. [E] [ ] task (from: Dec 5 2024 1800 to: Dec 6 2024 1800) []
### Marking and Unmarking tasks

Expand All @@ -104,7 +104,7 @@ Would yield the following response from the chatbot.

> Nice! I've marked this task as done:
>
> [T] [X] task
> [T] [X] task []
#### Unmarking tasks

Expand All @@ -121,7 +121,7 @@ Would yield the following response from the chatbot.

> OK. I've marked this task as incomplete:
>
> [T] [ ] task
> [T] [ ] task []
### Deleting tasks

Expand All @@ -138,7 +138,7 @@ Would yield the following response from the chatbot:

>Noted. I've removed the task:
>
>[T] [ ] task
>[T] [ ] task []
>
>Now you have 2 tasks in the list.
Expand All @@ -150,8 +150,8 @@ Would yield the following output:

>Here are the tasks in your list:
>
> 1. [D] [ ] task (by: Dec 5 2024 1800)
> 2. [E] [ ] task (from: Dec 5 2024 1800 to: Dec 6 2024 1800)
> 1. [D] [ ] task (by: Dec 5 2024 1800) []
> 2. [E] [ ] task (from: Dec 5 2024 1800 to: Dec 6 2024 1800) []
We can see that the task Todo task has been deleted and there are 2 tasks left.

Expand All @@ -171,8 +171,8 @@ For example using the above task list, inputting the following:
Would yield the following output:

> Here are the tasks occurring on this date:
> 1. [D] [ ] task (by: Dec 5 2024 1800)
> 2. [E] [ ] task (from: Dec 5 2024 1800 to: Dec 6 2024 1800)
> 1. [D] [ ] task (by: Dec 5 2024 1800) []
> 2. [E] [ ] task (from: Dec 5 2024 1800 to: Dec 6 2024 1800) []
Since the date inputted lies wihtin both the deadline and event duration.

Expand All @@ -183,7 +183,7 @@ On the other hand inputting the following:
Would yield the following output:

> Here are the tasks occurring on this date:
> 1. [E] [ ] task (from: Dec 5 2024 1800 to: Dec 6 2024 1800)
> 1. [E] [ ] task (from: Dec 5 2024 1800 to: Dec 6 2024 1800) []
Since the date does not lie within the deadline but lies within the event duration.

Expand All @@ -196,11 +196,11 @@ Users can make use of the find functionality in our chatbot to filter tasks by w
Given the following task list:

> Here are the tasks in your list:
> 1. [D] [ ] task (by: Dec 5 2024 1800)
> 2. [E] [ ] task (from: Dec 5 2024 1800 to: Dec 6 2024 1800)
> 3. [T] [ ] do work
> 4. [T] [ ] do work tomorrow
> 5. [T] [ ] do poetry
> 1. [D] [ ] task (by: Dec 5 2024 1800) []
> 2. [E] [ ] task (from: Dec 5 2024 1800 to: Dec 6 2024 1800) []
> 3. [T] [ ] do work []
> 4. [T] [ ] do work tomorrow []
> 5. [T] [ ] do poetry []
Users can input a word from the sentence such as:

Expand All @@ -209,9 +209,9 @@ Users can input a word from the sentence such as:
And yield the following output:

> Here are the matching tasks in your list:
> 1. [T] [ ] do work
> 2. [T] [ ] do work tomorrow
> 3. [T] [ ] do poetry
> 1. [T] [ ] do work []
> 2. [T] [ ] do work tomorrow []
> 3. [T] [ ] do poetry []
They may also input more than one word:

Expand All @@ -220,8 +220,8 @@ They may also input more than one word:
And yield the following output:

> Here are the matching tasks in your list:
> 1. [T] [ ] do work
> 2. [T] [ ] do work tomorrow
> 1. [T] [ ] do work []
> 2. [T] [ ] do work tomorrow []
They may even also input part of a word:

Expand All @@ -230,8 +230,8 @@ They may even also input part of a word:
And yield the following output:

> Here are the matching tasks in your list:
> 1. [D] [ ] task (by: Dec 5 2024 1800)
> 2. [E] [ ] task (from: Dec 5 2024 1800 to: Dec 6 2024 1800)
> 1. [D] [ ] task (by: Dec 5 2024 1800) []
> 2. [E] [ ] task (from: Dec 5 2024 1800 to: Dec 6 2024 1800) []
### Tagging tasks

Expand All @@ -249,7 +249,7 @@ Will yield the following output:

> OK. I've tagged the following task:
>
> [T] [ ] do poetry #fun
> [T] [ ] do poetry [fun]
### Exiting the application

Expand Down
6 changes: 4 additions & 2 deletions src/main/java/kietwoforone/tasks/Deadline.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class Deadline extends Task {
private LocalDate deadlineDate;
private String deadlineTime;
private Task task;
private String tag = "";

/**
* Constructor for a new Deadline object.
Expand Down Expand Up @@ -95,7 +96,8 @@ public boolean compareString(String keyword) {

@Override
public String addTag(String tag) {
return this.toString() + " " + "#" + tag;
this.tag = tag;
return this.toString();
}

/**
Expand All @@ -105,7 +107,7 @@ public String addTag(String tag) {
*/
@Override
public String toString() {
return String.format("[D] %s (by: %s %s)", this.task.toString(), this.getDate(), this.deadlineTime);
return String.format("[D] %s (by: %s %s) [%s]", this.task.toString(), this.getDate(), this.deadlineTime, this.tag);
}

}
7 changes: 4 additions & 3 deletions src/main/java/kietwoforone/tasks/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class Event extends Task{
private LocalDate endDate;
private String endTime;
private Task task;

private String tag = "";
/**
* Constructor for a new Event object.
*
Expand Down Expand Up @@ -116,7 +116,8 @@ public boolean compareString(String keyword) {

@Override
public String addTag(String tag) {
return this.toString() + " " + "#" + tag;
this.tag = tag;
return this.toString();
}

/**
Expand All @@ -126,7 +127,7 @@ public String addTag(String tag) {
*/
@Override
public String toString() {
return String.format("[E] %s (from: %s %s to: %s %s)", this.task.toString(), this.getStartDate(), this.startTime, this.getEndDate(), this.endTime);
return String.format("[E] %s (from: %s %s to: %s %s) [%s]", this.task.toString(), this.getStartDate(), this.startTime, this.getEndDate(), this.endTime, this.tag);
}

}
4 changes: 3 additions & 1 deletion src/main/java/kietwoforone/tasks/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class Task implements Serializable {

protected String description;
protected boolean isDone;
private String tag = "";

/**
* Constructor for a new Task object.
Expand Down Expand Up @@ -93,7 +94,8 @@ public boolean compareString(String keyword) {
}

public String addTag(String tag) {
return this.toString() + " " + "#" + tag;
this.tag = tag;
return this.toString();
}

/**
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/kietwoforone/tasks/Todo.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
public class Todo extends Task {

private Task task;
private String tag = "";

/**
* Constructor for new Todo object.
Expand Down Expand Up @@ -65,7 +66,8 @@ public boolean compareString(String keyword) {

@Override
public String addTag(String tag) {
return this.toString() + " " + "#" + tag;
this.tag = tag;
return this.toString();
}

/**
Expand All @@ -75,7 +77,7 @@ public String addTag(String tag) {
*/
@Override
public String toString() {
return String.format("[T] %s", this.task.toString());
return String.format("[T] %s [%s]", this.task.toString(), this.tag);
}

}

0 comments on commit 7b8e920

Please sign in to comment.