JAVA GUI AND OOP Overview: Java Swing is a lightweight Graphical User Interface (GUI) toolkit that includes a rich set of widgets. It includes package lets you make GUI components for your Java applications, and it is platform independent. In this activity, students will have an opportunity to design a GUI of a simple java program. Instruction: Create a program that would compute for the total amount of purchase based on user preferences. Design the user interface and the source code using object-oriented programming Requirements Design the user interface of the Pizza Ordering System. Sample interface design shown below (Design your own interface but use the same tools for every section) Pizza Ordering System Date July 05. 2019 Customer Available Pizza Mountain Pizza Regular Personal O Family O Pasta Spaghetti w/ Meatballs Supreme O Meat Lovers Special Pansit Bihon Pansit Palabok O Veggie Lovers Hawaiian Sotanghon Bacon Lovers 0 Drinks Glass/Mug Pitcher Crust type Thick Additional Cheese Beef Bacon O Drum Governor Pack Road, Baguio City Contact Number: 442-3316 Thin Details Compute Total Amount Amount Due: $643.50 Discount. $0.00 Tax (22%): $181 50 Close Application Pungratumer g: Diar Terrirgar , Total Amount $825.00 Compute the total amount that the customer will pay based on the following Price List: Pizza Supreme Meat Lovers Veggie Lovers Hawaiian Bacon Lovers Personal P 350 P 300 P 250 P 275 P 275 Regular P 550 P 500 P 450 P 400 P 400 Family P 1,000 P 850 P 600 P 750 P 800 If the customer orders Family Supreme pizza, the pizza would cost P1,000.00. If the customer orders another pizza, let say Regular Hawaiian pizza, add P400 to the cost. The total amount would be P1,400.00. Also, include in the total amount the additional orders (see table below) the customer might avail. Additional Order: Food Spaghetti with Meat ball P 95 Special Pansit Bihon P 50 Pansit Palabok P 75 Sotanghon P 60 Soft drinks in: Glass/Mug P 25 Picher P 65 Р 120 Additional: Cheese P100.00 Beef 250.00 Bacon 200.00 Dum In the details area, compute for the amount due which is 78% of the computed total amount, and the Tax which is 22% of computed the total amount. Source code must be in OOP style. Create classes of each type of pizza. In each class, encapsulate the prize by creating a private attribute. Use setter and getter method to pass the prize value to main class which is your interface (JFrame). You may use a simple conditional statement for additional orders and no need for a separate class. A practice activity is given as your guide. PRACTICE ACTIVITY: 1. Create a project Pizza and add a JFrame form. 2. Create a sub class of Pizza named Supreme. 3. Add a radiobutton, label and a button By default the names of the tools are as follows JRadioButton1 , JLabell and JButton1 4. Add the following code to Supreme class (Let's say prize = 280) package pizza; public class Supreme Pizza extends PizzaJFrame { private int prize; public void setPrize ) { this.prize= 280; } public int getPrize() { return prize; } 5. Go to your JFrame Form and double click JButtonl and add following code 85 Ç 86 87 88 89 private void jButtonlActionPerformed (java.awt.event. ActionEvent evt) if (RadioButtonl.isSelected()) { Supreme Pizza pl = new Supreme Pizza (); pl.set Prize(); jLabel1.setText (Integer.toString(pl.getPrize())); }else{ JOptionPane.showMessageDialog(this, "Other Pizza Type"); } 90 91 92 93 Note: The codes shaded in gray is automatically added by netbeans. NO NEED TO ADD ANOTHER ONE. Just add the if block. 6. Test the program. Click the button while the radio button is unchecked. A message box will appear. Test it again this time check radio button and click the button. The labell must display 280.
Comments
Leave a comment