Class Slot

java.lang.Object
  extended bySlot

public class Slot
extends Object

Defines a storage class to store information about a single product slot inside the machine.

Author:
Bill Kuker , Kevin Thompson

Field Summary
(package private)  int cans
           
(package private)  int dropped
           
(package private)  boolean enabled
           
(package private)  int index
           
(package private)  String name
           
(package private)  int price
           
 
Constructor Summary
Slot()
          Default constructor - initialize all the private variables to default values
Slot(int index, String name, int cans, int dropped, int price, boolean enabled)
          Construct a Slot from supplied values.
 
Method Summary
 boolean equals(Slot other)
           
 int getCans()
          Returns the number of cans left in the slot
 int getDropped()
          Returns the number of cans that have been dropped from this slot.
 int getIndex()
          Returns the index of this slot.
 String getName()
          Returns the name or drink in the slot
 int getPrice()
          Returns the price of the slot in credits (cents).
 boolean isEnabled()
          Returns whether or not the slot is enabled.
 void setCans(int _cans)
          Changes the number of cans available from the slot.
 void setDropped(int _dropped)
          Changes the number of cans dropped from this slot.
 void setEnabled(boolean _enabled)
          Sets whether or not this slot is enabled.
 void setIndex(int _index)
          Changes/sets the index of this slot.
 void setName(String _name)
          Changes the name of the slot.
 void setPrice(int _price)
          Changes this slots price.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

index

int index

name

String name

cans

int cans

dropped

int dropped

price

int price

enabled

boolean enabled
Constructor Detail

Slot

public Slot()
Default constructor - initialize all the private variables to default values


Slot

public Slot(int index,
            String name,
            int cans,
            int dropped,
            int price,
            boolean enabled)
Construct a Slot from supplied values.

Parameters:
index - The index of the slot. Indicies are zero based.
name - The slots name.
cans - The number of cans of product left in the slot
dropped - The number of cans that have come out of the slot.
price - The price of the product.
enabled - Whether or not the slot is enabled.
Method Detail

getIndex

public int getIndex()
Returns the index of this slot. Indicies are zero based.

Returns:
the index of this slot.

getName

public String getName()
Returns the name or drink in the slot

Returns:
The name of the slot.

getCans

public int getCans()
Returns the number of cans left in the slot

Returns:
The number of cans in the slot.

getDropped

public int getDropped()
Returns the number of cans that have been dropped from this slot.

Returns:
The number of dropped cans.

getPrice

public int getPrice()
Returns the price of the slot in credits (cents).

Returns:
The price of the slot.

isEnabled

public boolean isEnabled()
Returns whether or not the slot is enabled.

Returns:
True if this slot can be operated. False otherwise.

setIndex

public void setIndex(int _index)
Changes/sets the index of this slot.

Parameters:
_index - The new index of this slot.

setName

public void setName(String _name)
Changes the name of the slot.

Parameters:
_name - The new name for the slot.

setCans

public void setCans(int _cans)
Changes the number of cans available from the slot.

Parameters:
_cans - The number of available cans.

setDropped

public void setDropped(int _dropped)
Changes the number of cans dropped from this slot.

Parameters:
_dropped - The number of cans dropped from this slot.

setPrice

public void setPrice(int _price)
Changes this slots price.

Parameters:
_price - This slots new price.

setEnabled

public void setEnabled(boolean _enabled)
Sets whether or not this slot is enabled.

Parameters:
_enabled - If true, then the slot is enabled. Else, the slot is disabled.

equals

public boolean equals(Slot other)

toString

public String toString()