binibiningtinamoran

WorkOut.java

Nov 26th, 2019
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.91 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.List;
  3. import java.util.Scanner;
  4.  
  5. public class WorkOut {
  6.  
  7.     private static final int range = 6;
  8.  
  9.     public static void main(String[] args) {
  10.  
  11.         Scanner kb = new Scanner(System.in);
  12.         System.out.println("Pick a workout day (Chest Day, Leg Day, Back Day):");
  13.         String workOut = kb.nextLine();
  14.  
  15.         System.out.printf("You entered %s.\n",workOut);
  16.         System.out.println("Here are the workouts: ");
  17.  
  18.         if (workOut.equalsIgnoreCase("Chest Day")) {
  19.             // System.out.println(Arrays.toString(chestDay()));
  20.             printArray(chestDay());
  21.         } else if (workOut.equalsIgnoreCase("Leg Day")) {
  22.             printArray(legDay());
  23.         } else if (workOut.equalsIgnoreCase("Back Day")) {
  24.             printArray(backDay());
  25.         } else {
  26.             System.out.println("Invalid choice made. Choose between Chest, Leg or Back days only.");
  27.         }
  28.     }
  29.  
  30.     public static String[] backDay() {
  31.         List<String> backList = new ArrayList <>();
  32.         backList.add("Deadlift");
  33.         backList.add("Pull Up");
  34.         backList.add("Back Rows");
  35.         backList.add("Bend-Over Barbell Rows");
  36.         backList.add("Romanian Deadlift");
  37.         backList.add("Front Squat");
  38.  
  39.         return randomizerHelper(backList);
  40.     }
  41.  
  42.     public static String[] chestDay() {
  43.         List <String> chestList = new ArrayList <>();
  44.         chestList.add("Bench Press");
  45.         chestList.add("Incline Press");
  46.         chestList.add("Dip");
  47.         chestList.add("Flys");
  48.         chestList.add("Reverse Flys");
  49.         chestList.add("Supine Press");
  50.  
  51.         return randomizerHelper(chestList);
  52.     }
  53.  
  54.     public static String[] legDay() {
  55.         List<String> legList = new ArrayList <>();
  56.         legList.add("Squat");
  57.         legList.add("Leg Press");
  58.         legList.add("Leg Extension");
  59.         legList.add("Dumbbell Step Up");
  60.         legList.add("Body Weight Calf Raises");
  61.         legList.add("Walking Lunge");
  62.  
  63.         return randomizerHelper(legList);
  64.     }
  65.  
  66.     private static String[] randomizerHelper(List<String> arr) {
  67.         String[] returnArray = new String[3];
  68.         String chosen;
  69.         for(int i = 0; i < returnArray.length; i++) {
  70.             chosen = arr.get((int) (Math.random() * range));
  71.  
  72.             for(int j = 0; j < returnArray.length; j++) {
  73.                 if (!(chosen.equalsIgnoreCase(returnArray[j]))) {
  74.                     returnArray[i]= chosen;
  75.                     break; // AVOIDS DUPLICATES!
  76.                 }
  77.             }
  78.         }
  79.         return returnArray;
  80.     }
  81.  
  82.     // Helper method to print array
  83.     // Or if you do not want to use this, use:
  84.     // System.out.println(Arrays.toString(chestDay(range))); in the main method
  85.     private static void printArray(String[] arr) {
  86.         for (String val : arr) {
  87.             System.out.println(val);
  88.         }
  89.     }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment