Assigned | Monday, March 7, 2011 |
Program Due | 11:59pm, Sunday, March 20, 2011 |
Weight | 7% |
Updates |
Monday, March 14th: A minor change was made to Project2.java such that the add
cookies/mints dialogs will now allow you to attempt to add up to 100 items at
a time. This should make testing the maximum number of cookies/mints cases
slightly easier. You may update your Project2.java to this newer
revision if you like.
|
To continue to gain experience in the following areas:
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 Project2.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¢ and come in virtually all colors (all of the mints in a single package are of the same color). Cookies cost 65¢ per bag and come in three flavors — chocolate chip, oatmeal, and lemon. When you purchase a package of mints, you will not know the color of the mints; when you purchase a bag of cookies, you will not know their flavor. 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 change drawer (number of nickels, dimes, quarters, and total amount of money).
Project2.java
requires a specific set of classes to be created
with specific public interfaces. We have generated Javadoc APIs (i.e. the
public interface) for the classes you are required to implement for this
project.
The following 2 classes have been provided for you on this assignment:
You are not permitted to make any changes to Project2.java or CookieFlavors.java.
However, you are welcome to add additional members/methods (public or private) to the other classes referenced in the Javadocs. Additionally, you are welcome to add additional helper classes as you see fit.Snack machine screen shots from the provided GUI can be found here:
Project2.java
and CookieFlavors.java
may be downloaded from this project description.
You must write all other classes. You MUST NOT edit these files.proj2
.SnackMachine.java
.
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.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 the class file into the files that use Color
objects.
import java.awt.Color;
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.
submit cs202 Proj2 <all .java files you create>
. Submit only your
.java files (not .class files or any other files). DO NOT submit
Project2.java
or CookieFlavors.java
. If either file is
submitted, it will be deleted before your project is graded.
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!