Question
Write a program (Java) that can store information about basketballs. Ball class (Everything is public) radius double color String Ball(radius, color) //one constructor area() //returns
Write a program (Java) that can store information about basketballs.
Ball class (Everything is public)
radius double
color String
Ball(radius, color) //one constructor
area() //returns the area of the ball. Use Math.PI and Math.pow for
//calculating the area
Basketball inherits Ball (Everything is public)
noOfStripes int
Basketball(noOfStripes,radius, color)
Basketball(radius, color) //assign the number 8 as the default value
//for the number of stripes
//use this and super to call the constructors as you see fit
Driver class
Main method
Create two Basketball objects (You can hardcode the basketball data)
basket1 uses the three argument constructor
basket2 uses the two argument constructor
call display method
//note basket1 and basket2 should be local variables
Display method
Call the area method to display the area for each of the balls
Display all the instance variables for each of the objects.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started