
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
}


Trending nowThis is a popular solution!
Step by stepSolved in 7 steps with 9 images

- Which of the following cases is most like the adapter pattern? A. If you have an interface called Duck, and have many ducks that implement the duck interface. All of these ducks must have the behaviour “quack” but for some ducks, like a Mallard, this must result in a quack, where for a rubber duck it must result in a squeak. We decide to delegate the quack method to another interface, which can be implemented either in a concrete class that returns a quack or a concrete class that returns a squeak. B. None of these are like the adapter pattern. C. We have a large collection of Ducks. We want to look at them one by one and hear them quack. We write a piece of code that iterates through them all, and as we encounter each one, we have it invoke the quack method. D. If we have an interface called Duck. We need to give an object to a user that can quack like a duck. All we have is Turkeys. We create a special class that implements the duck interface, and to implement the quack…arrow_forwardPlease look at the images for the programming question. I am not sure sure where I should start on this. All coding is done in Java, using IntelliJ Idea.arrow_forwardCreate a Point class to hold x and y values for a point. Create methods show(), add() and subtract() to display the Point x and y values, and add and subtract point coordinates. Create another class Shape, which will form the basis of a set of shapes. The Shape class will contain default functions to calculate area and circumference of the shape, and provide the coordinates (Points) of a rectangle that encloses the shape (a bounding box). These will be overloaded by the derived classes; therefore, the default methods for Shape will only print a simple message to standard output. Create a display() function for Shape, which will display the name of the class and all stored information about the class (including area, circumference and bounding box). Build the hierarchy by creating the Shape classes Circle, Rectangle and Triangle. Search the Internet for the rules governing these shapes, if necessary. For these three Shape classes, create default constructors, as well as constructors…arrow_forward
- Refer to the following interface: Provide two examples (screenshots) that in many ways could improve the above or similar interface using the principles of direct manipulation. Explain the relevant improvements as well. (Examples might have different object, labels and organization)arrow_forwardFor this lab task, you will work with classes and objects. Create a class named text that works similar to the built-in string class. You will need to define a constructor that can be used to initialize objects of this new class with some literal text. Next, define three methods: to_upper() that will convert all characters to uppercase, reverse() that will reverse the text and length() that will return the length of the text. After you have completed this part, copy the following mainfunction to your code and check if the implementation is correct. int main() { text sample = "This is a sample text"; cout << sample.to_upper(); // This should display "THIS IS A SAMPLE TEXT" cout << endl;cout << sample.reverse(); // This should display "txet elpmas a si sihT"cout << endl; cout << sample.length(); // This should display 21 }arrow_forwardBelow for each class you find a UML and description of the public interface. Implementing the public interface as described is madatory. There's freedom on how to implement these classes.The private properties and private methods are under your control.. There are multiple ways of implementing all these classes. Feel free to add private properties and methods. For each object, it's mandatory to create a header file (.h), implementation file (.cpp) and a driver. Blank files are included. The header should have the class definition in it. The implementation file should contain the implementations of the methods laid out in the header fine. And finally the Driver should test/demonstrate all the features of the class. It's best to develop the driver as the class is being written. Check each section to see if there are added additional requirements for the driver. Two test suites are included so that work can be checked. It's important to implement the drivers to test and demonstrate…arrow_forward
- Can you help me with this please: Write the definition of a class swimmingPool, to implement the properties of a swimming pool. Your class should have the instance variables to store the length (in feet), width (in feet), depth (in feet), the rate (in gallons per minute) at which the water is filling the pool, and the rate (in gallons per minute) at which the water is draining from the pool. Add appropriate constructors to initialize the instance variables. Also, add member functions to do the following: determine the amount of water needed to fill an empty or partially filled pool, determine the time needed to completely or partially fill or empty the pool, and add or drain water for a specific amount of time, if the water in the pool exceeds the total capacity of the pool, output "Pool overflow" to indicate that the water has breached capacity. The header file for the swimmingPool class has been provided for reference. Write a program to test your swimmingPool class. An example of…arrow_forwardBelow for each class you find a UML and description of the public interface. Implementing the public interface as described is madatory. There's freedom on how to implement these classes.The private properties and private methods are under your control.. There are multiple ways of implementing all these classes. Feel free to add private properties and methods. For each object, it's mandatory to create a header file (.h), implementation file (.cpp) and a driver. Blank files are included. The header should have the class definition in it. The implementation file should contain the implementations of the methods laid out in the header fine. And finally the Driver should test/demonstrate all the features of the class. It's best to develop the driver as the class is being written. Check each section to see if there are added additional requirements for the driver. Two test suites are included so that work can be checked. It's important to implement the drivers to test and demonstrate…arrow_forwardadd a class to package that represents your new drivable type. That type should be something that is capable of being driven (speeding up and slowing down) and therefore a perfect candidate for a class that implements the actions in the Drivable interface.arrow_forward
- USING JAVA Write these: An interface called Shape that has two methods: area and perimeter. A class Rectangle that implements Shape and has a length and a width. A class Circle that implements Shape and has a radius. For each class, write the needed constructors, getters, setters, and a toString method that stringifies the instance variables in a readable format. Supply a test program that instantiates an instance of each class and exercises each method defined for the class.arrow_forwardFor this exercise, you will be completing the Account class, which simulates a regular bank account, then using overrides and calls to the superclass to create a StudentAccount. Student accounts differ from regular accounts in that they get a bonus $1 for every deposit, but a $2 fee for every withdrawal. You will override the methods in the StudentAccount by calling the superclass methods with the additonal amount or fee incorporated since the balance is not directly stored in the StudentAccount object. You will also update the toString, as outlined in the comments. When completed, create one student account and one regular account for testing. Deposit and withdraw money and print the results. import java.text.*;public class BankTester{public static void main(String[] args){Account a = new Account("Imran", 1100);a.deposit(200.00);System.out.println(acc1.toString());a.withdraw(100.00); }} public class StudentAccount extends Account{// Complete this class with Override methods.…arrow_forwardExtend the functionality of the Carinventory class by introducing a new method called 'add_car. This method should facilitate the addition of custom cars to the inventory. The method should take two parameters: a car model and its price. Implement this method to ensure that the inventory is updated accordingly. Instantiate a new object of the car inventory, naming it 'Auto Emporium,' utilizing the extended class with the newly added 'add_car' method. Your next step is to add three distinct custom cars to 'AutoEmporium'-for example, "Sleek Sedan,' 'Sporty Convertible,' and 'Luxury SUV: Assign varying prices to each of these cars. To conclude, utilize the 'display_inventory method to showcase the updated information about 'AutoEmporium." Verify that the output includes details about the newly added custom cars, ensuring that the prices are accurately reflected. This question tests the candidate's ability to implement a specific method, instantiate objects, add custom items, and…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





