#ifndef _VENDINGLOGIC_H_
#define _VENDINGLOGIC_H_

class VendingLogic
{
    //  The target value needed to serve the product.
    //  The price must be a multiple of five cents since
    //  the machine will accept only nickels, dimes, and
    //  quarters.
    int goal;

    //  The total amount of money inserted.  This value is set
    //  to zero at the beginning of each transaction.  Each call
    //  to the input method may increase the value.
    int total;

public:
    //  The constructor accepts the vending machine's
    //  goal amount.  The machine is set to its initial
    //  state.  Note that the goal amount cannot change
    //  for the life of this VendingLogic object.
    VendingLogic(int goal);
    
    //  The input method expects coin values of the 
    //  following amounts: 5, 10, 25.
    //  The function returns true if the amount the
    //  client provides is 5, 10, or 25, AND the 
    //  accumulated amount before this call is less than
    //  the product price (goal).  In addition to returning
    //  true, the function increases the accumulated amount
    //  by the value of the parameter.
    //  If the parameter is neither 5, 10, nor 25, the
    //  function returns false and the accumulated amount
    //  is not modified.  If the parameter is 5, 10, or 15 but
    //  the accumulated amount is greater than or equal to the
    //  product price, the function returns false and does not
    //  modify the accumlated amount.
    //  Clients can check the return value to implement a coin
    //  return feature for coins that are not accepted.
    bool input(int amount);

    //  Resets the machine to its initial state.  The value
    //  returned is the accumulated amount, if any; it 
    //  represents the money that can be sent to the 
    //  coin return unit, if a coin return feature is 
    //  implemented.
    int reset();

    //  Returns the cost of the product (same as the goal)
    int cost() const;

    //  Returns the amount remaining that must be entered to
    //  vend the product.  Returns a negative number if the 
    //  amount entered is greater than the price of the 
    //  product.  Clients can call this method to determine
    //  if the product can be vended (return value less than
    //  or equal to zero) and to compute how much change is due.
    int amount_due() const;
};

#endif

