CIS 120 GUI Lab
Overview
Given the success of all-day breakfast shops (donuts, bagels, cereal)
you and your friends would like to open the latest incarnation: All day
eggs!
As part of your plan you would like to have a simple way to calculate
the prices---a basic breakfast order consists of two eggs, any number
of toppings and one beverage. Customers should be able to specify how
their eggs should be cooked, what sort of condiments they would like
for their eggs, and what they want to drink (if anything). Your
application should calculate the price of this order, taking into
account the local sales tax rate.

[The "look and feel" of the application may be a little different depending
on your platform. The one above shows the default look on a Mac
platform. The windows version and linux version look slightly different.]
The price for a particular order should be determined by the following
price list:
Price
List
|
Sunnyside up
|
2.00
|
Scrambled
|
2.00
|
Over easy
|
1.50
|
Poached
|
2.00
|
|
|
Ketchup
|
0.20
|
Salt
|
0.10
|
Pepper
|
0.10
|
Cheese
|
1.00
|
Salsa
|
1.00
|
|
|
Coffee
|
2.00
|
Milk
|
1.50
|
Orange Juice
|
3.00
|
|
|
Tax rate
|
6%
|
Assignment
Your job is to write this application, contained in the class EggShop (which extends the class
javax.swing.JFrame), whose single, no-argument constructor opens the
400 x 250 pixel frame shown above. The main method in this class should
just use this constructor to create an instance of this class. Your
window should look exactly
like the one above, modulo any OS-based differences. The total price
displayed at the bottom of the window should always be correct (and
include sales tax) even as customers change their minds about their
orders. When the window is closed, the application should terminate.
Skeleton Files
And the javadocs.
Getting started: The OptionPanel Class
Start off by completing the OptionPanel class. If you need a reminder about CheckBoxes and Radio Buttons, read this Java tutorial.
Hints:
- We use a ButtonGroup object to tell Java that radio buttons should be grouped together, enforcing the rule that only one
of them can be selected at a time.
- Note that we chose to make the OptionPanel implement the
ActionListener interface, which requires a method
actionPerformed(ActionEvent e). This method gets called by Swing automaticaly when an event (mouseclick, etc.) occurs
inside the OptionPanel. What do you think should happen in this method?
Finishing Up: the EggShop Class
Now, move on to the EggShop class, where you will build the actual window, as well as add the price calculation functionality.
Hints: