Because RectangularPrism \"implements\" Shape, Eclipse has populated the class w
ID: 3732550 • Letter: B
Question
Because RectangularPrism "implements" Shape, Eclipse has populated the class with two methods which "Override" the interface methods. Without the existence of these methods, we would encounter a compiler error (try removing one of the methods to see this "contract" enforcement in action). Add a constructor to this class:
RectangularPrism(double width, double height, double length)
Finally, complete the two methods by using the volume and surface area formulas for a rectangular prism:
v = whl
A = 2(wl + hl + hw)
JPizza.java ShapeHandler.ja PizzaType.java "1 Main.java PizzaModified.java Shape.java 1 package oop.PizzaModified; 1 package oop.PizzaModified; 3 public class PizzaModified { 4 3 public enum PizzaType f 4 HAWAIIANC10), MEATLOVERSC12), VEGETARIANC9); // Private properties private int price; private String type; private int price; PizzaType(int price) f this.price price 8 /7 Constructs a Pizza object with a price and a 9public PizzaModified(int price, String type) £ 10 10 this.price price; this.type type; 12 public int priceO 13 14 15 12 13 14 15 public int priceO 16 17 18 19 return price; // Gets the price of the pizza return price; //Gets the type of the pizza public String typeO 21 return type; 23 1Explanation / Answer
//RectangularPrism.java public class RectangularPrism { private int w,h,l; public RectangularPrism(int w, int h, int l) { this.w = w; this.h = h; this.l = l; } public int getVolume(){ return w*h*l; } public int getArea(){ return 2*(w*h+h*l+l*w); } }