gui applications jcheckbox. contents a.problem: an order calculator for the brandi’s bagel house...
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](https://reader036.vdocument.in/reader036/viewer/2022062423/56649e965503460f94b99f6b/html5/thumbnails/1.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062423/56649e965503460f94b99f6b/html5/thumbnails/2.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062423/56649e965503460f94b99f6b/html5/thumbnails/3.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062423/56649e965503460f94b99f6b/html5/thumbnails/4.jpg)
• 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](https://reader036.vdocument.in/reader036/viewer/2022062423/56649e965503460f94b99f6b/html5/thumbnails/5.jpg)
• 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](https://reader036.vdocument.in/reader036/viewer/2022062423/56649e965503460f94b99f6b/html5/thumbnails/6.jpg)
![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](https://reader036.vdocument.in/reader036/viewer/2022062423/56649e965503460f94b99f6b/html5/thumbnails/7.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062423/56649e965503460f94b99f6b/html5/thumbnails/8.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062423/56649e965503460f94b99f6b/html5/thumbnails/9.jpg)
• 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](https://reader036.vdocument.in/reader036/viewer/2022062423/56649e965503460f94b99f6b/html5/thumbnails/10.jpg)
![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](https://reader036.vdocument.in/reader036/viewer/2022062423/56649e965503460f94b99f6b/html5/thumbnails/11.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062423/56649e965503460f94b99f6b/html5/thumbnails/12.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062423/56649e965503460f94b99f6b/html5/thumbnails/13.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062423/56649e965503460f94b99f6b/html5/thumbnails/14.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062423/56649e965503460f94b99f6b/html5/thumbnails/15.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062423/56649e965503460f94b99f6b/html5/thumbnails/16.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062423/56649e965503460f94b99f6b/html5/thumbnails/17.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062423/56649e965503460f94b99f6b/html5/thumbnails/18.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062423/56649e965503460f94b99f6b/html5/thumbnails/19.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062423/56649e965503460f94b99f6b/html5/thumbnails/20.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062423/56649e965503460f94b99f6b/html5/thumbnails/21.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062423/56649e965503460f94b99f6b/html5/thumbnails/22.jpg)
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