Coffee Vending Machine Applet



Coffee Vending Machine Applet

Description

Our Group has designed and coded a coffee vending machine applet modeled after the actual machine on the 5th floor of the IS Building. This applet allows a user to choose a coffee, tea, hot chocolate, or French vanilla beverage. Then, the user may select light, heavy or no cream. After that, the user may select light, heavy or no sugar. The cost of the beverage is computed based on the actual beverage chosen and the options that were selected. The user then deposits coins via buttons and purchases their coffee.

Applet Behavior

This Applet is run through a web browser. The user selects their beverage of choice by clicking the radio buttons provided. Beverages are mutually exclusive. So, a user may only select one beverage at a time. When a user selects a beverage, the cost of the beverage is displayed in the Beverage Cost label. After the user selects their beverage, they may then choose to have light, heavy, or no cream added for a corresponding charge. Subsequently, they may choose to have light, heavy or no sugar added for another corresponding charge. These charges are displayed in the Options cost label and the Total Cost is adjusted accordingly.

Next, the user clicks on buttons to simulate the depositing of coins into a vending machine. The user may choose to deposit (i.e., click) dollars, quarters, dimes or nickels. If the user changes their mind, they may choose Reset, which simulates the returning of their money from the vending machine. As the user deposits money, the credit label is updated with their total input. Once the credit is higher than the beverage and options cost, the user may choose to purchase their beverage.

In order to purchase the beverage, the user clicks the purchase button; a graphic is then displayed to simulate the pouring of the beverage.

Applet Classes

Java Radio Buttons (JRadiobutton class) are used to simulate the selection of beverage and the beverage options (i.e., cream and sugar). The Radio Buttons are grouped via Java Button Groups (ButtonGroup class) so that only one beverage may be selected at a time. Likewise, the beverage cream and sugar options are grouped similarly.

Java Labels (Jlabel class) are used to display the cost of the beverage, option, and total. They are also used to display the user’s input credit.

Java Buttons (Jbutton class) are used to provide the user with a method for entering coins. Separate buttons are used for dollar, quarter, dime, and nickel inputs. Another button is provided to reset the credit charge, which effectively returns the user’s money to them. Finally, a purchase button is provided to simulate the pouring of the beverage.

Perini class was public used to define all of the variables and contained all of the code.

The GridBagLayout Class was used to layout the vending machine

Action Performed and Action Listener classes are used to determine what the user has selected (i.e., which radio buttons have been selected and what coins have been entered) or if the user has chosen to purchase their beverage or retrieve the coins entered.

Screen Shots

[pic]

As Java beginners one of the problems that we ran into included making our own image. We wanted to show a cup before the process empty and a full cup after. This proved to be very hard. We used images and changed them during different processes.

To Use: Open Applet.html file in ZIP. Enjoy.

Team Members and Roles

Dave Perini – Main Java Programmer

Mary Popeck – Java Support, Tester and Author

Jason Cowan – Designer, Tester, and Screen Shots

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download