|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectproj2.SnackMachine
public class SnackMachine
The SnackMachine
class implements a basic snack machine that
provides several operations.
Constructor Summary | |
---|---|
SnackMachine()
The sole constructor that creates a SnackMachine instance. |
Method Summary | |
---|---|
boolean |
addCookies(CookieFlavors flavor,
int numberCookies)
Adds the specified number of cookies of the given flavor. |
boolean |
addMints(java.awt.Color color,
int numberMints)
Adds the specified number of mints of the given color. |
Cookies |
buyCookies(Money money)
Purchases Cookies with the specified money. |
Mints |
buyMints(Money money)
Purchases Mints with the specified money. |
int |
getNumberCookies()
Gets the number of Cookies in the snack machine. |
int |
getNumberMints()
Gets the number of Mints in the snack machine. |
Money |
getTotalMoney()
Gets the amount of Money in the snack machine. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SnackMachine()
SnackMachine
instance.
Creates an empty SnackMachine
devoid of any Cookies
,
Mints
and Money
.
Method Detail |
---|
public Mints buyMints(Money money)
Mints
with the specified money.
money
- the money for purchasing the Mints
.
Mints
from machine, or null
if an error occurs.public Cookies buyCookies(Money money)
Cookies
with the specified money.
money
- the money for purchasing the Cookies
.
Cookies
from machine, or null
if an error occurs.public boolean addCookies(CookieFlavors flavor, int numberCookies)
flavor
- the flavor of cookies to add.numberCookies
- the number of cookies to add.
true
if the addition was successful,
false
if not (e.g. the number of cookies
being added would put the SnackMachine
over
the limit).public boolean addMints(java.awt.Color color, int numberMints)
color
- the color of mints to add.numberMints
- the number of mints to add.
true
if the addition was successful,
false
if not (e.g. the number of mints
being added would put the SnackMachine
over
the limit).public int getNumberMints()
Mints
in the snack machine.
Mints
.public int getNumberCookies()
Cookies
in the snack machine.
Cookies
.public Money getTotalMoney()
Money
in the snack machine.
Money
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |