Project 1 - A Soda Machine
Due - Tuesday, October 18, 2005
The goal of this project is to give you an opportunity to practice
writing large programs that require you to employ object-oriented
design.
In this project, you will write a program to simulate a soda
machine. The soda machine will stock at least three different
kinds of soda. The interaction with the user will be as follows:
- The soda machine asks the user for the type of soda she wishes
to purchase.
- The user makes a selection.
- The soda machine displays the price of the selection.
- The user enters the amount she wishes to pay.
- The machine dispenses the soda and the user's change.
Implementation Guidelines
Your soda machine should consist of at least four classes. Your
design may include additional classes, and may extend the
functionality of the the following classes:
- Beverage - The Beverage class represents a single
beverage. Your soda machine will store several Beverage objects
and will reduce its inventory of Beverage objects by 1 each time a
Beverage is purchased.
- ChangeMaker - The ChangeMaker class will define the
functionality of an object that will keep track of all of the
money stored in the soda machine and will return the appropriate
change to the user when a purchase is made. The Constructor for
the ChangeMaker class should initialize the number of each
denomination of bill and coin stored in the soda machine to a
reasonable default value.
- Inventory - The Inventory class will define the
functionality of an object that will track all of the Beverage
objects stored in the soda machine. The Inventory Constructor
will create all of the Beverages initially stored in the soda
machine and will remove the appropriate Beverage each time a
purchase is made.
- UserInterface - The UserInterface class will define the
interaction with the user. The UserInterface object will receive
input from the user and will provide output to the user.
Make sure that you handle all error conditions. For example, your
program should appropriate handle the case when the machine is out
of a particular type of soda and the case when the appropriate
change cannot be dispensed.
For extra credit, implement several different types of Beverages.
To accomplish this, make the Beverage class abstract and
use inheritance to implement a derived class for each
specific type of Beverage.
Due Tuesday October 18, 2005
- Complete and submit your working code.
- Make sure that each function is well documented. Your documentation should specify the type and function of the input parameters and output.
- Run your program on a variety of inputs ensuring that all error conditions are handled correctly.
Note: No portion of your code may be copied from any other
source including another text book, a web page, or another
student (current or former). You must provide citations for any
sources you have used in designing and implementing your program.
Sami Rollins