project4
Class Order

java.lang.Object
  extended by project4.Order
Direct Known Subclasses:
DeliveredOrder, DineInOrder

public class Order
extends java.lang.Object


Nested Class Summary
 class Order.NegativeOrderException
          throw this exception when an order with a negative number is created
 
Field Summary
static int CHEESEBURGER_VALUE
          the value of a cheeseburger in an order
static int DELIVERED_ORDER_TYPE
          delivered order type
static int DINE_IN_ORDER_TYPE
          dine-in order type
static int FRIES_VALUE
          the value of fries in an order
static int HAMBURGER_VALUE
          the value of a hamburger in an order
static int TAKE_OUT_ORDER_TYPE
          take-out order type
 
Constructor Summary
Order(int numHamburgers, int numCheeseburgers, int numFries)
          standard constructor creates an order with some hamburgers, cheeseburgers, and french fries
 
Method Summary
 boolean equals(java.lang.Object obj)
          overridden version of the equals method
 int getNumCheeseburgers()
          accessor method to get the number of cheeseburgers in the order
 int getNumFries()
          accessor method to get the number of fries in the order
 int getNumHamburgers()
          accessor method to get the number of hamburgers in the order
 int getOrderValue()
          compute and return the order's value
 void setNumCheeseburgers(int numCheeseburgers)
          mutator method to set the number of cheeseburgers in the order
 void setNumFries(int numFries)
          mutator method to set the number of fries in the order
 void setNumHamburgers(int numHamburgers)
          mutator method to set the number of hamburgers in the order
 java.lang.String toString()
          overridden version of the toString method
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TAKE_OUT_ORDER_TYPE

public static final int TAKE_OUT_ORDER_TYPE
take-out order type

See Also:
Constant Field Values

DINE_IN_ORDER_TYPE

public static final int DINE_IN_ORDER_TYPE
dine-in order type

See Also:
Constant Field Values

DELIVERED_ORDER_TYPE

public static final int DELIVERED_ORDER_TYPE
delivered order type

See Also:
Constant Field Values

HAMBURGER_VALUE

public static final int HAMBURGER_VALUE
the value of a hamburger in an order

See Also:
Constant Field Values

CHEESEBURGER_VALUE

public static final int CHEESEBURGER_VALUE
the value of a cheeseburger in an order

See Also:
Constant Field Values

FRIES_VALUE

public static final int FRIES_VALUE
the value of fries in an order

See Also:
Constant Field Values
Constructor Detail

Order

public Order(int numHamburgers,
             int numCheeseburgers,
             int numFries)
      throws Order.NegativeOrderException
standard constructor creates an order with some hamburgers, cheeseburgers, and french fries

Parameters:
numHamburgers - the number of hamburgers in the order
numCheeseburgers - the number of cheeseburgers in the order
numFries - the number of fries in the order
Throws:
Order.NegativeOrderException - thrown if any of the arguments are negative values
Method Detail

getOrderValue

public int getOrderValue()
compute and return the order's value

Returns:
the order's value

toString

public java.lang.String toString()
overridden version of the toString method

Overrides:
toString in class java.lang.Object
Returns:
a String representation of the order

equals

public boolean equals(java.lang.Object obj)
overridden version of the equals method

Overrides:
equals in class java.lang.Object
Parameters:
order - the other order to compare against
Returns:
true if the argument order is the same as this order, false otherwise

getNumHamburgers

public int getNumHamburgers()
accessor method to get the number of hamburgers in the order

Returns:
the number of hamburgers in the order

getNumCheeseburgers

public int getNumCheeseburgers()
accessor method to get the number of cheeseburgers in the order

Returns:
the number of cheeseburgers in the order

getNumFries

public int getNumFries()
accessor method to get the number of fries in the order

Returns:
the number of fries in the order

setNumHamburgers

public void setNumHamburgers(int numHamburgers)
                      throws Order.NegativeOrderException
mutator method to set the number of hamburgers in the order

Parameters:
numHamburgers - the number of hamburgers for the order
Throws:
Order.NegativeOrderException - thrown if numHamburgers < 0

setNumCheeseburgers

public void setNumCheeseburgers(int numCheeseburgers)
                         throws Order.NegativeOrderException
mutator method to set the number of cheeseburgers in the order

Parameters:
numCheeseburgers - the number of cheeseburgers for the order
Throws:
Order.NegativeOrderException - thrown if numHamburgers < 0

setNumFries

public void setNumFries(int numFries)
                 throws Order.NegativeOrderException
mutator method to set the number of fries in the order

Parameters:
numFries - the number of fries for the order
Throws:
Order.NegativeOrderException - thrown if numHamburgers < 0