Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Scanner;
- public class WorkOut {
- private static final int range = 6;
- public static void main(String[] args) {
- Scanner kb = new Scanner(System.in);
- System.out.println("Pick a workout day (Chest Day, Leg Day, Back Day):");
- String workOut = kb.nextLine();
- System.out.printf("You entered %s.\n",workOut);
- System.out.println("Here are the workouts: ");
- if (workOut.equalsIgnoreCase("Chest Day")) {
- // System.out.println(Arrays.toString(chestDay()));
- printArray(chestDay());
- } else if (workOut.equalsIgnoreCase("Leg Day")) {
- printArray(legDay());
- } else if (workOut.equalsIgnoreCase("Back Day")) {
- printArray(backDay());
- } else {
- System.out.println("Invalid choice made. Choose between Chest, Leg or Back days only.");
- }
- }
- public static String[] backDay() {
- List<String> backList = new ArrayList <>();
- backList.add("Deadlift");
- backList.add("Pull Up");
- backList.add("Back Rows");
- backList.add("Bend-Over Barbell Rows");
- backList.add("Romanian Deadlift");
- backList.add("Front Squat");
- return randomizerHelper(backList);
- }
- public static String[] chestDay() {
- List <String> chestList = new ArrayList <>();
- chestList.add("Bench Press");
- chestList.add("Incline Press");
- chestList.add("Dip");
- chestList.add("Flys");
- chestList.add("Reverse Flys");
- chestList.add("Supine Press");
- return randomizerHelper(chestList);
- }
- public static String[] legDay() {
- List<String> legList = new ArrayList <>();
- legList.add("Squat");
- legList.add("Leg Press");
- legList.add("Leg Extension");
- legList.add("Dumbbell Step Up");
- legList.add("Body Weight Calf Raises");
- legList.add("Walking Lunge");
- return randomizerHelper(legList);
- }
- private static String[] randomizerHelper(List<String> arr) {
- String[] returnArray = new String[3];
- String chosen;
- for(int i = 0; i < returnArray.length; i++) {
- chosen = arr.get((int) (Math.random() * range));
- for(int j = 0; j < returnArray.length; j++) {
- if (!(chosen.equalsIgnoreCase(returnArray[j]))) {
- returnArray[i]= chosen;
- break; // AVOIDS DUPLICATES!
- }
- }
- }
- return returnArray;
- }
- // Helper method to print array
- // Or if you do not want to use this, use:
- // System.out.println(Arrays.toString(chestDay(range))); in the main method
- private static void printArray(String[] arr) {
- for (String val : arr) {
- System.out.println(val);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment