/**
* A PizzaServer knows how to answer basic
* questions about the area of pizzas.
* Also, this version adds a salary.
*
* @author Ian Barland
* @version 2007.Feb.05
*/
class PizzaServer {
/** The salary of this particular PizzaServer (in $/hr). */
double salary = 5.75;
/** Ask this particular PizzaServer about their salary.
* @return This PizzaServer's salary (in $/hr).
*
* Note: No test cases, for the moment!
* (Because the answer depends on the history of the
* particular PizzaServer we ask; we can no longer say
* 'with a certain input, the answer is always such-and-such'.
* We'll discuss proper testing of methods-involving-fields soon.)
*/
double getSalary() {
return this.salary;
}
/** Set this particular PizzaServer's salary.
* @param _salary The new salary for this employee (in $/hr).
*/
void setSalary( double _salary ) {
this.salary = _Salary;
}
/**
* Calculate the area of a pizza, given its diameter.
*
* @param diam The diameter of a pizza (in inches).
* @return The area (in sq.in.).
*
*
Test cases (if p is a PizzaServer instance):
*
p.pizzaArea( 0) = 0 +/- 0.0001
*
p.pizzaArea( 2) = 3.14 +/- 0.0001
*
p.pizzaArea(20) = 314.0 +/- 0.0001
*
*
p.pizzaArea( 4) = 12.52 +/- 0.0001
*
p.pizzaArea(16) = 201.5 +/- 0.0001
*/
double pizzaArea( double diam ) {
double radius = diam/2.0;
return Math.PI * radius * radius;
}
/**
* Given a pizza diameter, calculate how much crust there is (in sq.in.).
* It is guaranteed that there is {@value CRUST_WIDTH}" of crust around the edge;
* hey, this means 2*{@value CRUST_WIDTH}" is the smallest allowable pizza.
*
* @param diam The diameter of the pizza (in inches); diam must be >= 4.
* @return The amount of crust (in sq.in.).
*
*
Test cases:
*
p.crustArea( 6) = 28.16 +/- 0.0001
*
p.crustArea(20) = 160.14 +/- 0.0001
*/
double crustArea( double diam ) {
return pizzaArea(diam) - pizzaArea( diam - 2*3 );
}
}