I am taking a java course and one of the assignments is to make a basic order calculator, like the ones from a Restaurant, so far i was able to make it do everything but display the names of the foods.
here is the code:
public FlameBay ()
{
money = new DecimalFormat("0.00");
mp = new MenuItem[9];
mp[0] = new MenuItem("Egg Noodles", 1.0);
mp[1] = new MenuItem("Spaghetti", 0.95);
mp[2] = new MenuItem("Ramen", 0.5);
mp[3] = new MenuItem("Beef", 2);
mp[4] = new MenuItem("Chicken", 1.5);
mp[5] = new MenuItem("Pork", 1.25);
mp[6] = new MenuItem("Kung Pao", 0.5);
mp[7] = new MenuItem("Teriyaki", 0.25);
mp[8] = new MenuItem("Curry", 0.45);
LayoutManager some_layout = new BorderLayout();
setLayout(some_layout);
add(r,BorderLayout.CENTER);
add(clear,BorderLayout.NORTH);
add(checkout,BorderLayout.SOUTH);
comp_callback dosomthing = new comp_callback();
checkout.addActionListener(dosomthing...
clear.addActionListener(dosomthing);
JPanel center_panel = new JPanel();
LayoutManager some_layout2 = new GridLayout(3,3);
center_panel.setLayout(some_layout2);
MenuItem amenuitem[] = mp;
int x = amenuitem.length;
for(int y = 0; y < x; y++)
{
MenuItem menuitem = amenuitem[y];
menuitem.addActionListener(dosomthing);
center_panel.add(menuitem);
}
getContentPane().add(center_panel, "West");
setTitle("Flame Bay");
setSize(500,400 );
setDefaultCloseOperation(JFrame.EXIT_...
setVisible(true);
}
any suggestions?