+ All Categories
Home > Documents > GUI Applications JCheckBox. Contents A.Problem: An Order Calculator for the Brandi’s Bagel House...

GUI Applications JCheckBox. Contents A.Problem: An Order Calculator for the Brandi’s Bagel House...

Date post: 12-Jan-2016
Category:
Upload: asher-green
View: 227 times
Download: 0 times
Share this document with a friend
22
GUI Applications JCheckBox
Transcript
Page 1: GUI Applications JCheckBox. Contents A.Problem: An Order Calculator for the Brandi’s Bagel House B.Solution C.Exercise: Implementing a Separate Model.

GUI ApplicationsJCheckBox

Page 2: GUI Applications JCheckBox. Contents A.Problem: An Order Calculator for the Brandi’s Bagel House B.Solution C.Exercise: Implementing a Separate Model.

Contents

A. Problem: An Order Calculator for the Brandi’s Bagel House

B. Solution

C. Exercise: Implementing a Separate Model

Page 3: GUI Applications JCheckBox. Contents A.Problem: An Order Calculator for the Brandi’s Bagel House B.Solution C.Exercise: Implementing a Separate Model.

A. Problem: An Order Calculator for the Brandi’s Bagel House

• Brandi’s Bagel House has a bagel and coffee delivery service for the businesses in her neighborhood

• Customers may call in and order white and whole wheat bagels with a variety of toppings

• In addition, customers may order three different types of coffee (Delivery for coffee alone is not available, however)

Page 4: GUI Applications JCheckBox. Contents A.Problem: An Order Calculator for the Brandi’s Bagel House B.Solution C.Exercise: Implementing a Separate Model.

• Here is a complete price list– Bagels

• White bagel $1.25• Whole wheat bagel $1.50

– Toppings• Cream cheese $0.50• Butter $0.25• Peach jelly $0.75• Blueberry jam $0.75

– Coffee• Regular coffee $1.25• Decaf coffee $1.25• Cappuccino @2.00

Page 5: GUI Applications JCheckBox. Contents A.Problem: An Order Calculator for the Brandi’s Bagel House B.Solution C.Exercise: Implementing a Separate Model.

• Brandi, the owner, needs an “order calculator” application that her staff can use to calculate the price of an order as it is called in

• The application should display the subtotal, the amount of a 6% sales tax, and the total of the order

Page 6: GUI Applications JCheckBox. Contents A.Problem: An Order Calculator for the Brandi’s Bagel House B.Solution C.Exercise: Implementing a Separate Model.
Page 7: GUI Applications JCheckBox. Contents A.Problem: An Order Calculator for the Brandi’s Bagel House B.Solution C.Exercise: Implementing a Separate Model.

B. Solution

1. Developing the View

2. Implementing Event Handlers3.1. Implementing an event handler for the Exit

button

3.2. Implementing an event handler for the Calculate button

Page 8: GUI Applications JCheckBox. Contents A.Problem: An Order Calculator for the Brandi’s Bagel House B.Solution C.Exercise: Implementing a Separate Model.

2. Developing the View

• Project name: OrderCalculator• Class name: OrderCalculatorView• Package: ordercalculator• Frame title: Order Calculator

Page 9: GUI Applications JCheckBox. Contents A.Problem: An Order Calculator for the Brandi’s Bagel House B.Solution C.Exercise: Implementing a Separate Model.

• The Title Label• The Food and Drink Panel

– The Bagel Panel• 1 Button Group

– The White Radio Button– The Whole wheat Radio Button

– The Toppings Panel• 4 Check Boxes

– The Coffee Panel• 1 Button Group

– 4 Radio Buttons

• The Button Panel– 2 Buttons

Page 10: GUI Applications JCheckBox. Contents A.Problem: An Order Calculator for the Brandi’s Bagel House B.Solution C.Exercise: Implementing a Separate Model.
Page 11: GUI Applications JCheckBox. Contents A.Problem: An Order Calculator for the Brandi’s Bagel House B.Solution C.Exercise: Implementing a Separate Model.

3.1. Implementing an event handler for the Exit button

• This is an exercise for you

Page 12: GUI Applications JCheckBox. Contents A.Problem: An Order Calculator for the Brandi’s Bagel House B.Solution C.Exercise: Implementing a Separate Model.

3.2. Implementing an event handler for the Calculate button

3.2.1. Declaring the priceList map and implementing initPriceList()

3.2.2. Implementing getSubtotal()

3.2.3. Implementing the event handler

Page 13: GUI Applications JCheckBox. Contents A.Problem: An Order Calculator for the Brandi’s Bagel House B.Solution C.Exercise: Implementing a Separate Model.

3.2.1. Declaring the priceList map and implementing initPriceList()

Page 14: GUI Applications JCheckBox. Contents A.Problem: An Order Calculator for the Brandi’s Bagel House B.Solution C.Exercise: Implementing a Separate Model.

3.2.2. Implementing getSubtotal()

Page 15: GUI Applications JCheckBox. Contents A.Problem: An Order Calculator for the Brandi’s Bagel House B.Solution C.Exercise: Implementing a Separate Model.

3.2.3. Implementing the event handler

Page 16: GUI Applications JCheckBox. Contents A.Problem: An Order Calculator for the Brandi’s Bagel House B.Solution C.Exercise: Implementing a Separate Model.

Exercise

• Modify the application so that it has a separate Model class

Page 17: GUI Applications JCheckBox. Contents A.Problem: An Order Calculator for the Brandi’s Bagel House B.Solution C.Exercise: Implementing a Separate Model.

Solution

1. The Design

2. The View & Controller

3. The Model

4. The Data Transfer Object

Page 18: GUI Applications JCheckBox. Contents A.Problem: An Order Calculator for the Brandi’s Bagel House B.Solution C.Exercise: Implementing a Separate Model.

1. The Design

Bill- double subtotal- double tax- double total

<<Data Transfer Object>>

OrderCalculatorView- OrderCalculator

<<View & Controller>>

OrderCalculator<<Model>>

1

uses uses

1

Page 19: GUI Applications JCheckBox. Contents A.Problem: An Order Calculator for the Brandi’s Bagel House B.Solution C.Exercise: Implementing a Separate Model.

2. The View & Controller

Page 20: GUI Applications JCheckBox. Contents A.Problem: An Order Calculator for the Brandi’s Bagel House B.Solution C.Exercise: Implementing a Separate Model.

3. The Model

Page 21: GUI Applications JCheckBox. Contents A.Problem: An Order Calculator for the Brandi’s Bagel House B.Solution C.Exercise: Implementing a Separate Model.

4. The Data Transfer Object

Page 22: GUI Applications JCheckBox. Contents A.Problem: An Order Calculator for the Brandi’s Bagel House B.Solution C.Exercise: Implementing a Separate Model.

References

1. GUI Building in NetBeans IDE 5.5. http://testwww.netbeans.org/kb/55/quickstart-gui.html

2. Starting Out With Java 5 from control structures to objects. Tony Gaddis


Recommended