Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

Write an interface and then modify classes to implement the interface. Write an interface, GeometricSolid, which has one method, volume. The volume method takes no arguments and returns a double.

You are provided with three classes: Cylinder, Sphere, and RightCircularCone Modify the classes so that they implement the GeometricSolid interface. Supply the appropriate method for each class. Make sure that you use Math.PI in your calculations.

Notice in InterfaceRunner that the objects are added to an ArrayList of GeometricSolids.

Cylinder.java

/**
* Models a Cylinder
*/
public class Cylinder
{
private double radius;
private double height;

/**
* Constructor for objects of class Cylinder
* @param radius the radius of the Cylinder
* @param height the height of this Cylinder
*/
public Cylinder(double radius, double height)
{
this.radius = radius;
this.height = height;
}

/**
* Gets the radius of this Cylinder
* @return the radius of the Cylinder
*/
public double getRadius()
{
return radius;
}

/**
* Sets the radius of the Cylinder
* @param newRadius the value of the new radius
*/
public void setRadius(int newRadius)
{
radius = newRadius;
}

/**
* Gets the height of this Cylinder
* @return the height of the Cylinder
*/
public double getHeight()
{
return height;
}

/**
* Sets the height of the Cylinder
* @param newHeight the value of the new height
*/
public void setHeight(int newHeight)
{
height = newHeight;
}
Write Override method here
}

 

GeometricSolid.java

Write GeometricSolid interface here

 

RightCircularCone.java

/**
* Models a Right circular cone

*/
public class RightCircularCone

{
private double radius;
private double height;

/**
* Constructor for objects of class RightCircularCone
* @param radius the radius of the RightCircularCone
* @param height the height of this RightCircularCone
*/
public RightCircularCone(double radius, double height)
{
this.radius = radius;
this.height = height;
}

/**
* Gets the radius of this RightCircularCone
* @return the radius of the RightCircularCone
*/
public double getRadius()
{
return radius;
}

/**
* Sets the radius of the RightCircularCone
* @param newRadius the value of the new radius
*/
public void setRadius(double newRadius)
{
radius = newRadius;
}

/**
* Gets the height of this RightCircularCone
* @return the height of the RightCircularCone
*/
public double getHeight()
{
return height;
}

/**
* Sets the height of the RightCircularCone
* @param newHeight the value of the new height
*/
public void setHeight(double newHeight)
{
height = newHeight;
}
Write Override method here
}

 

Sphere.java

/**
* Models a sphere in 3-d space
*/
public class Sphere
{
private double radius;

/**
* Constructor for objects of class Sphere
* @param radius the radius of this Sphere
*/
public Sphere(double radius)
{
this.radius = radius;
}

/**
* Gets the radius of this Sphere
* @return the radius of this Sphere
*/
public double getRadius()
{
return radius;
}

/**
* Sets the the radius of this Sphere
* @param newRadius the radius of this Sphere
*/
public void setRadius(double newRadius)
{
radius = newRadius;
}

Write Override method here

}

expand button
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education