Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL For Data Science Data Cleaning Wrangling And Analytics With Relational Databases

Authors: Antonio Badia

1st Edition

3030575918, 978-3030575915

More Books

Students also viewed these Databases questions

Question

2. What process will you put in place to address conflicts?

Answered: 1 week ago