/**
* Computes the price/area ratio of a Pizza to model the notion of a "deal".
* Compares the deals between two Pizzas.
* @author Dung X. Nguyen
* @Copyright 2002 by Dung X. Nguyen - All rights reserved.
*/
public class PizzaDeal {
/**
* Computes the price/area ratio of a given Pizza.
* @param p != null
* @returns the price/area ratio of p.
*/
public double deal(Pizza p) {
return p.getPrice() / p.getShape().getArea();
}
/**
* Compares the price/area ratios of the two Pizza parameters p1, and p2.
* @param p1 != null
* @param p2 != null
* @returns true if p1 is a better deal than p2, false otherwise.
*/
public boolean betterDeal(Pizza p1, Pizza p2) {
return deal(p1) < deal(p2);
}
}