Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a class definition for a basketball player. Its attributes are: name, a S

ID: 3565233 • Letter: C

Question

Create a class definition for a basketball player. Its attributes are: name, a String height (in inches), an int weight (in pounds), an int freeThrowsAttempted, an int freeThrowsMade, an int twoPointFieldGoalsAttempted, an int twoPointFfieldGoalsMade, an int threePointersAttempted, an int threePointersMade, an int turnovers, an int assists, an int Include the expected getters and setters. Also, include a getStats() method that returns a string formatted as follows: Name: xxxxxxxxxxxxx Field Goal Percentage: xxxxx.xx% 3 Pointer Percentage: Free Throw Percentage: xxxxx.xx% Assist to Turnover Ration: xxx.xx Write a tester class that creates several instances of basketball player, sets attributes, and prints stats. Be sure to include enough tests to verify that your BasketBallPlayer class works properly.

Explanation / Answer

import java.io.*;

class tester{
   String name;
   int height;
   int weight;
   int freeThrowsAttempted;
   int freeThrowsMade;
   int twoPointFieldGoalsAttempted;
   int twoPointFieldGoalsMade;
   int threePointersAttempted;
   int threePointersMade;
   int turnovers;
   int assists;
   public tester(String n,int h,int w,int f1,int f2,int t1,int t2,int t3,int t4,int t5,int a){
       name = n;
       height = h;
       weight = w;
       freeThrowsAttempted = f1;
       freeThrowsMade = f2;
       twoPointFieldGoalsAttempted = t1;
       twoPointFieldGoalsMade = t2;
       threePointersAttempted = t3;
       threePointersMade = t4;
       turnovers = t5;
       assists = a;
   }
   void getStats(){
       System.out.println("Name: "+name);
       float s = twoPointFieldGoalsMade*100;
       float s1 = twoPointFieldGoalsAttempted;
       System.out.println("Field Goal Percentage: "+(s/s1));
       s = threePointersMade*100;
       s1 = threePointersMade;
       System.out.println("3 Pointer Percentage: "+(s/s1));
       s = freeThrowsMade*100;
       s1= freeThrowsAttempted;
       System.out.println("Free Throw Percentage: "+(s/s1));
       s = assists;
       s1 = turnovers;
       System.out.println("Assist to Turnover Ration: "+(s/s1));
   }
}

class main{
    public static void main(String []args) {
       /* change these value to have new results */
       tester test = new tester("Name",92,120,56,12,50,25,75,30,12,6);  
       test.getStats();
    }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote