summaryrefslogtreecommitdiff
path: root/src/main/java/design/controller/userinput/menus/StatisticsMenu.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/design/controller/userinput/menus/StatisticsMenu.java')
-rw-r--r--src/main/java/design/controller/userinput/menus/StatisticsMenu.java108
1 files changed, 52 insertions, 56 deletions
diff --git a/src/main/java/design/controller/userinput/menus/StatisticsMenu.java b/src/main/java/design/controller/userinput/menus/StatisticsMenu.java
index 3af790e..8835ce1 100644
--- a/src/main/java/design/controller/userinput/menus/StatisticsMenu.java
+++ b/src/main/java/design/controller/userinput/menus/StatisticsMenu.java
@@ -27,62 +27,6 @@ public class StatisticsMenu extends Menu {
return "statistics menu";
}
- // Helper classes to get user input and handle finding the data they requested (Course, Hole, Year, etc.)
- @SuppressWarnings("resource")
- private Statistics getUserYear(Statistics baseStats){
- Scanner sc = new Scanner(System.in);
-
- System.out.println("Enter year to search: ");
- int year = Integer.parseInt(sc.nextLine());
-
- Statistics yearStats = new YearlyStats(baseStats, year);
- return yearStats;
- }
-
- @SuppressWarnings("resource")
- private Statistics getUserCourse(Statistics baseStats){
- Scanner sc = new Scanner(System.in);
- Course[] courses = golfer.getCourses();
- for(int i = 0; i < courses.length; i++){
- System.out.println((i+1) + ".) Name: " + courses[i].getName() + ". Location: " + courses[i].getLocation());
- }
- System.out.println("Select the course number corresponding to the course. ");
- int selection = Integer.parseInt(sc.nextLine());
- return new CourseStats(baseStats, courses[selection - 1]);
- }
-
- @SuppressWarnings("resource")
- private Statistics getUserRound(Statistics baseStats){
- Scanner sc = new Scanner(System.in);
- Round[] rounds = baseStats.getRounds();
- for(int i = 0; i < rounds.length; i++){
- System.out.println((i+1) + ".) Date: " + rounds[i].getDateTime().toLocalDate() + ". Time: " + rounds[i].getDateTime().toLocalTime() + ". Final Score: " + rounds[i].getTotalSwings() + ". Total Distance: " + rounds[i].getTotalDistance());
- }
- System.out.println("Select the round number: ");
- int selection = Integer.parseInt(sc.nextLine());
- return new RoundStats(baseStats, rounds[selection - 1]);
- }
-
- @SuppressWarnings("resource")
- private Statistics getUserHole(Statistics baseStats){
- Scanner sc = new Scanner(System.in);
- Round round = baseStats.getRounds()[0]; // Only 1 round
- Play[] plays = round.getPlays();
- for(Play play : plays){
- System.out.println("Hole number: " + play.getHoleNumber());
- }
- System.out.println("Enter the hole number: ");
- int holeNum = Integer.parseInt(sc.nextLine());
-
- Course course = round.getCourse();
- for(Hole hole : course.getHoles()){
- if(hole.getNumber() == holeNum){
- return new HoleStats(baseStats, hole);
- }
- }
- return baseStats;
- }
-
@Override
public List<MenuOption> getMenuOptions() {
return List.of(
@@ -134,4 +78,56 @@ public class StatisticsMenu extends Menu {
})
);
}
+
+ // Helper classes to get user input and handle finding the data they requested (Course, Hole, Year, etc.)
+ private Statistics getUserYear(Statistics baseStats){
+ Scanner sc = new Scanner(System.in);
+
+ System.out.println("Enter year to search: ");
+ int year = Integer.parseInt(sc.nextLine());
+
+ Statistics yearStats = new YearlyStats(baseStats, year);
+ return yearStats;
+ }
+
+ private Statistics getUserCourse(Statistics baseStats){
+ Scanner sc = new Scanner(System.in);
+ Course[] courses = golfer.getCourses();
+ for(int i = 0; i < courses.length; i++){
+ System.out.println((i+1) + ".) Name: " + courses[i].getName() + ". Location: " + courses[i].getLocation());
+ }
+ System.out.println("Select the course number corresponding to the course. ");
+ int selection = Integer.parseInt(sc.nextLine());
+ return new CourseStats(baseStats, courses[selection - 1]);
+ }
+
+ private Statistics getUserRound(Statistics baseStats){
+ Scanner sc = new Scanner(System.in);
+ Round[] rounds = baseStats.getRounds();
+ for(int i = 0; i < rounds.length; i++){
+ System.out.println((i+1) + ".) Date: " + rounds[i].getDateTime().toLocalDate() + ". Time: " + rounds[i].getDateTime().toLocalTime() + ". Final Score: " + rounds[i].getTotalSwings() + ". Total Distance: " + rounds[i].getTotalDistance());
+ }
+ System.out.println("Select the round number: ");
+ int selection = Integer.parseInt(sc.nextLine());
+ return new RoundStats(baseStats, rounds[selection - 1]);
+ }
+
+ private Statistics getUserHole(Statistics baseStats){
+ Scanner sc = new Scanner(System.in);
+ Round round = baseStats.getRounds()[0]; // Only 1 round
+ Play[] plays = round.getPlays();
+ for(Play play : plays){
+ System.out.println("Hole number: " + play.getHoleNumber());
+ }
+ System.out.println("Enter the hole number: ");
+ int holeNum = Integer.parseInt(sc.nextLine());
+
+ Course course = round.getCourse();
+ for(Hole hole : course.getHoles()){
+ if(hole.getNumber() == holeNum){
+ return new HoleStats(baseStats, hole);
+ }
+ }
+ return baseStats;
+ }
} \ No newline at end of file