PizzaMenu

java

School

University of Victoria *

*We aren’t endorsed by this school

Course

115

Subject

Computer Science

Date

Nov 24, 2024

Type

java

Pages

3

Uploaded by MateLapwing4062

Report
/* * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template */ package pizza; import javafx.application.Application; import javafx.collections.ObservableList; import javafx.geometry.Insets; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.CheckBox; import javafx.scene.control.Label; //import javafx.scene.layout.FlowPane; import javafx.stage.Stage; import javafx.scene.layout.GridPane; //import javafx.scene.layout.VBox; //import javafx.geometry.Pos; //import javafx.scene.layout.BorderPane; /** * * @author Rolla Elsayed * Date: 24/12/22 */ public class PizzaMenu extends Application { @Override public void start(Stage stage){ //VBox layout = new VBox(10); //BorderPane pane = new BorderPane(); // //Scene scener = new Scene(pane, 300,300); // // //layout.setStyle("-fx-background-color: yellow;"); CheckBox chkPepperoni = new CheckBox("Pepperoni"); CheckBox chkExtraCheese = new CheckBox("Extra Cheese"); CheckBox chkGreenPepper = new CheckBox("Green Pepper"); CheckBox chkSusages = new CheckBox("Susages"); CheckBox chkOnions = new CheckBox("Onions"); CheckBox chkAnchoives = new CheckBox("Anchioves"); Label price = new Label("Total Cost: "); //Creating the stop button Button calculate = new Button("Place Order"); //Grid GridPane gridpane = new GridPane(); gridpane.add(chkPepperoni,0,0,1,2); gridpane.add(chkExtraCheese,0,1,1,2); gridpane.add(chkGreenPepper,1,0,1,2);
gridpane.add(chkSusages,1,1,1,2); gridpane.add(chkOnions,2,0,1,2); gridpane.add(chkAnchoives,2,1,1,2); //Instantiating the HBox class //HBox hbox = new HBox(); //Setting the space between the nodes of a HBox pane //hbox.setSpacing(10); //Setting the margin to the nodes //hbox.setMargin(chkPepperoni, new Insets(10, 10, 10, 10)); //hbox.setMargin(chkExtraCheese, new Insets(10,10,10,10)); //hbox.setMargin(chkGreenPepper, new Insets(10,10,10,10)); //hbox.setMargin(chkSusages, new Insets(10,10,10,10)); //hbox.setMargin(chkOnions, new Insets(10,10,10,10)); //hbox.setMargin(chkAnchoives, new Insets(10,10,10,10)); // //hbox.setMargin(price, new Insets(10, 10, 10, 10)); //hbox.setMargin(calculate, new Insets(10, 10, 10, 10)); //Verical checkbuttons //VBox vbox = new VBox(); //vbox.getChildren().add(price); //vbox.getChildren().add(chkPepperoni); // ////vbox.getChildren().add(new CheckBox("Pepperoni")); //vbox.getChildren().add(new CheckBox("Extra Cheese")); //vbox.getChildren().add(new CheckBox("Green Pepper")); //vbox.getChildren().add(new CheckBox("Susages")); //vbox.getChildren().add(new CheckBox("Onions")); //vbox.getChildren().add(new CheckBox("Anchioves")); //vbox.getChildren().add(new Button("Place Order")); //Rolla //retrieving the observable list of the HBox //ObservableList list = hbox.getChildren(); //Adding all the nodes to the observable list (HBox) //list.addAll(chkPepperoni,chkExtraCheese,chkGreenPepper,chkSusages,chkOnions,chkAn choives, calculate,price); calculate.setOnAction((event) -> { double pizzaPrice=10.00; if(chkSusages.isSelected()){ pizzaPrice+=0.50; }
if(chkPepperoni.isSelected()){ pizzaPrice+=0.50; } if(chkExtraCheese.isSelected()){ pizzaPrice+=0.50; } if(chkOnions.isSelected()){ pizzaPrice+=0.50; } if(chkAnchoives.isSelected()){ pizzaPrice+=0.50; } if(chkGreenPepper.isSelected()){ pizzaPrice+=0.50; } price.setText("Total Cost: $"+pizzaPrice); }); //Creating a scene object //Scene scene = new Scene(vbox, 300, 300); Scene scene = new Scene(gridpane, 240,100); //Setting title to the Stage stage.setTitle("Pizza Order"); //Adding scene to the stage stage.setScene(scene); //Displaying the contents of the stage stage.show(); } /** * @param args the command line arguments */ public static void main(String[] args) { launch(args); } }
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help