/** Functions to calculate the area of pizza purchased, given a diameter. * * @author Ian Barland * @version 2007.Jan.10 */ class PizzaServer { /** Calculate the area of a pizza, given its diameter. * @param diam The diameter of the pizza, in inches. * @return The area of the pizza, in square inches. * p.pizzaArea( 0) = 0 * p.pizzaArea( 2) =~ 3.14 * p.pizzaArea(12) =~ 113.04 * p.pizzaArea(16) =~ 209.96 * p.pizzaArea(20) =~ 314 */ double pizzaArea( double diam ) { return 3.14 * (diam/2) * (diam/2); } /** Calculate the area of pizza ordered, given its diameter, * based on the "free foot friday" promo of itec120-lect01c. * @param diam The diameter of the pizza ordered, in inches. * @return The total area of pizza received, in square inches. * p.friPizzaArea( 0) = p.pizzaArea( 0) + pizzaArea(12) =~ 113.04 * p.friPizzaArea( 2) = p.pizzaArea( 2) + pizzaArea(12) =~ 116.18 * p.friPizzaArea(12) = p.pizzaArea(12) + pizzaArea(12) =~ 226.08 * p.friPizzaArea(16) = p.pizzaArea(16) + pizzaArea(12) =~ * p.friPizzaArea(20) = p.pizzaArea(20) + pizzaArea(12) =~ 427.04 */ double friPizzaArea( double diam ) { return this.pizzaArea(diam) + this.pizzaArea(12); } /** Calculate the area of pizza ordered, given its diameter, * based on the "20% Tuesday" promo of itec120-lect01c. * @param diam The diameter of the pizza ordered, in inches. * @return The total area of pizza received, in square inches. * p.tuePizzaArea( 0) = 1.20 * p.pizzaArea( 0) =~ 0 * p.tuePizzaArea( 2) = 1.20 * p.pizzaArea( 2) =~ 3.768 * p.tuePizzaArea(20) = 1.20 * p.pizzaArea(20) =~ 376.8 */ double tuePizzaArea( double diam ) { return 1.20 * this.pizzaArea(diam); // Alternately: // return this.pizzaArea(diam) + 0.20*this.pizzaArea(diam); // However you compute "20% more", your code should match that. } /** Calculate the area of a pizza, given its diameter, * based on the "widening wednesdays" promo of itec120-lect01c. * @param diam The diameter of the pizza ordered, in inches. * @return The total area of pizza received, in square inches. * p.wedPizzaArea( 0) = p.pizzaArea( 0 * 1.10 ) =~ 0 * p.wedPizzaArea( 2) = p.pizzaArea( 2 * 1.10 ) =~ 3.7994 * p.wedPizzaArea(12) = p.pizzaArea( 12 * 1.10 ) =~ 136.7784 */ double wedPizzaArea( double diam ) { return this.pizzaArea( 1.10 * diam ); } }