/**
* @(#)chixmenu.java
*
* chixmenu Applet application
*
* @author
* @version 1.00 2010/9/10
*/
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.awt.font.*;
public class chixmenu extends Applet implements ActionListener
{
CheckboxGroup mainmenu;
Checkbox optChx, optPrk, optBef;
Checkbox chkChx1,chkChx2,chkChx3,chkPrk1,chkPrk2,chkPrk3,chkBef1,chkBef2,chkBef3;
Button setMenu, setOrder;
int trueTotal;
Label lblOrderInit, lblOrder1, lblOrder2, lblOrder3, lblOrderTotal, lblOrderTotalInit;
String order1,order2,order3;
String strTotal;
Font bigFont = new Font("Serif",Font.BOLD,50);
Font smallFont = new Font("Arial",Font.PLAIN,14);
public void init()
{
setLayout(null);
mainmenu = new CheckboxGroup();
optChx = new Checkbox("Chicken",false,mainmenu);
optPrk = new Checkbox("Pork",false,mainmenu);
optBef = new Checkbox("Beef",false,mainmenu);
chkChx1 = new Checkbox("Chicken Adobo - 35");
chkChx2 = new Checkbox("Fried Chicken - 30");
chkChx3 = new Checkbox("Chicken Teriyaki - 35");
chkPrk1 = new Checkbox("Lechong Baboy - 40");
chkPrk2 = new Checkbox("Dinuguan - 35");
chkPrk3 = new Checkbox("Porkchop - 30");
chkBef1 = new Checkbox("Beef Steak - 35");
chkBef2 = new Checkbox("Nilagang Baka - 40");
chkBef3 = new Checkbox("Beef Caldereta - 35");
setMenu = new Button("See Menu!");
setOrder = new Button("Order!");
lblOrderInit = new Label("Your order:");
lblOrderTotalInit = new Label ("Total:");
setMenu.addActionListener(this);
setOrder.addActionListener(this);
optChx.setBounds(10,10,100,25);
optPrk.setBounds(130,10,100,25);
optBef.setBounds(260,10,100,25);
setMenu.setBounds(130,50,100,25);
chkChx1.setBounds(10,90,300,25);
chkChx2.setBounds(10,120,300,25);
chkChx3.setBounds(10,150,300,25);
chkPrk1.setBounds(10,90,300,25);
chkPrk2.setBounds(10,120,300,25);
chkPrk3.setBounds(10,150,300,25);
chkBef1.setBounds(10,90,300,25);
chkBef2.setBounds(10,120,300,25);
chkBef3.setBounds(10,150,300,25);
setOrder.setBounds(10,180,100,25);
lblOrderInit.setBounds(10,220,100,25);
lblOrderTotalInit.setBounds(250,220,50,25);
lblOrder1 = new Label(order1);
lblOrder2 = new Label(order2);
lblOrder3 = new Label(order3);
lblOrderTotal = new Label(strTotal);
lblOrder1.setBounds(130,220,100,25);
lblOrder2.setBounds(130,250,100,25);
lblOrder3.setBounds(130,280,100,25);
lblOrderTotal.setBounds(250,220,80,80);
lblOrderTotal.setFont(bigFont);
add(lblOrder1);
add(lblOrder2);
add(lblOrder3);
add(lblOrderTotal);
add(optChx);
add(optPrk);
add(optBef);
add(setMenu);
trueTotal = 0;
order1 = " ";
order2 = " ";
order3 = " ";
}
public void paint(Graphics g)
{
}
public void actionPerformed (ActionEvent objEvent)
{
if (objEvent.getSource() == setMenu)
{
if (optChx.getState())
{
add(chkChx1);
add(chkChx2);
add(chkChx3);
chkPrk1.setState(false);
chkPrk2.setState(false);
chkPrk3.setState(false);
chkBef1.setState(false);
chkBef2.setState(false);
chkBef3.setState(false);
remove(chkPrk1);
remove(chkPrk2);
remove(chkPrk3);
remove(chkBef1);
remove(chkBef2);
remove(chkBef3);
add(setOrder);
add(lblOrderInit);
add(lblOrderTotalInit);
}
if (optPrk.getState())
{
add(chkPrk1);
add(chkPrk2);
add(chkPrk3);
chkChx1.setState(false);
chkChx2.setState(false);
chkChx3.setState(false);
chkBef1.setState(false);
chkBef2.setState(false);
chkBef3.setState(false);
remove(chkChx1);
remove(chkChx2);
remove(chkChx3);
remove(chkBef1);
remove(chkBef2);
remove(chkBef3);
add(setOrder);
add(lblOrderInit);
add(lblOrderTotalInit);
}
if (optBef.getState())
{
add(chkBef1);
add(chkBef2);
add(chkBef3);
chkChx1.setState(false);
chkChx2.setState(false);
chkChx3.setState(false);
chkPrk1.setState(false);
chkPrk2.setState(false);
chkPrk3.setState(false);
remove(chkChx1);
remove(chkChx2);
remove(chkChx3);
remove(chkPrk1);
remove(chkPrk2);
remove(chkPrk3);
add(setOrder);
add(lblOrderInit);
add(lblOrderTotalInit);
}
}
if (objEvent.getSource() == setOrder)
{
trueTotal = 0;
order1 = " ";
order2 = " ";
order3 = " ";
remove(lblOrder1);
remove(lblOrder2);
remove(lblOrder3);
remove(lblOrderTotal);
if(chkChx1.getState() == true)
{
trueTotal = trueTotal + 35;
}
if(chkChx2.getState() == true)
{
trueTotal = trueTotal + 30;
}
if(chkChx3.getState() == true)
{
trueTotal = trueTotal + 35;
}
if(chkPrk1.getState() == true)
{
trueTotal = trueTotal + 35;
}
if(chkPrk2.getState() == true)
{
trueTotal = trueTotal + 40;
}
if(chkPrk3.getState() == true)
{
trueTotal = trueTotal + 30;
}
if(chkBef1.getState() == true)
{
trueTotal = trueTotal + 40;
}
if(chkBef2.getState() == true)
{
trueTotal = trueTotal + 35;
}
if(chkBef3.getState() == true)
{
trueTotal = trueTotal + 35;
}
if (optChx.getState() == true)
{
if(chkChx1.getState() == true)
{
order1 = "Chicken Adobo";
}
if(chkChx2.getState() == true)
{
if (order1 == " ")
order1 = "Fried Chicken";
else
order2 = "Fried Chicken";
}
if(chkChx3.getState() == true)
{
if (order1 == "Chicken Adobo" & order2 == "Fried Chicken")
order3 = "Chicken Teriyaki";
else if ((order1 == "Chicken Adobo"|order1 == "Fried Chicken") & order2 == " ")
order2 = "Chicken Teriyaki";
else
order1 = "Chicken Teriyaki";
}
}
else if (optPrk.getState() == true)
{
if(chkPrk1.getState() == true)
{
order1 = "Lechong Baboy";
}
if(chkPrk2.getState() == true)
{
if (order1 == " ")
order1 = "Dinuguan";
else
order2 = "Dinuguan";
}
if(chkPrk3.getState() == true)
{
if (order1 == "Lechong Baboy" & order2 == "Dinuguan")
order3 = "Porkchop";
else if ((order1 == "Lechong Baboy"|order1 == "Dinuguan") & order2 == " ")
order2 = "Porkchop";
else
order1 = "Porkchop";
}
}
else if (optBef.getState() == true)
{
if(chkBef1.getState() == true)
{
order1 = "Beef Steak";
}
if(chkBef2.getState() == true)
{
if (order1 == " ")
order1 = "Nilagang Baka";
else
order2 = "Nilagang Baka";
}
if(chkBef3.getState() == true)
{
if (order1 == "Beef Steak" & order2 == "Nilagang Baka")
order3 = "Beef Caldereta";
else if ((order1 == "Beef Steak"|order1 == "Nilagang Baka") & order2 == " ")
order2 = "Beef Caldereta";
else
order1 = "Beef Caldereta";
}
}
//trueTotal = Integer.parseInt(strTotal);
strTotal = Integer.toString(trueTotal);
System.out.println("\n\ntrueTotal: "+trueTotal);
System.out.println("trueTotal Stringed: "+strTotal);
System.out.println("order1: "+order1);
System.out.println("order2: "+order2);
System.out.println("order3: "+order3+"\n\n");
lblOrder1 = new Label(order1);
lblOrder2 = new Label(order2);
lblOrder3 = new Label(order3);
lblOrderTotal = new Label(strTotal);
lblOrder1.setBounds(130,220,100,25);
lblOrder2.setBounds(130,250,100,25);
lblOrder3.setBounds(130,280,100,25);
lblOrderTotal.setBounds(250,220,80,80);
lblOrderTotal.setFont(bigFont);
add(lblOrder1);
add(lblOrder2);
add(lblOrder3);
add(lblOrderTotal);
}
}
}