/**
* 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.15;
/** Is this PizzaServer a manager? */
boolean isManager = false;
/** Ask this particular PizzaServer about their salary.
* @return This PizzaServer's salary (in $/hr).
*/
double getSalary() {
return this.salary;
}
/** Set this particular PizzaServer's salary.
* @param newSalary The new salary for this employee (in $/hr).
*/
void setSalary( double newSalary ) {
this.salary = newSalary;
}
/** Ask this particular PizzaServer whether they are a manager.
* @return true if this PizzaServer is a manager.
*/
boolean getIsManager() {
return this.isManager;
}
/** Set this particular PizzaServer's manager-status.
* @param newIsManager true if the PizzaServer is to be a manager,
* and false if not.
*/
void setIsManager( boolean newIsManager ) {
this.isManager = newIsManager;
}
/**
* Calculate the area of a pizza, given its diameter.
*
* After Sep.19 (Tue)'s lecture, we realize this would better be static.
*
* @param diam The diameter of a pizza (in inches).
* @return The area (in sq.in.).
*
*
Test cases:
*
pizzaArea( 0) = 0
*
pizzaArea( 2) =~ 3.14
*
pizzaArea(20) =~ 314.0
*
*
pizzaArea( 4) =~ 12.52
*
pizzaArea(16) =~ 201.5ish
*/
static 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.
*
* After Sep.19 (Tue)'s lecture, we realize this would better be static.
*
* @param diam The diameter of the pizza (in inches); diam must be >= 4.
* @return The amount of crust (in sq.in.).
*
*
Test cases:
*
crustArea( 6) = pizzaArea( 6) - 0 =~ 28.16
*
crustArea(20) = pizzaArea(20) - pizzaArea(14) =~ 314 - 153.86 = 160.14ish
*/
static double crustArea( double diam ) {
return pizzaArea(diam) - pizzaArea( diam - 2*3 );
}
}