The Programmer's Late Night Snack Machine

Assigned Thursday, October 25th
Program Due Monday, November 12rd by 9:00am
Weight 8%
Updates There was a slight mistake in the Project3.java file. When one would purchase mints, the pop-up box would say, "Cookies Purchase" rather than "Mints Purchase". This has been corrected. Please download the Project3.java file again. Don't worry -- this will have no effect on any code that you have already written. (SMM, 11/4/12) When reporting the cash on hand (under the Cash Register Maintenance menu item), display the number of nickels, dimes, and quarters, and the total amount of cash in the machine (to two decimal points -- it's a monetary amount). Here's a sample screenshot. (SMM, 11/2)

Objectives

To continue to gain experience


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 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.


Project Specification

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 Details

  1. The snack machine holds a maximum of 75 packages of mints and 60 bags of cookies.
  2. The user interface code will not provide any explicit user input validation. All input validation must be performed by the snack machine, with the exception 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 mints or cookies.

The code for the Project3 and CookieFlavors classes can be found below. You are responsible for writing all other classes.

Snack machine screen shots can be found here:


Requirements and Hints

  1. (Requirement) Each file for this project must be part of a package named proj3.
  2. (Requirement) All classes that you implement must have a main( ) method. Unit test each class separately by using its main( ). See Testing Your Class in Main for help writing main to test your class.
  3. (Requirement) All files must have a class header comment with an appropriate class invariant(s).
  4. (Requirement) All methods of all classes that you write must have header comments, including pre- and post-conditions.
  5. (Requirement) We will use Java's 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.
  6. (Requirement) An enumeration must be used for the flavors of the bags of cookies.
  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.


Project Policy

This project is considered an OPEN project. Please review the open project policy before beginning your project.

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.


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 or CookieFlavors.java. If either file is submitted, it will be deleted before your project is graded.
  2. Use submitls to verify that your files are in your submittal 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!