Assigned | Wednesday, October 21, 2009 |
Program Due | 10:00am, Monday, November 9, 2009 |
Weight | 8% |
Updates | Monday, October 26 Project3.java and CookieFlavors.java have been placed in Ms. Mitchell's pub directory. Monday, October 26 Snack machine screen shots can be found here: Snack machine Snack machine maintenance Cash register maintenance |
In this project, you will be part of a team working on a simulation of a vending machine that sells snacks to hungry computer science students working late at night on their CMSC 202 projects. The simulation will be comprised of an application that uses the snack machine and a collection of classes that implement the snack machine's functionality. The application will be developed by another group of programmers. Your assignment is to design and implement the supporting classes.
Designing this project will be an in-class student exercise based on the specification below. In class, we will identify the classes necessary for the simulation and specify the required interface between these classes and the application. The application will eventually be provided for you as Project3.java.
Our mysterious vending machine sells only bags of cookies (for that late-night sugar boost) and breath mints (for some early morning freshness), both of which are necessities for computer science students everywhere. Breath mints cost 35 cents and come in virtually all colors (all of the mints in a single package are of the same color). Cookies cost 65 cents per bag and come in three flavors - chocolate chip, oatmeal, and lemon. When you purchase a package of mints, you don't know what color the mints will be; when you purchase a bag of cookies, you don't know what flavor they'll be -- that's the mystery!
To use the snack machine, the CMSC 202 student inserts some change (nickels, dimes and/or quarters only) and pushes either the "buy mints" button or the "buy cookies" button. If the student has inserted the correct amount of money and the snack machine is not sold out, the application displays a "success" message. The "success message" when a package of mints is purchased displays the color of the mints as part of the message. The "success message" when a bag of cookies is purchased indicates the flavor. If the purchase fails, the application displays a "failure" message. Snacks are sold in "first-in, first-out" order (oldest ones first) -- no one wants a stale bag of cookies at 4:30 in the morning!
The vending machine company application has responsibility for maintaining the snack machine. These responsibilites include stocking the snack machine by adding more mints and bags of cookies, reporting the number of packages of mints and bags of cookies currently in the machine, and reporting the contents of the cash drawer (number of nickels, dimes, quarters, and total amount of money).
Other Snack Machine Detailsproj3
.main( )
in your cash drawer class to perform unit testing.
See Testing Your Class in Main for help writing main
to test your class.Color
class to represent the colors of the mints.
Check out the Java API for details about this class. To use Java's Color
class in your code, you must import java.awt.Color
into the files that
use Color
objects.Because we have not yet completed our discussion of inheritance and polymorphism, they are not required for this project. However, if you think your design and code can be improved by using inheritance and polymorphism, here's your chance to give it a try. Ten (10) points of extra credit will be awarded for doing all of the following tasks.
This project is considered an OPEN project. Please review the OPEN project policy on the course website.
As you will no doubt discover, this project is a variation on a project from spring 2009. Copying code from anyone is a violation of the project policy, even copying code from someone who was in CMSC 202 last semester. Be advised that the programs that compare projects will compare your project with those from last semester as well as those from this semester.
See the course website for a description of how your project will be graded.
Remember -- if you make any change to your program, no matter how insignificant it may seem, you should recompile and retest your program before submitting it. Even the smallest typo can cause compiler errors and a reduction in your grade.
Avoid unpleasant surprises!