Class Product

java.lang.Object
  extended by Product

public class Product
extends java.lang.Object

Represents a product to be stored in a vending machine and purchased by a customer


Constructor Summary
Product(java.lang.String productName, int productPrice, int productQuantity)
          Constructs a new Product object
 
Method Summary
 void decrementQuantity()
          Reduces this Product's quantity count by one, if it is not zero
 java.lang.String dispenseProduct()
          Returns a String representation of the dispensed form of this Product
 java.lang.String getName()
          Returns the name of this Product
 int getPrice()
          Returns the number of coins required to purchase this Product
 int getQuantity()
          Returns the number of this Product in stock
 void increaseQuantity(int count)
          Increases the stock quantity of this Product by a given amount
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Product

public Product(java.lang.String productName,
               int productPrice,
               int productQuantity)
Constructs a new Product object

Parameters:
productName - the name of this Product
productPrice - the number of coins required to purchase this Product
productQuantity - the number of this Product in stock
Method Detail

getName

public java.lang.String getName()
Returns the name of this Product

Returns:
the name of this Product

getPrice

public int getPrice()
Returns the number of coins required to purchase this Product

Returns:
the number of coins required to purchase this Product

getQuantity

public int getQuantity()
Returns the number of this Product in stock

Returns:
the number of this Product in stock

increaseQuantity

public void increaseQuantity(int count)
Increases the stock quantity of this Product by a given amount

Parameters:
count - the amount to increase this Products quantity by
Precondition:
count >= 0
Postcondition:
this Product's quantity field will have increased by zero or more

decrementQuantity

public void decrementQuantity()
Reduces this Product's quantity count by one, if it is not zero

Precondition:
this Product's quantity count is not zero
Postcondition:
this Product's quantity count will have been decremented by one

dispenseProduct

public java.lang.String dispenseProduct()
Returns a String representation of the dispensed form of this Product

Returns:
a String representation of the dispensed form of this Product