0

This one to be exact... i wonder if it's asking too much... it would help a lot of us... it's an activity that needs to be passed tomorrow, and it's an all or nothing activity... we'd rather have the perfect grade than zero...

THE PROBLEM is that, when we run this on cmd, it just says

Note: Order.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details...

import java.awt.GridLayout;
import java.awt.BorderLayout;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.ItemListener;
import java.awt.event.ItemEvent;

import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JRadioButton;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.ButtonGroup;
import javax.swing.JCheckBox;
import javax.swing.JPanel;

public class Order extends JFrame{

    private JLabel title;
    private JLabel size;
    private JLabel top;
    private JRadioButton b1;
    private JRadioButton b2;
    private JRadioButton b3;
    private JCheckBox c1;
    private JCheckBox c2;
    private JCheckBox c3;
    private JButton process;
    private ButtonGroup group;
    private JPanel p1;
    private JPanel p2;
    private JPanel p3;
    private double total;
    private boolean cb1 = false;
    private boolean cb2 = false;
    private boolean cb3 = false;
    private boolean cheese = false;
    private boolean tomato = false;
    private boolean mushroom = false;
    private String toppings = "Add-on Toppings: ";
    private double length = 0;
    private JList list;
    private boolean cf = false;
    private boolean tf = false;
    private boolean mf = false;
    private String sizeString;
    private String num;
    private String price = "Amount Due: ";
    private DefaultListModel tops;
    private double tprice;
    private String listData[] = new String [3];

public Order(){

    super ("");

    p1 = new JPanel();

    title = new JLabel("WELCOME TO HAUZ DINNERS");
    p1.add(title);

    add(p1, BorderLayout.NORTH);

    p2 = new JPanel();
    p2.setLayout(new GridLayout(4,2));

    size = new JLabel("Burger Size");
    p2.add(size);

    top = new JLabel("Each Add-on Toppings: $1.25");
    p2.add(top);

    b1 = new JRadioButton("Small: $3.50");
    p2.add(b1);

    b1.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
            total = 3.50;
            sizeString = "Burger Size: Small";
        }
    });

    c1 = new JCheckBox("Extra Cheese");
    p2.add(c1);

    c1.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
            if(c1.isSelected()){
                cheese = true;
            }
            else{
                cheese = false;
            }

            if(cheese == true){
                length++;
            }
            else{
                length--;
            }
        }
    });

    b2 = new JRadioButton("Medium: $4.50");
    p2.add(b2);

    b2.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
            total = 4.50;
            sizeString = "Burger Size: Medium";
        }
    });

    c2 = new JCheckBox("Tomato");
    p2.add(c2);

    c2.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
            if(c2.isSelected()){
                tomato = true;
            }
            else{
                tomato = false;
            }

            if(tomato == true){
                length++;
            }

            else{
                length--;
            }
        }
    });

    b3 = new JRadioButton("Large: $6.00");
    p2.add(b3);

    b3.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
            total = 6.00;
            sizeString = "Burger Size: Large";
        }
    });

    c3 = new JCheckBox("Mushrooms");
    p2.add(c3);

    c3.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
            if(c3.isSelected()){
                mushroom = true;
            }
            else{
                mushroom = false;
            }

            if(mushroom == true){
                length++;
            }

            else{
                length--;
            }
        }
    });

    group = new ButtonGroup();
    group.add(b1);
    group.add(b2);
    group.add(b3);

    add(p2, BorderLayout.CENTER);

    p3 = new JPanel();

    process = new JButton("Process Order");
    p3.add(process);

    process.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
            if(cheese == true){
                cf = true;
                if((cf == true)&&(tf != true)&&(mf != true)){
                    toppings = toppings + "Extra Cheese";
                }
                else{
                    toppings = toppings + ", Extra Cheese";
                }
            }
            if(tomato == true){
                tf = true;
                if((cf != true)&&(tf == true)&&(mf != true)){
                    toppings = toppings + "Tomato";
                }
                else{
                    toppings = toppings + ", Tomato";
                }
            }
            if(mushroom == true){
                mf = true;
                if((cf != true)&&(tf != true)&&(mf == true)){
                    toppings = toppings + "Mushrooms";
                }
                else{
                    toppings = toppings + ", Mushrooms";
                }
            }

            tprice = 1.25 * length;

            total = total + tprice;
            num = Double.toString(total);

            price = price + "$" + num;

            listData [0] = sizeString;
            listData [1] = toppings;
            listData [2] = price;

            list = new JList(listData);

            p3.add(list);
        }
    });



    add(p3, BorderLayout.SOUTH);

}

public static void main(String[]args){

    Order frame = new Order();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(350,220);
    frame.setVisible(true);

}

}

Lil' Dunno
  • 37
  • 4

0 Answers0