summaryrefslogtreecommitdiff
path: root/src/main/java/design/controller/userinput/menus/SelectCourse.java
diff options
context:
space:
mode:
authorWillemDalton <willemhdalton@gmail.com>2025-10-08 21:49:21 -0400
committerWillemDalton <willemhdalton@gmail.com>2025-10-08 21:49:21 -0400
commit2ef38d86d8b207bc0dad6e3c6b7780abc6f6e82b (patch)
tree5e81c9311165b98bc4c65b25c3b6a37456d23e82 /src/main/java/design/controller/userinput/menus/SelectCourse.java
parentdb1ede10a6547b51ffed71dc86d73f3a6c8af129 (diff)
downloaddesignproject-design-6-2ef38d86d8b207bc0dad6e3c6b7780abc6f6e82b.tar.gz
designproject-design-6-2ef38d86d8b207bc0dad6e3c6b7780abc6f6e82b.tar.bz2
designproject-design-6-2ef38d86d8b207bc0dad6e3c6b7780abc6f6e82b.zip
finished multi filtering
Diffstat (limited to 'src/main/java/design/controller/userinput/menus/SelectCourse.java')
-rw-r--r--src/main/java/design/controller/userinput/menus/SelectCourse.java91
1 files changed, 0 insertions, 91 deletions
diff --git a/src/main/java/design/controller/userinput/menus/SelectCourse.java b/src/main/java/design/controller/userinput/menus/SelectCourse.java
deleted file mode 100644
index 0a57ab6..0000000
--- a/src/main/java/design/controller/userinput/menus/SelectCourse.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package design.controller.userinput.menus;
-
-import design.controller.userinput.Menu;
-import design.controller.userinput.MenuOption;
-import design.runtime.*;
-import design.model.*;
-import design.model.course_search.*;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Scanner;
-
-public class SelectCourse extends Menu {
- CurrentSearchQuery query = CurrentSearchQuery.INSTANCE;
-
- @Override
- public String getTitle() {
- return "select course";
- }
-
- /*
- * Prompt for input and search.
- */
- public void search()
- {
- System.out.print("Enter search term (blank for all): ");
- Scanner sc = new Scanner(System.in);
- String searchTerm = sc.nextLine();
-
- // reset the query so we aren't trying to search on an already searched query
- query.reset();
-
- // search and present
- query.search(searchTerm);
- this.present();
- }
-
- /*
- * Display the results of our search.
- */
- @Override
- public List<MenuOption> getMenuOptions()
- {
- var l = new ArrayList<MenuOption>();
- List<ICourse> queryResult = query.getQueryResult().getCourses();
-
- // 0 - return to main menu
- l.add(new MenuOption("return to main menu", (a) -> new MainMenu().present()));
-
- // if we find no results, let the user know.
- if (queryResult.isEmpty())
- {
- System.out.println("\nNo matching courses found.\n");
- }
-
- // traverse the course list tree and add menu options for each leaf (course)
- addCoursesRecursive(l, query.getQueryResult());
- return l;
- }
-
-
- // recursively go through tree structure of courselist to make menu options
- private void addCoursesRecursive(List<MenuOption> menuOptions, CourseList list)
- {
- for (ICourse icourse : list.getCourses())
- {
- // if we find a leaf (course), display it as a menu option
- if (icourse instanceof Course c)
- {
- menuOptions.add(new MenuOption( c.getName() + ", " + c.getLocation() + ", Difficulty: " + c.getDifficultyRating() + ", " + c.getHoleCount() + " holes",
- (a) -> {
- Golfer currentGolfer = Session.getCurrentGolfer();
- if(currentGolfer == null)
- {
- System.out.println("\n\n !!! log into a golfer account to add courses to your profile. !!! \n\n");
- new MainMenu().present();
- }
-
- currentGolfer.addCourse(c);
- System.out.println("\n Course added to profile. \n");
- }
- ));
- }
- // if not, we need to traverse another courselist
- else if (icourse instanceof CourseList sublist)
- {
- addCoursesRecursive(menuOptions, sublist);
- }
- }
- }
-}