Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here is my pizza order program(javafx),i want it to have function that can add pizza to cart and print the receipt import javafx.application.Application; import javafx.event.ActionEvent;

Here is my pizza order program(javafx),i want it to have function that can add pizza to cart and print the receipt import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Node; import javafx.scene.Scene; import javafx.scene.control.*; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.layout.GridPane; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; import javafx.stage.Stage; import java.awt.*; import java.util.ArrayList; public class PizzaApp extends Application { private RadioButton r1 = new RadioButton("Small"); private RadioButton r2 = new RadioButton("Medium"); private RadioButton r3 = new RadioButton("Large"); private CheckBox r4 = new CheckBox("Peppers"); private CheckBox r5 = new CheckBox("Onions"); private CheckBox r6 = new CheckBox("Mushrooms"); private CheckBox r7 = new CheckBox("Olives"); private CheckBox r8 = new CheckBox("Banana Peppers"); private CheckBox r9 = new CheckBox("None"); private CheckBox r10 = new CheckBox("Hams"); private CheckBox r11 = new CheckBox("Pepperoni"); private CheckBox r12 = new CheckBox("Sausage"); private CheckBox r13 = new CheckBox("Salami"); private CheckBox r14 = new CheckBox("Chicken"); private CheckBox r15 = new CheckBox("Steak"); private CheckBox r16 = new CheckBox("None"); private ToggleGroup size=new ToggleGroup(); private Button add=new Button("Add to cart"); private Button done=new Button("Done"); TitledPane SIZE,vegg,meats; double price = 0.00; Label P=new Label(); ArrayListcart=new ArrayList<>(); @Override public void start(Stage primaryStage) throws Exception { r1.setUserData("Small"); r2.setUserData("Medium"); r3.setUserData("Large"); size.getToggles().add(r1); size.getToggles().add(r2); size.getToggles().add(r3); //print the receipt  done.setOnAction(new pricehandler()); //add pizza to cart  //add.setOnAction(new addhandler());  VBox v1=new VBox(r1,r2,r3); SIZE = new TitledPane("Size:", v1); SIZE.setCollapsible(false); SIZE.setPrefHeight(75); GridPane VEGGIE=new GridPane(); VEGGIE.setHgap(10); VEGGIE.setVgap(10); VEGGIE.setPadding(new Insets(10, 10, 10, 10)); VEGGIE.addRow(0, r4); VEGGIE.addRow(1, r5); VEGGIE.addRow(2, r6); VEGGIE.addRow(3, r7); VEGGIE.addRow(4, r8); VEGGIE.addRow(5, r9); r4.setUserData("Peppers"); r5.setUserData("Onions"); r6.setUserData("Mushrooms"); r7.setUserData("Olives"); r8.setUserData("Banana Peppers"); r9.setUserData("None"); vegg = new TitledPane("Veggies:", VEGGIE); vegg.setPrefHeight(150); vegg.setCollapsible(false); VBox v2=new VBox(); v2.setPadding(new Insets(0)); v2.getChildren().addAll(vegg); GridPane MEATS=new GridPane(); MEATS.setHgap(10); MEATS.setVgap(10); MEATS.setPadding(new Insets(10, 10, 10, 10)); MEATS.addRow(0, r10); MEATS.addRow(1, r11); MEATS.addRow(2, r12); MEATS.addRow(3, r13); MEATS.addRow(4, r14); MEATS.addRow(5, r15); MEATS.addRow(6, r16); meats = new TitledPane("Meats:", MEATS); meats.setPrefHeight(150); meats.setCollapsible(false); VBox v3=new VBox(); v3.setPadding(new Insets(0)); v3.getChildren().addAll(meats); HBox h1=new HBox(SIZE,v2,v3); HBox h2=new HBox(add,done,P); VBox zong=new VBox(h1,h2); primaryStage.setTitle( "PIZZA" ); primaryStage.setMinHeight(150); primaryStage.setMinWidth(500); Scene s=new Scene(zong); primaryStage.setScene( s ); primaryStage.show(); for(int i=0;i<cart.size();i++){ System.out.println(cart.get(i)); } } public static void main(String[] args){ launch( args ); } private class pricehandler implements EventHandler { @Override public void handle(ActionEvent event) { if(r1.isSelected()){ price=price+10; }else if(r2.isSelected()){ price=price+11; }else if(r3.isSelected()){ price=price+12; } if(r4.isSelected()){ price=price+0.5; } if(r5.isSelected()){ price=price+0.5; } if(r6.isSelected()){ price=price+0.5; } if(r7.isSelected()){ price=price+0.5; } if(r8.isSelected()){ price=price+0.5; } if(r9.isSelected()){ price=price+0; } if(r10.isSelected()){ price=price+0.5; } if(r11.isSelected()){ price=price+0.5; } if(r12.isSelected()){ price=price+0.5; } if(r13.isSelected()){ price=price+0.5; } if(r14.isSelected()){ price=price+0.5; } if(r15.isSelected()){ price=price+0.5; } if(r16.isSelected()){ price=price+0; } double tax; tax=price*0.06; price=tax+price; P.setText("$"+new Double( price ).toString()); } } /* private class addhandler implements EventHandler{  @Override  public void handle(ActionEvent event) {  if(r1.isSelected()){  pizza p=new pizza(r1.getText(),vegg.getUserData().toString(),price);  cart.add(p);  }else if(r2.isSelected()){  pizza p=new pizza(r2.getText(),vegg.getUserData().toString(),price);  cart.add(p);  }else if(r3.isSelected()){  pizza p=new pizza(r3.getText(),vegg.getUserData().toString(),price);  cart.add(p);  }  price=0;  r1.setSelected(true);  r4.setSelected(false);  r5.setSelected(false);  r6.setSelected(false);  r7.setSelected(false);  r8.setSelected(false);  r9.setSelected(false);  r10.setSelected(false);  r11.setSelected(false);  r12.setSelected(false);  r13.setSelected(false);  r14.setSelected(false);  r15.setSelected(false);  r16.setSelected(false);  }  }*/  public class pizza{ String size; String top; double price; public pizza(String s,String t,double p){ this.size=s; this.top=t; this.price=p; } public String getSize(){ return size; } public void setSize(String s){ this.size=s; } public String getTop(){ return top; } public void setTop(String t){ this.top=t; } public double getPrice(){ return price; } public void setPrice(double p){ this.price=p; } } } 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Database Technology Edbt 88 International Conference On Extending Database Technology Venice Italy March 14 18 1988 Proceedings Lncs 303

Authors: Joachim W. Schmidt ,Stefano Ceri ,Michele Missikoff

1988th Edition

3540190740, 978-3540190745

More Books

Students also viewed these Databases questions

Question

What is a greenfield investment?

Answered: 1 week ago

Question

dy dx Find the derivative of the function y=(4x+3)5(2x+1)2.

Answered: 1 week ago

Question

Draw and explain the operation of LVDT for pressure measurement

Answered: 1 week ago

Question

Identify the different methods employed in the selection process.

Answered: 1 week ago

Question

Demonstrate the difference between ability and personality tests.

Answered: 1 week ago