Question

In: Computer Science

******You do not need to get everything working exactly as it says, I mostly just need...

******You do not need to get everything working exactly as it says, I mostly just need an outline of how to create this GUI and add up the costs and print them all out. Any help at all will be greatly appreciated*******

********MUST BE IN JAVAFX**********

Design and implement a Java program that creates a GUI that will allow a customer to order pizza and other items from a Pizza Paarlor.  The customer should be able to order a variety of items which are listed below. The GUI should allow the customer (via JavaFX UI Controls - text areas, buttons, checkbox, radio button, etc.) to input the following information:

  • Customer Contact Info (Use text fields to input these from user)
    • First Name
    • Last Name
    • Phone Number
    • Address
  • Type of food that can be ordered are: (Use checkboxes to pick)
    • pizza
      • Small
      • Large
    • calzone
    • garlic knots
  • Quantity of each food item being ordered (Use text field that only accepts numbers to type in a number between 1 and 50)
    • Pizza toppings (Use checkboxes to pick)
      • Plain
      • Extra cheese
      • Mushrooms
      • Pepperoni

    Pricing (assign these prices to each item)

    Base Price for items :

  • Small Plain Pie –  $11.25
  • Large Plain Pie –  $14.00
  • Calzone - $7.75
  • Garlic Knots -$3.50
  • Additional fees for Toppings:

  • Small Pie - $2.00 per topping
  • Large Pie - $3.00 per topping

Conditions:

  • The GUI will have two buttons. The first will be used to create a running total of the current order. This button should be clicked every time an item is added to the order to give a current total of the order.
  • The second button will be used to print the following:
    • Customer Contact Info
    • All items and the quantity ordered
    • The grand total for the order

Solutions

Expert Solution

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import java.text.SimpleDateFormat;

import java.util.Date;

import javax.swing.event.ChangeEvent;

import javax.swing.event.ChangeListener;

import java.awt.event.ItemListener;

import java.awt.event.ItemEvent;

class GUI2 extends JFrame

{

private JRadioButton res, par;

private ButtonGroup group;

private JLabel logo_name, delivery_type, date_time, table_no, name, address, contact, toppings_label, quantity_label;

private ImageIcon logo;

private JTextField table_no_tf, name_tf, address_tf, contact_tf;

private JPanel input_panel, delivery_panel, toppings_panel, toppings2_panel, quantity_panel, initial_panel, buttons_panel;

private JPanel top1_panel, top2_panel;

private JCheckBox top_onion, top_mushroom, top_broccoli, top_corn, top_capsicum, top_cheese;

private JComboBox quantity_box;

String date;

public float rate = 80; //base rate is Rs.80

private JLabel quantity_op_label, quantity_op, rate_label, rate_op_label;

private JButton print, clear, calculate;

private ImageIcon print_icon, clear_icon;

private JLabel table_no_op, name_op, address_op, contact_op;

String table_no_str, name_str, address_str, contact_str;

private JLabel table_no2, name2, address2, contact2;

private JLabel date_time2;

private JLabel logo_name2;

public GUI2()

{

super("Pizza Palace");

setLayout(new FlowLayout(FlowLayout.CENTER, 30, 15));

logo = new ImageIcon("pizza.png");

logo_name = new JLabel("Pizza Palace", logo, 0);

initial_panel = new JPanel();

initial_panel.setLayout(new GridLayout(2, 1));  

  

JOptionPane.showMessageDialog(new JFrame(), "Welcome to Pizza Palace!", "Pizza Palace", JOptionPane.PLAIN_MESSAGE, logo);

  

//Logo Icon and Name

logo = new ImageIcon("pizza.png");

logo_name = new JLabel("Pizza Palace", logo, 0);  

initial_panel.add(logo_name);

  

//Date and Time

date = new SimpleDateFormat("EEEE yyyy-MM-dd hh:mm:ss a zzz").format(new Date());

date_time = new JLabel(date);

initial_panel.add(date_time);

add(initial_panel);

}

public void Input()

{  

input_panel = new JPanel();

input_panel.setLayout(new GridLayout(5, 2, 5, 5));

delivery_panel = new JPanel();

delivery_panel.setLayout(new GridLayout(1, 3));

  

//Delivery Type

delivery_type = new JLabel("Delivery Type:");

// delivery_panel.add(delivery_type);  

res = new JRadioButton("in-Restaurant");

res.setActionCommand("res");

par = new JRadioButton("Parcel");

par.setActionCommand("par");

  

  

group = new ButtonGroup();

group.add(res);

group.add(par);

delivery_panel.add(res);

delivery_panel.add(par);

  

// add(delivery_panel);

  

input_panel.add(delivery_type);

input_panel.add(delivery_panel);  

  

//Table Number

table_no = new JLabel("Table Number");  

table_no_tf = new JTextField("", 5);

input_panel.add(table_no);

input_panel.add(table_no_tf);   

  

//Parcel Details

name = new JLabel("Name");

address = new JLabel("Address");

contact = new JLabel("Contact Number");

name_tf = new JTextField("", 10);

address_tf = new JTextField("", 20);

contact_tf = new JTextField("", 10);

input_panel.add(name);

input_panel.add(name_tf);

input_panel.add(address);

input_panel.add(address_tf);

input_panel.add(contact);

input_panel.add(contact_tf);

  

add(input_panel);

  

  

// Disable Extra Labels & TextFields depending on RadioButton Selected

res.addChangeListener(new ChangeListener()

{

public void stateChanged(ChangeEvent arg0)

{

if(res.isSelected())

{

name.setEnabled(false);

address.setEnabled(false);

contact.setEnabled(false);

name_tf.setEditable(false);

address_tf.setEditable(false);

contact_tf.setEditable(false);

name_tf.setEnabled(false);

address_tf.setEnabled(false);

contact_tf.setEnabled(false);

table_no.setEnabled(true);

table_no_tf.setEnabled(true);

table_no_tf.setEditable(true);  

}

}

});

  

par.addChangeListener(new ChangeListener()

{

public void stateChanged(ChangeEvent arg0)

{

if(par.isSelected())

{

table_no.setEnabled(false);

table_no_tf.setEnabled(false);

table_no_tf.setEditable(false);

name.setEnabled(true);

address.setEnabled(true);

contact.setEnabled(true);

name_tf.setEditable(true);

address_tf.setEditable(true);

contact_tf.setEditable(true);

name_tf.setEnabled(true);

address_tf.setEnabled(true);

contact_tf.setEnabled(true);   

}

}

});   

}

public void Toppings()

{

top1_panel = new JPanel();

top1_panel.setLayout(new GridLayout(1, 3));

  

top2_panel = new JPanel();

top2_panel.setLayout(new GridLayout(1, 3));

  

toppings_panel = new JPanel();

toppings_panel.setLayout(new GridLayout(2, 1));

  

toppings2_panel = new JPanel();

toppings2_panel.setLayout(new GridLayout(2, 1));

  

toppings_label = new JLabel("Toppings:");

  

top_onion = new JCheckBox("Onion", false);

top_mushroom = new JCheckBox("Mushroom", false);

top_broccoli = new JCheckBox("Broccoli", false);

top_corn = new JCheckBox("Corn", false);

top_capsicum = new JCheckBox("Capsicum", false);

top_cheese = new JCheckBox("Cheese", false);

  

  

/* ActionListener actionListener = new ActionListener() {

public void actionPerformed(ActionEvent actionEvent) {

AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();

boolean selected = abstractButton.getModel().isSelected();

if(selected)

rate = rate + 15;

}

};

  

  

  

top_onion.addActionListener(actionListener);

top_mushroom.addActionListener(actionListener);

top_broccoli.addActionListener(actionListener);

top_corn.addActionListener(actionListener);

top_capsicum.addActionListener(actionListener);

top_cheese.addActionListener(actionListener);

*/

  

ItemListener itemListener = new ItemListener()

{

public void itemStateChanged(ItemEvent itemEvent)

{

AbstractButton abstractButton = (AbstractButton) itemEvent.getSource();

int state = itemEvent.getStateChange();

if(state == ItemEvent.SELECTED)

{

rate = rate + 15;

}

}

};

top_onion.addItemListener(itemListener);

top_mushroom.addItemListener(itemListener);

top_broccoli.addItemListener(itemListener);

top_corn.addItemListener(itemListener);

top_capsicum.addItemListener(itemListener);

top_cheese.addItemListener(itemListener);

  

top1_panel.add(top_onion);

top1_panel.add(top_mushroom);

top1_panel.add(top_broccoli);

top2_panel.add(top_corn);

top2_panel.add(top_capsicum);

top2_panel.add(top_cheese);

toppings_panel.add(top1_panel);

toppings_panel.add(top2_panel);

toppings2_panel.add(toppings_label);

toppings2_panel.add(toppings_panel);

add(toppings2_panel);

  

}

public void Quantity()

{

quantity_label = new JLabel("Quantity: ");

quantity_op_label = new JLabel("Quantity: ");

quantity_op = new JLabel();

quantity_panel = new JPanel();

quantity_panel.setLayout(new GridLayout(2, 2));

String[] quantity = {"1", "2", "3", "4", "5"};

  

JComboBox<String>quantity_box = new JComboBox<String>();

for(int i = 0; i < quantity.length; i++)  

quantity_box.addItem(quantity[i]);

  

quantity_box.setSelectedIndex(0);

  

quantity_panel.add(quantity_label);

quantity_panel.add(quantity_box);

  

  

quantity_box.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

quantity_op.setText((String)((JComboBox)e.getSource()).getSelectedItem());

}

});

  

add(quantity_panel);

}

public void Output()

{

print_icon = new ImageIcon("print.png");

clear_icon = new ImageIcon("clear.png");

  

buttons_panel = new JPanel();

buttons_panel.setLayout(new GridLayout(1, 2, 50, 10));

table_no2 = new JLabel("Table No.: ");

name2 = new JLabel("Name: ");

address2 = new JLabel("Address: ");

contact2= new JLabel("Contact Number: ");

  

  

  

String rate_str;

rate_str = Float.toString(rate);

rate_label = new JLabel("Rate: ");

rate_op_label = new JLabel(rate_str);

  

  

print = new JButton("Print");

print.setRolloverIcon(print_icon);

print.setRolloverEnabled(true);

clear = new JButton("Clear");

  

buttons_panel.add(print);

buttons_panel.add(clear);  

add(buttons_panel);

  

  

clear.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

table_no_tf.setText("");

name_tf.setText("");

address_tf.setText("");

contact_tf.setText("");

group.clearSelection();

name.setEnabled(true);

address.setEnabled(true);

contact.setEnabled(true);

name_tf.setEditable(true);

address_tf.setEditable(true);

contact_tf.setEditable(true);

name_tf.setEnabled(true);

address_tf.setEnabled(true);

contact_tf.setEnabled(true);

table_no.setEnabled(true);

table_no_tf.setEnabled(true);

table_no_tf.setEditable(true);

  

top_broccoli.setSelected(false);

top_capsicum.setSelected(false);

top_cheese.setSelected(false);

top_corn.setSelected(false);

top_mushroom.setSelected(false);

top_onion.setSelected(false);

  

}

});

  

print.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String rate_str;

rate_str = Float.toString(rate);

rate_label = new JLabel("Rate: ");

rate_op_label = new JLabel(rate_str);

JFrame output = new JFrame();

output.setLayout(new GridLayout(8, 2));

  

logo_name2 = new JLabel("Pizza Palace", logo, 0);  

output.add(logo_name2);   

date = new SimpleDateFormat("E yyyy-MM-dd HH:mm:ss").format(new Date());

date_time2 = new JLabel(date);

output.add(date_time2);   

  

table_no_str = table_no_tf.getText();

name_str = name_tf.getText();

address_str = address_tf.getText();

contact_str = contact_tf.getText();

  

table_no_op = new JLabel(table_no_str);

name_op = new JLabel(name_str);

address_op = new JLabel(address_str);

contact_op = new JLabel(contact_str);

  

output.add(table_no2);

output.add(table_no_op);

output.add(name2);

output.add(name_op);

output.add(address2);

output.add(address_op);

output.add(contact2);

output.add(contact_op);

  

output.add(rate_label);

output.add(rate_op_label);

output.add(quantity_op_label);   

output.add(quantity_op);

output.pack();

output.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

output.setLocationRelativeTo(null);

// output.setSize(100, 100);

output.setVisible(true);

  

JOptionPane.showMessageDialog(null, "Your Order Has Been Placed!");

}

});

  

}

}

class GUI

{

public static void main(String[] args)

{

GUI2 gui_obj = new GUI2();

gui_obj.Input();  

gui_obj.Toppings();

gui_obj.Quantity();

gui_obj.Output();

  

gui_obj.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

gui_obj.setLocationByPlatform(true);

gui_obj.setSize(575,600);

gui_obj.setVisible(true);

  

}

}


Related Solutions

******You do not need to get everything working exactly as it says, I mostly just need...
******You do not need to get everything working exactly as it says, I mostly just need an outline of how to create this GUI and add up the costs and print them all out. Any help at all will be greatly appreciated******* Design and implement a Java program that creates a GUI that will allow a customer to order pizza and other items from a Pizza Paarlor.  The customer should be able to order a variety of items which are listed...
I have the answers for everything, I just need for it to be explained as to...
I have the answers for everything, I just need for it to be explained as to why that's the answer. A 24-year old female automotive technician presents herself at the doctor’s office. She complains of fever and of pain in her left hand. On physical examination, the patient had a deep wound on her left palm that was oozing pus. She had purplish, red streaks running up her left arm. She had enlarged lymph nodes at the elbow and under...
What exactly does Sartre mean when he says that"if Goddoes not exist, then everything is...
What exactly does Sartre mean when he says that"if God does not exist, then everything is permitted"? Do you agree with him? Why or why not?
What exactly does Sartre mean when he says that "If God does not exist, then everything...
What exactly does Sartre mean when he says that "If God does not exist, then everything is permitted"? Do you agree with him? Why or why not?
Hey yall, Im working on a quiz I completed. I really need to get a 100...
Hey yall, Im working on a quiz I completed. I really need to get a 100 I worked all the problems out and i was wondering if one of yall would mind checking it for me. If i missed one if yall could tell me how to get the correct answer? 1.The intermolecular forces present in CH3NH2 include which of the following? I. dipole-dipole II. ion-dipole III. dispersion IV. hydrogen bonding ANS: I, III, and IV 2. A liquid boils...
please do not change the category. you just typing no drawing needed i need Just speed...
please do not change the category. you just typing no drawing needed i need Just speed and few sentences! its easy for you. problem 1) Describe the pros and cons between BJT the Voltage divider Bias, Emitter Bias, Collector Feedback Bias. 2) Compare the Voutput and current characteristics between BJT Early Effect, Fet Channel. And cause of that two.
Why do you think a third financial statement is important? Do we not get everything we...
Why do you think a third financial statement is important? Do we not get everything we need from the Balance Sheet and Income Statement? What information does the Cash Flow Statement give us that is unique, and why do investors need that information?
For my economy class I need to annswer these questions but I just dont get/cant find...
For my economy class I need to annswer these questions but I just dont get/cant find the right inf. The Presentville – Futureville case: 1. Explain what motivated each group to make the decisions they made.
I am currently working on this problem. It says it is wrong, and I was wondering...
I am currently working on this problem. It says it is wrong, and I was wondering if someone could correct my code to where its ouput is as followed. Expected Output: 6↵ 5↵ 4↵ 3↵ 2↵ 1 Actual Output: 9↵ 8↵ 7↵ 6↵ 5↵ 4↵ 3↵ 2↵ 1↵ 0↵ 9.10: Reverse Array Write a function that accepts an int array and the array’s size as arguments. The function should create a copy of the array, except that the element values...
I need to do a research paper on self-esteem and job performance. I just need some...
I need to do a research paper on self-esteem and job performance. I just need some ideas to get me started
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT