Please create a class hierarchy for sports players with the super class being th
ID: 3647355 • Letter: P
Question
Please create a class hierarchy for sports players with the super class being the general player class and the subclasses containing more specific information about players in a specific sport. The Super class needs to contain general information including height weight age sex and yearly salary. The subclasses extending from the main class having specific information for that one sport. The main should create and test both subclasses.Please write out the code in full; having the subclasses extend the main class. Please write out both sub-classes.
The User should be able to input any values they want, and choose which type of sport the player plays.
Explanation / Answer
class general { public void info() { int height = 189; int weight = 74; int age = 29; String sex = "male"; float sal = 75000; System.out.println(" Height = "+height+" cm"); System.out.println(" Weight= "+weight+" Kg"); System.out.println(" age= "+age+ " years"); System.out.println(sex); System.out.println(" Salary = "+sal+" Rs"); } } class specific extends general { public void complete() { info(); System.out.println(); String sport = "Tennis"; int titles = 13; int gndslms = 7; int aces = 58; int careers = 47; System.out.println(sport); System.out.println("No of titles = "+titles); System.out.println("No of grandslams= "+gndslms); System.out.println("No of aces = "+aces); System.out.println("No of careers= "+careers); } } class hi { public static void main(String args[]) { specific obj = new specific(); obj.complete(); } }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.