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

Add searchTask functionality and edit AboutUs.md ~YanXu #25

Merged
merged 2 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 8 additions & 7 deletions docs/AboutUs.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# About us
Display | Name | Github Profile | Portfolio
--------|:------------------:|:---------------------------------------------:|:---------:
![](https://via.placeholder.com/100.png?text=Photo) | Eugene Chan Jiajun | [Github](https://github.com/EugeneChanJiajun) | [Portfolio](docs/team/eugenechanjiajun.md)
![](https://via.placeholder.com/100.png?text=Photo) | Daryl Tay | [Github](https://github.com/daryltay415) | [Portfolio](docs/team/daryltay415.md)
![](https://via.placeholder.com/100.png?text=Photo) | Annie Xu | [Github](https://github.com/annnniexu) | [Portfolio](docs/team/johndoe.md)
![](https://via.placeholder.com/100.png?text=Photo) | ChinYanXu | https://github.com/ChinYanXu | [Portfolio](docs/team/johndoe.md)
![](https://via.placeholder.com/100.png?text=Photo) | Chen Kang | [Github](https://github.com/ChenKangg) | [Portfolio](docs/team/johndoe.md)
Display | Name | Github Profile | Portfolio
--------|:-------------------:|:---------------------------------------------:|:---------:
![](https://via.placeholder.com/100.png?text=Photo) | Eugene Chan Jiajun | [Github](https://github.com/EugeneChanJiajun) | [Portfolio](docs/team/eugenechanjiajun.md)
![](https://via.placeholder.com/100.png?text=Photo) | Daryl Tay | [Github](https://github.com/daryltay415) | [Portfolio](docs/team/daryltay415.md)
![](https://via.placeholder.com/100.png?text=Photo) | Annie Xu | [Github](https://github.com/annnniexu) | [Portfolio](docs/team/annnniexu.md)
![](https://via.placeholder.com/100.png?text=Photo) | Chin Yan Xu | [Github](https://github.com/ChinYanXu) | [Portfolio](docs/team/ChinYanXu.md)
![](https://via.placeholder.com/100.png?text=Photo) | Chen Kang | [Github](https://github.com/ChenKangg) | [Portfolio](docs/team/ChenKangg.md)

6 changes: 5 additions & 1 deletion src/main/java/seedu/duke/Duke.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ public static void main(String[] args) {

int taskNumber = Integer.parseInt(sentence[1]);
travelActivityList.removeTask(taskNumber);
} else if(line.startsWith("bye")){
} else if(line.startsWith("find")) {
String[] taskName = line.split(" ");
travelActivityList.searchTask(taskName[1]);
}
else if(line.startsWith("bye")){
userSaysBye = true;
}

Expand Down
23 changes: 23 additions & 0 deletions src/main/java/seedu/duke/TravelActivityList.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,27 @@ public String getDescription(String plan){
}
return "cant be found";
}

public void searchTask (String taskName) {

Choose a reason for hiding this comment

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

I think you can use array list to simplify this method. Similar to getDescription

ArrayList<TravelActivity> temporaryArray = new ArrayList<TravelActivity>();;
int temporaryArrayCounter = 0;
boolean isFound = false;
for(int iterator = 0; iterator < travelActivities.size(); iterator += 1){
if(travelActivities.get(iterator).getPlan().contains(taskName)){
temporaryArray.add(temporaryArrayCounter ,travelActivities.get(iterator));
temporaryArrayCounter += 1;
}
}
if (temporaryArrayCounter == 0) {
System.out.println("Sorry I could not find what you are looking for.");
}
else {
System.out.println("Here are what you are looking for:");
for (int newIterator = 0; newIterator < temporaryArray.size(); newIterator += 1) {
System.out.println((newIterator + 1) + ". " + temporaryArray.get(newIterator).getPlan());
}
}
}


}
Loading