packageDFO;
Layout;
yout;
yout;
yout;
Event;
Listener;
edReader;
ption;
treamReader;
riter;
;
;
con;
n;
;
;
nPane;
;
ield;
publicclassmainMenu{
privatefinalintWIDTH=800;
privatefinalintHEIGHT=600;
privateJFramemainFrame;
privateJPanelcontrolPane;//下单,重置,结账
privateJPanelmenuPane;//各色菜单
privateJPanellistPane;//凉拌,热菜,主食
privateJButtonorder,ret,bill;
privateJPanelorderP,retP,billP;
privateJButtonsalad,dish,food;//三个切换按钮
privateJPanelsaladP,dishP,foodP;//要切换的三个JPanel
privateJPanelsaP1,saP2,saP3,saP4,saP5;
privateJButtonbtnMS1,btnMS2,btnMS3,btnMS4,btnMS5;
privateJTextField[]saladAmount;
privateJLabel[]saladText;
privateJButtonbtnPS1,btnPS2,btnPS3,btnPS4,btnPS5;
privateJPaneldiP1,diP2,diP3,diP4,diP5;
privateJButtonbtnMD1,btnMD2,btnMD3,btnMD4,btnMD5;
privateJButtonbtnPD1,btnPD2,btnPD3,btnPD4,btnPD5;
privateJTextField[]dishAmount;
privateJLabel[]dishText;
privateJPanelfoP1,foP2,foP3,foP4,foP5;
privateJButtonbtnMF1,btnMF2,btnMF3,btnMF4,btnMF5;
privateJButtonbtnPF1,btnPF2,btnPF3,btnPF4,btnPF5;
privateJTextField[]foodAmount;
privateJLabel[]foodText;
privateCardLayoutcard;
inti;
mainMenu()
{
mainFrame=newJFrame("桌面点餐系统");
out(newBorderLayout());
e(WIDTH,HEIGHT);
aultCloOperation(_ON_CLOSE);
ible(true);
controlPane=newJPanel(newGridLayout(3,1));
(controlPane,"East");
order=newJButton("下单");
ret=newJButton("重置");
bill=newJButton("结账");
orderP=newJPanel();
(order);
retP=newJPanel();
(ret);
billP=newJPanel();
(bill);
(orderP);
(retP);
(billP);
ionListener(newActionListener(){
@Override
publicvoidactionPerformed(ActionEvente){
for(i=0;i<5;i++)
saladAmount[i].tText("0");
for(i=0;i<5;i++)
dishAmount[i].tText("0");
for(i=0;i<5;i++)
foodAmount[i].tText("0");
}
});
ionListener(newAddUpAll());
ionListener(newSendOrderToServer());
listPane=newJPanel(newFlowLayout());
(listPane,"North");
salad=newJButton("凉菜");
dish=newJButton("热菜");
food=newJButton("主食");
(salad);
(dish);
(food);
saladP=newJPanel(newGridLayout(5,1));
saP1=newJPanel();
saP2=newJPanel();
saP3=newJPanel();
saP4=newJPanel();
saP5=newJPanel();
(saP1);
(saP2);
(saP3);
(saP4);
(saP5);
saladAmount=newJTextField[5];
for(i=0;i<5;i++)
saladAmount[i]=newJTextField("0",2);
saladText=newJLabel[5];
Iconicon=newImageIcon("");
JLabelsImage=newJLabel(icon);
(sImage);
btnMS1=newJButton("-");
btnPS1=newJButton("+");
ionLi防校园欺凌的手抄报 stener(newMinusOneListener());
ionCommand("101");
ionListener(newPlusOneListener());
ionCommand("101");
saladText[0]=newJLabel("101凉拌甜豆¥18元");
(btnMS1);
(saladAmount[0]);
(btnPS1);
(saladText[0]);
icon=newImageIcon("");
sImage=newJLabel(icon);
(sImage);
btnMS2=newJButton("-");
btnPS2=newJButton("+");
ionListener(newMinusOneListener());
ionCommand("102");
ionListener(newPlusOneListener());
ionCommand("102");
saladText[1]=newJLabel("102凉拌黄瓜¥15元");
(btnMS2);
(saladAmount[1]);
(btnPS2);
(saladText[1]);
icon=newImageIcon("");
sImage=newJLabel(icon);
(sImage);
btnMS3=newJButton("-");
btnPS3=newJButton("+");
ionListener(newMinusOneListener());
ionCommand("103");
ionListener(newPlusOneListener());
ionCommand("103");
saladText[2]=newJLabel(花茶搭配 "103凉拌猪耳¥28元");
(btnMS3);
(saladAmount[2]);
(btnPS3);
(saladText[2]);
icon=newImageIcon("");
sImage=newJLabel(icon);
(sImage);
btnMS4=newJButton("-");
btnPS4=newJButton("+");
ionListener(newMinusOneListener());
ionCommand("104");
ionListener(newPlusOneListener());
ionCommand("104");
saladText[3]=newJLabel("104凉拌牛肉¥28元");
(btnMS4);
(saladAmount[3]);
(btnPS4);
(saladText[3]);
icon=newImageIcon("");
sImage=newJLabel(icon);
(sImage);
btnMS5=newJButton("-");
btnPS5=newJButton("+");
ionListener(newMinusOneListener());
ionCommand("105");
ionListener(newPlusOneListener());
ionCommand("105");
saladText[4]=newJLabel("105凉拌皮蛋¥20元");
(btnMS5);
(saladAmount[4]);
(btnPS5);
(saladText[4]);
dishP=newJPanel(newGridLayout(5,1));
diP1=newJPanel();
diP2=newJPanel();
diP3=newJPanel();
diP4=newJPanel();
diP5=newJPanel();
(diP1);
(diP2);
(diP3);
(diP4);
(diP5);
dishAmount=newJTextField[5];
for(i=0;i<5;i++)
dishAmount[i]=newJTextField("0",2);
dishText=newJLabel[5];
icon=newImageIcon("");
sImage=newJLabel(icon);
(sImage);
btnMD1=newJButton("-");
btnPD1=newJButton("+");
ionListener(newMinusOneListener());
ionCommand("201");
ionListener(newPlusOneListener());
ionCommand("201")游戏惩罚大全 ;
dishText[0]=newJLabel("201红烧猪肉¥48元");
(btnMD1);
(dishAmount[0]);
(btnPD1);
(dishText[0]);
icon=newImageIcon("");
sImage=newJLabel(icon);
(sImage);
btnMD2=newJButton("-");
btnPD2=newJButton("+");
ionListener(newMinusOneListener());
ionCommand("202");
ionListener(newPlusOneListener());
ionCommand("202");
dishText[1]=newJLabel("202虎皮尖椒¥35元");
(btnMD2);
(dishAmount[1]);
(btnPD2);
(dishText[1]);
icon=newImageIcon("");
sImage=newJLabel(icon);
(sImage);
btnMD3=newJButton("-");
btnPD3=newJButton("+");
ionLis嗓子疼吃什么药好 tener(newMinusOneListener());
ionCommand特殊的反义词 ("203");
ionListener(newPlusOneListener());
ionCommand("203");
dishText[2]=newJLabel("203酸菜扣肉¥40元");
(btnMD3);
(dishAmount[2]);
(btnPD3);
(dishText[2]);
icon=newImageIcon("");
sImage=newJLabel(icon);
(sImage);
btnMD4=newJButton("-");
btnPD4=newJButton("+");
ionListener(newMinusOneListener());
ionCommand("204");
ionListener(newPlusOneListen作文四年级上册 er());
ionCommand("204");
dishText[3]=newJLabel("204番茄鸡蛋¥28元");
(btnMD4);
(dishAmount[3]);
(btnPD4);
(dishText[3]);
icon=newImageIcon("");
sImage=newJLabel(icon);
(sImage);
btnMD5=newJButton("-");
btnPD5=newJButton("+");
ionListener(newMinusOneListener());
ionCommand("205");
ionListener(newPlusOneListener());
ionCommand("205");
dishText[4]=newJLabel("205松鼠鲈鱼¥58元");
(btnMD5);
(dishAmount[4]);
(btnPD5);
(dishText[4]);
foodP=newJPanel(newGridLayout(5,1));
foP1=newJPanel();
foP2=newJPanel();
foP3=newJPanel();
foP4=newJPanel();
foP5=newJPanel();
(foP1);
(foP2);
(foP3);
(foP4);
(foP5);
foodAmount=newJTextField[5];
for(i=0;i<5;i++)
foodAmount[i]=newJTextField("0",2);
foodText=newJLabel[5];
icon=newImageIcon("");
sImage=newJLabel(icon);
(sImage);
btnMF1=newJButton("-");
btnPF1=newJButton("+");
ionListener(newMinusOneListener());
ionCommand("301");
ionListener(newPlusOneListener());
ionCommand("301");
foodText[0]=newJLabel("301米饭¥3元");
(btnMF1);
(foodAmount[0]);
(btnPF1);
(foodText[0]);
icon=newImageIcon("");
sImage=newJLabel(icon);
(sImage);
btnMF2=newJButton("-");
btnPF2=newJButton("+");
ionListener(newMinusOneListener());
ionCommand("302");
ionListener(newPlusOneListener());
ionCommand("302");
foodText[1]=newJLabel("302炒饭¥15元");
(btnMF2);
(foodAmount[1]);
(btnPF2);
(foodText[1]);
icon=newImageIcon("");
sImage=newJLabel(icon);
(sImage);
btnMF3=newJButton("-");
btnPF3=newJButton("+");
ionListener(newMinusOneListener());
ionCommand("303");
ionListener(newPlusOneListener());
ionCommand("303");
foodText[2]=newJLabel("303煎饼¥15元");
(btnMF3);
(foodAmount[2]);
(btnPF3);
(foodText[2]);
icon=newImageIcon("");
sImage=newJLabel(icon);
(sImage);
btnMF4=newJButton("-");
btnPF4=newJButton("+");
ionListener(newMinusOneListener());
ionCommand("304");
ionListener(newPlusOneListener());
ionCommand("304");
foodText[3]=newJLabel("304面条¥15元");
(btnMF4);
(foodAmount[3]);
(btnPF4);
(foodText[3]);
icon=newImageIcon("");
sImage=newJLabel(icon);
(sImage);
btnMF5=newJButton("-");
btnPF5=newJButton("+");
ionListener(newMinusOneListener());
ionCommand("305");
ionListener(newPlusOneListener());
ionCommand("305");
foodText[4]=newJLabel("305米线¥18元");
(btnMF5);
(foodAmount[4]);
(btnPF5);
(foodText[4]);
card=newCardLayout(5,5);
menuPane=newJPanel();
out(card);
(me关于毛泽东的诗词 nuPane,"West");
(saladP,"saladPane");
(dishP,"dishPane");
(foodP,"foodPane");
ionListener(newActionListener()
{
@Override
publicvoidactionPerformed(ActionEventarg0){
(menuPane,"saladPane");
}
});
ionListener(newActionListener()
{
@Override
publicvoidactionPerformed(ActionEventarg0){
(menuPane,"dishPane");
}
});
ionListener(newActionListener()
{
@Override
publicvoidactionPerform国家征信系统 ed(ActionEventarg0){
(menuPane,"foodPane");
}
});
();
}
classMinusOneListenerimplementsActionListener
{
@Override
publicvoidactionPerformed(ActionEvente){
StringcomString=ionCommand();
intID=nt(comString);
switch(ID){
ca101:
amountMinusOne(saladAmount[0]);break;
ca102:
amountMinusOne(saladAmount[1]);break;
ca103:
amountMinusOne(saladAmount[2]);break;
ca104:
amountMinusOne(saladAmount[3]);break;
ca105:
amountMinusOne(saladAmount[4]);break;
ca201:
amountMinusOne(dishAmount[0]);break;
ca202:
amountMinusOne(dishAmount[1]);break;
ca203:
amountMinusOne(dishAmount[2]);break;
ca204:
amountMinusOne(dishAmount[3]);break;
ca205:
amountMinusOne(dishAmount[4]);break;
ca301:
amountMinusOne(foodAmount[0]);break;
ca302:
amountMinusOne(foodAmount[1]);break;
ca303:
amountMinusOne(foodAmount[2]);break;
ca304:
amountMinusOne(foodAmount[3]);break;
ca305:
amountMinusOne(foodAmount[4]);break;
}
}
publicvoidamountMinusOne(JTextFieldjtf)
{
intt=nt(t());
t--;
t(((Integer)t).toString());
}
}
classPlusOneListenerimplementsActionListener
{
@Override
publicvoidactionPerformed(ActionEvente){
StringcomString=ionCommand();
intID=nt(comString);
switch(ID){
ca101:
amountPlusOne(saladAmount[0]);break;
ca102:
amountPlusOne(saladAmount[1]);break;
ca103:
amountPlusOne(saladAmount[2]);break;
ca104:
amountPlusOne(saladAmount[3]);break;
ca105:
amountPlusOne(saladAmount[4]);break;
ca201:
amountPlusOne(dishAmount[0]);break;
ca202:
amountPlusOne(dishAmount[1]);break;
ca203:
amountPlusOne(dishAmount[2]);break;
ca204:
amountPlusOne(dishAmount[3]);break;
ca205:
amountPlusOne(dishAmount[4]);break;
ca301:
amountPlusOne(foodAmount[0]);break;
ca302:
amountPlusOne(foodAmount[1]);break;
ca303:
amountPlusOne(foodAmount[2]);break;
ca304:
amountPlusOne(foodAmount[3]);break;
ca305:
amountPlusOne(foodAmount[4]);break;
}
}
publicvoidamountPlusOne(JTextFieldjtf)
{
intt=nt(t());
t++;
t(((Integer)t).toString());
}
}
classAddUpAllimplementsActionListener{
@Override
publicvoidactionPerformed(ActionEventarg0){
intamount;
Stringlabel;
inthead,tail;
intprice;
inttotal=0;
for(i=0;i<5;i++){
amount=nt(saladAmount[i].getText());
if(amount>0){
label=saladText[i].getText();
head=f("¥");
tail=f("元");
price=nt(ing(head+1,tail));
total=total+price*amount;
}
}
for(i=0;i<5;i++){
amount=nt(dishAmount[i].getText());
if(amount>0){
label=dishText[i].getText();
head=f("¥");
tail=f("元");
price=nt(ing(head+1,tail));
total=total+price*amount;
}
}
for(i=0;i<5;i++){
amount=nt(foodAmount[i].getText());
if(amount>0){
label=foodText[i].getText();
head=f("¥");
tail=f("元");
price=nt(ing(head+1,tail));
total=total+price*amount;
}
}
Stringmessage="总共消费"+total+"元";
ssageDialog(null,message);
}
}
classSendOrderToServerimplementsActionListener紫水晶的功效 {
@Override
publicvoidactionPerformed(ActionEvente){
Object[]options={"确定","取消"};
intresult=tionDialog(null,"确定要下单?","确
认",_CANCEL_OPTION,
ATION_MESSAGE,null,options,
options[0]);
if(result==0){
try{
SocketclientSocket=newSocket("127.0.0.1",4700);
PrintWriteros=new
PrintWriter(putStream());
BufferedReaderin=newBufferedReader(new
InputStreamReader(utStream()));
booleanNotReceived=true;
Stringm="";
inti,amount;
for(i=0;i<5;i++){
amount=nt(saladAmount[i].getText());
if(amount>0)
n(amount+"*"+saladText[i].getText());
}
for(i=0;i<5;i++){
amount=nt(dishAmount[i].getText());
if(amount>0)
n(amount+"*"+dishText[i].getText());
}
for(i=0;i<5;i++){
amount=nt(foodAmount[i].getText());
if(amount>0)
n(amount+"*"+foodText[i].getText());
}
n("EndOfTheOrder");
();
while(NotReceived){
m=ne();
if(("OrderConfirmed"))
NotReceived=fal;
}
ssageDialog(null,"你的订单已确认,请稍
等~厨房马上为你献上美味佳肴");
();
();
();
}catch(IOExceptione1){
//TODOAuto-generatedcatchblock
tackTrace();
}
}
}
}
}
packageDFO;
Event;
Listener;
ption;
riter;
;
nHostException;
nPane;
publicclassclient{
publicstaticvoidmain(Stringargs[])
{
newmainMenu();
}
}
本文发布于:2023-03-23 18:34:19,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/8d50023db5c81dd09e739763dcd73379.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:凉拌甜豆.doc
本文 PDF 下载地址:凉拌甜豆.pdf
留言与评论(共有 0 条评论) |