CMSC 202 Project 3

The UMBC Snack Machine Simulation

Assigned Monday March 23, 2009
Program Due 8:00AM, Monday April 13, 2008
Weight 8%
Updates  

Objectives


Project Description
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 project. 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.


Project Specification

Our mysterious vending machine sells only lollipops and bags of potato chips, both of which provided 94% of the recommended daily allowance of sugar required by college students everywhere. Lollipops (or simply "pops") cost 35 cents and come in virtually all colors. Chips cost 65 cents per bag and come in three flavors - plain, salt & vinegar, and barbeque (BBQ). When you purchase a lollipop you don't know what color it will be; when you purchase a bag of chips you don't know what flavor --- 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 lollipop" button or the "buy chips" 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 lollipop is purchased displays the color of the lollipop as part of the message. The "success message" when a bag of chips is purchased indicates the flavor. If the purchase fails the application diplays a "failure" message. Snack are sold in "first-in, first-out" order (oldest ones first) -- no one wants a stale bag of chips 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 lollipops and bags of chips, reporting the number of lollipops and bags of chips 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 Details

  1. The snack machine holds a maximum of 75 lollipops and 60 bags of chips.
  2. The application will not provide any explicit user input validation -- it's just taking the place of a student half asleep and writing code. All input validation must be performed by the snack machine execpt that no attempt will be made to overfill the machine with snacks.
  3. Your snack machine should accept exact change only.
  4. Because the snack machine only accepts exact change, the cash drawer is initially empty.
  5. The snack machine initially contains no lollipops or bags of chips.
Requirements and Hints
  1. Mr. Frey's public directory for this project is /afs/umbc.edu/users/f/r/frey/pub/202/Proj3/ Project3.java may be copied from Mr. Frey's directory when it is made available.
  2. (Requirement) Each file for this project must be part of the package named proj3.
  3. (Requirement) You must implement main( ) in your cash drawer class to perform unit testing. See Testing Your Class in Main for help writing main to test your class.
  4. (Requirement) All methods of the snack machine class must be fully commented including pre- and post-conditions.
  5. (Requirement) We will use Java's Color class to represent the colors of the lollipops. 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.
  6. (Requirement) An enumeration must be used for the flavors of the bags of chips.
  7. (Hint) Some of your classes may be immutable. That means that making copies of them is not necessary since "aliasing" does no harm. Use this fact to make your code easier, but be sure you can tell when it's safe.

10 Point Extra Credit
Because we have not yet completed our dicsussion 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
  1. Properly using inheritance and polymorphism in your design
  2. Properly writing code that takes advantage of your use of inheritance and polymorphism
  3. Submitting a plain text file (not .doc) file named ExtraCredit.txt (approx 1 "page" in length) that explains how and why your design uses inheritance and polymorphism. Include some mention of how your design and/or code is simpler as a result of using inheritance and polymorphism.
You are strongly encouraged to complete and submit the project without inheritance and polymorphism first before attempting the extra credit. That way you have a working project that can be graded in case you don't complete the extra credit assignment. Don't let a non-working or incomplete attempt at extra credit result in a lower project grade.
Project Policy
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 fall 2008. 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.


Grading
See the course website for a description of how your project will be graded.
Project Submission
  1. submit all .java files you create.. Submit only your .java files (not .class files or any other files). DO NOT submit Project3.java. If Project3.java is submitted it will be deleted before your project is graded.
  2. Use submitls to verify that your files are in your sumbittal directory
More complete documentation for submit and related commands can be found here.

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!