Answered step by step
Verified Expert Solution
Question
1 Approved Answer
JAVA CODE: A Shape class is given. The Shape class has one data member: type (String), which is used to store the type of shape
JAVA CODE: A Shape class is given. The Shape class has one data member: type (String), which is used to store the type of shape (Circle, Cylinder) and two abstract methods as specified in the following method signatures-both methods return a double value: area() and volume() Write a subclass named Circle.java, which inherits from Shape. This class has one attribute representing the radius of the circle. The volume of a circle is 0. The radius is limited to [0, 100], inclusive. For all other values, you need to set the radius to its default value: 10.00. provides all mutator and accessor methods implements volume and area methods. provides a constructor (takes 2 parameters: shape name and radius) Write a subclass named Cylinder.java, which inherits from Circle. A cylinder has a circle as its base, and another attribute, its height. The height of a cylinder is limited to 0 to 50, otherwise, the height is set to 10. overwrite area and volume methods. provides a constructor (takes three parameters: shape name, radius, and height). provides all mutator and accessor methods override toString method for both subclasses: for Circle class, toString returns, for example: Circle[radius:1.00; Area: 3.14] for Cylinder class, toString returns, for example: Cylinder[radius: 1.00; height: 1.00; Area: 3.14; Volume: 3.14] Please keep all of the varaible and files names as it is stated in the assignment.
this is the uneditable Shape class:
public abstract class Shape{
private String type;
public Shape(String type){ setType(type); }
public String getType(){ return type; } public void setType(String type){ this.type = type; } public abstract double volume(); public abstract double area(); public String toString(){ return type; } }
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