Не удается найти символ Ошибка при создании нового объекта. Не выдает ошибку в затмении, только в терминале на ОС Ma c - PullRequest
0 голосов
/ 22 апреля 2020

Я получаю ошибки на всех моих объектах, которые я создаю со всеми If-утверждениями. Написание все то же самое, как и заглавные буквы также то же самое. Ошибка, которую я получаю от моего Ма c, такова:

symbol:   class Deadlift
  location: class volumeCalculator
volumeCalculator.java:287: error: cannot find symbol
                            Deadlift newDeadlift = new Deadlift();
                                                   ^

Эта ошибка возникает все 12 раз, когда я пытаюсь создать объект. Пожалуйста, помогите как можно скорее, так как мне нужен этот проект сегодня вечером!

public class volumeCalculator {

public static void main(String[] args) {
            System.out.println("Please enter how many execises you did in your workout. No more than 18 allowed.\n"); //Add in a verify of 10 or less exercises
            Scanner scan = new Scanner(System.in); 
            int b = scan.nextInt();
            while(b>18 || b<0) {
                System.out.println("Please enter valid input.");
                b=scan.nextInt();
            }
            String[] yourExerciseList = exercisePrompt(b);          //creating the array of size b to hold the amount of exercises 
            int[][] setsAndReps = new int[b][b];                    // created array to hold the return from the totalWeight() method
            int[] totalReps = new int[b];                           // Holds the total repetitions done.
            int[] sets = new int[b];                                //To hold the sets done
            int[] totalWeightMoved = new int[b];                        //To hold the total weight moved.

            for(int i=0;i<b;i++) {                                  //For loop to fill the exercise array and call the other methods and fill the proper arrays
                    System.out.println("How many Sets did you do for " + yourExerciseList[i]);  
                    sets[i] = scan.nextInt();   //for the total sets done on that exercise. Also to then call the 'totalWeight' method
                    while(sets[i]>40 || sets[i]<0) {
                        System.out.println("Please enter your sets again, less than 30 sets is acceptable.");
                        sets[i] = scan.nextInt();
                    }
                    setsAndReps = totalWeight(sets[i]);
                    totalWeightMoved[i] = weightMoved(setsAndReps, sets[i]);
                    totalReps[i] = totalRepetitionsDone(setsAndReps);// To sum up the total repetitions completed
                }


            for(int j=0;j<b;j++) { //Loop for the final print output (If a back squat, bench press or deadlift was not done.)
                System.out.print("For the " + yourExerciseList[j]);
                System.out.print(" you completed a total of " + sets[j] + " sets. \n");
                System.out.print("In those " + sets[j] + " sets, you completed a total of " + totalReps[j] );
                System.out.print(" repetitions.\nResulting in " + totalWeightMoved[j] + "lbs moved in the duration of the " + yourExerciseList[j]);
                System.out.println("\n");
            }

            for(int j=0;j<yourExerciseList.length;j++) {    
                if(yourExerciseList[j].equals("Deadlift")) {
                    System.out.println("Additional input required for notes.");
                    setObjects(yourExerciseList);
                    break;
                }else if(yourExerciseList[j].equals("Back Squat")) {
                    System.out.println("Additional input required for notes.");
                    setObjects(yourExerciseList);
                    break;
                }else if(yourExerciseList[j].equals("Box Squat")) {
                    System.out.println("Additional input required for notes.");
                    setObjects(yourExerciseList);
                    break;
                }else if(yourExerciseList[j].equals("Front Squat")) {
                    System.out.println("Additional input required for notes.");
                    setObjects(yourExerciseList);
                    break;
                }else if(yourExerciseList[j].equals("Split Squat")) {
                    System.out.println("Additional input required for notes.");
                    setObjects(yourExerciseList);
                    break;
                }else if(yourExerciseList[j].equals("Bench Press")) {
                    System.out.println("Additional input required for notes.");
                    setObjects(yourExerciseList);
                    break;
                }   


            }

                String fileName = "WorkoutLog.txt"; //To declare string variable to hold the filename.
                PrintWriter writer = null;
                try {
                    FileWriter fw = new FileWriter(fileName, true);//Print to the file name, and since true, add to the text already in the file.
                    writer = new PrintWriter(fw);
                }catch (IOException e) {
                    e.printStackTrace();
                }
                for(int k=0;k<yourExerciseList.length;k++) {
                    writer.println("\nFor the " + yourExerciseList[k]);
                    writer.println(" you completed a total of " + sets[k] + " sets. \n");
                    writer.println("In those " + sets[k] + " sets, you completed a total of " + totalReps[k] );
                    writer.println(" repetitions.\nResulting in " + totalWeightMoved[k] + "lbs moved in the duration of the " + yourExerciseList[k]);
                    writer.println("Well did it work?");
                    writer.close();
                }




        }

        public static String[] exercisePrompt(int b) {          //To prompt user with exercise list and return the exercise.
            Scanner scan = new Scanner(System.in);              //scanner to take user input
            String[] yourExerciseList = new String[b];          //array to hold the list of exercises that the user chooses.
            String[] exerciseList = {"Back Squat", "Box Squat", "Split Squat", "Front Squat", "Front Raise", "Side Raise", "Rear Raise", "Bench Press", "Pushup", "Shoulder Press", "Chest Fly", "Face Pull", "Tricep Pushdown", "Rollback", "Shrug", "Deadlift", "Row", "Lat Pulldown", "Goodmorning"};
            System.out.print("Pre-Programmed exercies available:\n "
                    + "\n (0)Back Squat   (1)Box Squat   (2)Split Squat    (3)Front Squat   (4)Front Raise   (5)Side Raise   (6)Rear Raise   ,"
                    + "\n\n (7)Bench Press  (8)Pushup      (9)Shoulder Press (10)Chest Fly        (11)Face Pull    (12)Tricep Pushdown   (13)RollBack  "
                    + "\n\n (14)Shrug      (15)Deadlift   (16)Row            (17)Lat Pulldown     (18)Goodmorning    \n \n");
            for(int i=0;i<b;i++) {
                System.out.println("Please enter the number that cooresponds to the exercise you did.");
                int exercise = scan.nextInt();                  //To pick the desired exercise from the list.
                yourExerciseList[i] = exerciseList[exercise];   //To fill the array with the exercies's, to then be returned for later use.

                    }
            return yourExerciseList;
            }


        public static int[][] totalWeight(int sets){//To fill an array with the amount of sets done total
            Scanner scan = new Scanner(System.in);
            int[] weight = new int[sets]; //array to hold the weights for each set
            int[] reps = new int[sets]; 
                for(int i=0;i<sets;i++) {
                    System.out.println("Please enter the weight used for set # " + (i + 1));
                     int x = scan.nextInt();
                     weight[i] = x; //the array holding each exercise's weights per set
                     while(weight[i]<0) {
                         System.out.println("\nPlease enter a valid weight.");
                         weight[i] = scan.nextInt();
                     }
                     System.out.println("Please enter the reps for set # " + (i + 1));
                     int z = scan.nextInt();
                     reps[i] = z;
                     while(reps[i]<0) {
                         System.out.println("\nPlease enter a valid amount of reps");
                         reps[i] = scan.nextInt();
                     }
                }
            int[][] weightAndReps = { weight, reps };   //2d Array with the weight done for each set as well as the rep's done at that particular weight
            return weightAndReps;
            }


        public static int weightMoved(int[][] totalWeight, int sets) {  //Method to calculate the total amount of weight moved for each exercise.
            int[][] weights = totalWeight; //2d Array to take in the 2d array from the totalWeight Method
            int[] weight = weights[0]; //to separate the array for easy math
            int[] reps = weights[1]; // to separate the array for easy math
            int totalVolume = 0;
            int volume = 0; //initialize the variable to hold the total weight moved in the exercise.
            for(int i =0;i<weight.length;i++) {
                volume = (weight[i] * reps[i]); //To calculate the weight moved through out the length of sets and rep's for each exercise.
                totalVolume += volume;
            }
            return totalVolume;
        }


        public static int totalRepetitionsDone(int[][] setAndReps){ //Calculates the total repetitions done for each exercise.
            int[][] setsAndRepsOfExercises = setAndReps;
            int[] setWeight = setAndReps[0]; // To separate the 2D array for easy math
            int[] setReps = setAndReps[1];  // To separate the 2D array for easy math
            int totalReps = 0;
            for(int k=0;k<setReps.length;k++) {
                totalReps = (totalReps + setReps[k]); // To calculate the Repetitions done.
            }
            return totalReps;  //Return the Repetitions done.
        }


        public static void setObjects(String[] listOfExercises) {  //To set the Squat, BenchPress, and Deadlift objects
            Scanner scan = new Scanner(System.in);
            String[] squatObjectArray = new String[3];              //Hold future output for notes on the workout
            String[] benchObjectArray = new String[2];              //hold future output for notes on the workout
            String[] deadliftObjectArray = new String[2];           //Hold future output for notes on the workout


            for(int i=0;i<listOfExercises.length;i++) {
                int[] angles = new int[2];  //To hold the angles
                String[] angleOptions = {"Back", "Foot"}; //To allow better output to the user - holds the two angle names asked for when squat objects are created
                String[] benchAngle = {"Flat Bench", "Decline Bench", "Incline Bench"};
                String[] benchGrip = {"Normal Grip", "Close Grip", "Wide Grip"};
                    if(listOfExercises[i].equals("Back Squat")) {  //the series of if statements are to properly create the correct objects 
                        Squat newSquat = new Squat();//For the Back Squat
                        newSquat.setBackSquat(true);
                            for(int j=0;j<2;j++) {
                                System.out.println("\nPlease enter what angle your " + angleOptions[j] + " was at during the Back Squat \n"); //Ask the user for their back and foot angle during their lifts
                                System.out.println("For Back: 90 = Straight, 0 = Parallel to the floor. \n");  //Make sure user understands how to input proper data
                                System.out.println("For Foot: 90 = Straight, 0 = Complete rotation outwards \n");  //Make sure user understands how to input proper data
                                int x =scan.nextInt();
                                angles[j] = x;
                            }
                    squatObjectArray[0] = newSquat.getBackSquat();
                    squatObjectArray[1] = newSquat.getBackAngle();
                    squatObjectArray[2] = newSquat.getFootAngle();
                    newSquat.setAngles(angles[0],angles[1]);    //Assigning the correct angles to the correct object to be created  

                    }else if(listOfExercises[i].equals("Box Squat")){
                        Squat newSquat = new Squat();//For the Box squat
                        newSquat.setBoxSquat(true);
                            for(int j=0;j<2;j++) {
                                System.out.println("\nPlease enter what angle your " + angleOptions[j] + " was at during the Box Squat\n"); //Ask the user for their back and foot angle during their lifts
                                System.out.println("For Back: 90 = Straight, 0 = Parallel to the floor. \n"); //Make sure user understands how to input proper data
                                System.out.println("For Foot: 90 = Straight, 0 = Complete rotation outwards \n");//Make sure user understands how to input proper data
                                int x =scan.nextInt();
                                angles[j] = x;
                            }
                    squatObjectArray[0] = newSquat.getBoxSquat();
                    squatObjectArray[1] = newSquat.getBackAngle();
                    squatObjectArray[2] = newSquat.getFootAngle();
                    newSquat.setAngles(angles[0],angles[1]);    //Assigning the correct angles to the correct object to be created  
                    }else if(listOfExercises[i].equals("Split Squat")) {
                        Squat newSquat = new Squat();   //for the Split squat
                        newSquat.setSplitSquat(true);
                            for(int j=0;j<2;j++) {
                                System.out.println("\nPlease enter what angle your " + angleOptions[j] + " was at during the Split Squat \n"); //Ask the user for their back and foot angle during their lifts
                                System.out.println("For Back: 90 = Straight, 0 = Parallel to the floor. \n");//Make sure user understands how to input proper data
                                System.out.println("For Foot: 90 = Straight, 0 = Complete rotation outwards \n");//Make sure user understands how to input proper data
                                int x =scan.nextInt();
                                angles[j] = x;
                            }
                    squatObjectArray[0] = newSquat.getSplitSquat();
                    squatObjectArray[1] = newSquat.getBackAngle();
                    squatObjectArray[2] = newSquat.getFootAngle();
                    newSquat.setAngles(angles[0],angles[1]);        //Assigning the correct angles to the correct object to be created
                    }else if(listOfExercises[i].equals("Front Squat")) {
                        Squat newSquat = new Squat();//for the front squat
                        newSquat.setFrontSquat(true);
                            for(int j=0;j<2;j++) {
                                System.out.println("\nPlease enter what angle your " + angleOptions[j] + " was at durnig the Front Squat\n"); //Ask the user for their back and foot angle during their lifts
                                System.out.println("For Back: 90 = Straight, 0 = Parallel to the floor. \n");//Make sure user understands how to input proper data
                                System.out.println("For Foot: 90 = Straight, 0 = Complete rotation outwards \n");//Make sure user understands how to input proper data
                                int x =scan.nextInt();
                                angles[j] = x;
                            }
                    squatObjectArray[0] = newSquat.getFrontSquat();
                    squatObjectArray[1] = newSquat.getBackAngle();
                    squatObjectArray[2] = newSquat.getFootAngle();
                    newSquat.setAngles(angles[0],angles[1]);        //Assigning the correct angles to the correct object to be created
                    }
                    if(listOfExercises[i].equals("Bench Press")) {
                        BenchPress Bench = new BenchPress();
                        String[] benchPressOptions = new String[2];
                        System.out.println("\nPlease choose which type of Bench Press you did. \n");
                        System.out.println("(0)Flat Bench, (1)Decline Bench, (2)Incline Bench \n"); //Finding out what type of Bench Press the user did.
                        int benchType = scan.nextInt();                                             //thus determining what part of the chest was used most.
                        while(benchType<0||benchType>2) {
                            System.out.println("\nPlease enter valid input.");
                            benchType = scan.nextInt();
                        }
                     if(benchType<1) {
                        benchPressOptions[0] = benchAngle[0];
                        Bench.setFlatBench(true); //sets Flat Bench to true
                        benchObjectArray[0] = Bench.getFlatBench();
                     }else if(benchType<2) {
                        benchPressOptions[0] = benchAngle[1];
                        Bench.setDeclineBench(true);//sets Decline Bench to true
                        benchObjectArray[0] = Bench.getDeclineBench();
                     }else if(benchType<3) {
                        benchPressOptions[0] = benchAngle[2];
                        Bench.setInclineBench(true);//sets Incline Bench to true
                        benchObjectArray[0] = Bench.getInclineBench();
                        }
                        System.out.println("\nPlease enter which grip you used for the Bench Press \n"); //Finding out what type of grip was used.
                        System.out.println("(0)Normal Grip, (1)Close Grip, (2)Wide Grip \n");           //To determine how much tricep was used in the lift.
                        int benchPressGrip = scan.nextInt();
                        while(benchPressGrip<0||benchPressGrip>2) {
                            System.out.println("\nPlease enter valid input.");
                            benchPressGrip = scan.nextInt();
                        }
                    if(benchPressGrip<1) {
                        benchPressOptions[1] = benchGrip[0];
                        Bench.setnormalGrip(true); //Sets bench grip to normal
                        benchObjectArray[1] = Bench.getNormalGrip();
                    }else if(benchPressGrip<2) {
                        benchPressOptions[1] = benchGrip[1];
                        Bench.setCloseGrip(true); //Sets bench grip to close
                        benchObjectArray[1] = Bench.getCloseGrip();
                    }else if(benchPressGrip<3) {
                        benchPressOptions[1] = benchGrip[2];
                        Bench.setWideGrip(true); //Sets bench grip to wide
                        benchObjectArray[1] = Bench.getWideGrip();
                    }
                    }
                    if(listOfExercises[i].equals("Deadlift")) {  //call the proper set methods in the Deadlift Object.
                        System.out.println("\nPlease enter which height you performed your deadlift. \n");
                        System.out.println("(0)Block, (1)Deficit, (2)Floor \n");
                        Deadlift newDeadlift = new Deadlift();
                        int deadHeight = scan.nextInt();
                        while(deadHeight<0||deadHeight>2) {
                            System.out.println("\nPlease enter valid input.");
                            deadHeight = scan.nextInt();
                        }
                            if(deadHeight<1) {
                                newDeadlift.setBlock(true); // Sets block deadlift to true
                                deadliftObjectArray[0] = newDeadlift.getBlock();
                            }else if(deadHeight<2) {
                                newDeadlift.setDeficit(true); // sets deficit deadlift to true
                                deadliftObjectArray[0] = newDeadlift.getDeficit();
                            }else if(deadHeight<3) {
                                newDeadlift.setFloor(true);  //Sets deadlift off the floor to true
                                deadliftObjectArray[0] = newDeadlift.getFloor();
                            }
                    System.out.println("Next enter which stance you used when performing the deadlift.\n");
                    System.out.println("(0)Sumo, (1)Conventional \n");
                        int deadStance = scan.nextInt();
                        while(deadStance<0||deadStance>1) {
                            System.out.println("\nPlease enter a valid option.");
                            deadStance = scan.nextInt();
                        }
                            if(deadStance<1) {
                                newDeadlift.setSumo(true); //Sets sumo stance to True
                                deadliftObjectArray[1] = newDeadlift.getSumo();
                            }else if(deadStance<2) {
                                newDeadlift.setConventional(true); //sets conventional stance to true
                                deadliftObjectArray[1] = newDeadlift.getConventional();
                            }


                     }

                }
            for(int j=0;j<listOfExercises.length;j++) { 
                if(listOfExercises[j].equals("Deadlift")) {
                    System.out.println("\nNote 1 [On the Deadlift]: " + deadliftObjectArray[0]);
                    System.out.println("Note 2 [On the Deadlift]: " + deadliftObjectArray[1]);
                }else if(listOfExercises[j].equals("Back Squat")) {
                    System.out.println("\nNote 1 [On the Back Squat]: " + squatObjectArray[0]);
                    System.out.println("Note 2 [On the Back Squat]: " + squatObjectArray[1]);
                    System.out.println("Note 3 [On the Back Squat]: " + squatObjectArray[2]);
                }else if(listOfExercises[j].equals("Box Squat")) {
                    System.out.println("\nNote 1 [On the Box Squat]: " + squatObjectArray[0]);
                    System.out.println("Note 2 [On the Box Squat]: " + squatObjectArray[1]);
                    System.out.println("Note 3 [On the Box Squat]: " + squatObjectArray[2]);
                }else if(listOfExercises[j].equals("Front Squat")) {
                    System.out.println("\nNote 1 [On the Front Squat]: " + squatObjectArray[0]);
                    System.out.println("Note 2 [On the Front Squat]: " + squatObjectArray[1]);
                    System.out.println("Note 3 [On the Front Squat]: " + squatObjectArray[2]);
                }else if(listOfExercises[j].equals("Split Squat")) {
                    System.out.println("\nNote 1 [On the Split Squat]: " + squatObjectArray[0]);
                    System.out.println("Note 2 [On the Split Squat]: " + squatObjectArray[1]);
                    System.out.println("Note 3 [On the Split Squat]: " + squatObjectArray[2]);
                }else if(listOfExercises[j].equals("Bench Press")) {
                    System.out.println("\nNote 1 [On the Bench Press]: " + benchObjectArray[0]);
                    System.out.println("Note 2 [On the Bench Press]: " + benchObjectArray[1]);
                }   
            }   

        }






}

Тогда для моего класса Squat у меня есть такое: я получаю одинаковую ошибку для всех моих классов, поэтому я не думаю, что есть необходимость размещать другие два класса. Я могу полностью запустить его в Eclipse, но мой терминал в Ma c выдает ошибки. специально к названию объекта, который я создаю.

package volumeCalculator;

public class Squat {
private boolean frontSquat;
private boolean backSquat;
private boolean boxSquat;
private boolean splitSquat;
private int backAngle = 0;
private int footAngle = 0;
/** To set splitSquat to true/false
 * @param split Sets the exercise 'Split Squat' to true.
 */
public void setSplitSquat(boolean split) {splitSquat = split;}
/**To set splitSquat to true/false
 * @param front Sets the exercise 'Front Squat' to true.
 */
public void setFrontSquat(boolean front){frontSquat = front;}
/**To set splitSquat to true/false
 * @param back Sets the exercise 'Back Squat' to true.
 */
public void setBackSquat(boolean back) {backSquat = back;}
/**To set splitSquat to true/false
 * @param box Sets the exercise 'Box Squat' to true.
 */
public void setBoxSquat(boolean box) {boxSquat = box;}
/**To set the user entered Back and foot angles used during the work out.
 * @param a The Back angle used during the particular Squat performed.
 * @param b The knee angle used during the particular Squat performed.
 */
public void setAngles(int a, int b) {
    backAngle = a; //90 being a straight back and 0 being parallel to the floor
    footAngle = b; //0 being straight and 45 being outward rotation 

}


/** To create information to report back to the user on what muscles were used.
 * @return The information on the Split squat to relay to the user.
 */
public String getSplitSquat() {
    String splitSquatInfo = "Performing the split squat you used very little of your back muscles. Instead you used the hamstrings, quads, and dominantly the glutes.";
    return splitSquatInfo;
    }
/** To create information to report back to the user on what muscles were used.
 * @return The information on the Split squat to relay to the user.
 */
public String getFrontSquat() {
    String frontSquatInfo = "Performing the front squat you force an upright position, causing you to use mostly you're core muscles (Abdominals, saratous, lower back)"
            + "and the quads and glutes, rather then the hamstrings for a back squat.";
    return frontSquatInfo;
    }
/** To create information to report back to the user on what muscles were used.
 * @return The information on the Split squat to relay to the user.
 */
public String getBackSquat() {
    String backSquatInfo = "Performing the back squat is an equally distributed effort between your lower back errectors, quads, hamstrings, hips and glutes. ";
    return backSquatInfo;
    }
/** To create information to report back to the user on what muscles were used.
 * @return The information on the Split squat to relay to the user.
 */
public String getBoxSquat() {
    String boxSquatInfo = "Peforming the box squat is a hip dominant movement, requiring a high recruitment of the glutes, hips and hamstrings."
            + " Resulting in very little quad usage.";
    return boxSquatInfo;
    }
/** To create information to report back to the user on what muscles were used.
 * @return The information on the Split squat to relay to the user.
 */
public String getBackAngle(){
    String backAngleOutput = "";
    if(backAngle>45 && backAngle <=90){
        backAngleOutput = "Since you Squatted very upright you used much more Hip and Quad muscles.";
    }else if(backAngle<=45){
        backAngleOutput = "Since you Squatted with a heavily bent back, your main muscles used were the lower back and hamstrings.";
    }else if(backAngle>90 || backAngle<0){
        backAngleOutput = "You might want to reconsider your Squat form! (Or re-enter your input!)";
    }
    return backAngleOutput;
    }
/** To create information to report back to the user on what muscles were used.
 * @return The information on the Split squat to relay to the user.
 */
public String getFootAngle() {
    String footAngleOutput = "";
    if(footAngle>45 && footAngle<90){
        footAngleOutput = "Since your foot roatated outward  during the squat, your hips, glutes, and hamstrings did most of the work";
    }else if(footAngle<=45){
        footAngleOutput = "Since your foot was more forward oriented your quads and glutes did most of the work.";
    }else if(footAngle>90 || footAngle<0){
        footAngleOutput = "You might want to reconsider your Squat form! (Or re-enter your input!)";
    }
    return footAngleOutput;
    }
}
...