Assigned | Wednesday, October 20, 2010 |
Program Due | 10:00am, Monday, November 8, 2010 |
Weight | 8% |
Updates |
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 user interface 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 user interface. The user interface will be provided for you as Project3.java.
Our programmer's 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 because the machine is stocked by a group of pranksters from the Information Systems Department!
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!
There are responsibilities that come with having the snack machine on campus. 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 DetailsSnack machine screen shots can be found here:
Project3.java and CookieFlavors.java may be copied from this directory. You will write all other classes.
proj3
.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.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 that has been assigned before. Copying code from anyone is a violation of the project policy, even copying code from someone who was in CMSC 202 during a previous semester. Be advised that the programs that compare projects will compare your project with those from past semesters 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!