/** * The best little pizza house in Texas. * A Pizza has a price and a shape. A shape is that abstract entity that * intrinsically knows how to compute its own area. * A Pizza can tell you its price and its area. * Its area is computed by delegating to its shape. * @author Dung X. Nguyen ** Copyright 2001 by Dung X. Nguyen - All rights reserved. *
*/ public class Pizza { private double _price; private AShape _shape; /** * Initializes thisPizza
to a given price and a given concrete shape. * @param price selling price, >= 0. * @param shape a concrete shape, != null. */ public Pizza(double p, AShape s) { _price = p; _shape = s; } /** * @return this Pizza's price in US$. */ public double getPrice () { return _price; } /** * The area of this pizza is the area of its shape. * @return this _shape's area. */ public double getArea() { return _shape.getArea(); } /** * Returns a String representation of this Pizza showing its price and its * shape. For example, [$4.99, Rectangle(h= 4, w = 6)]. */ public String toString() { return null; // TO DO: STUDENT TO WRITE CODE } }