這個(gè)很簡單的啦,新建一個(gè)類專門放這些數(shù)據(jù)。
隴南ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)公司的ssl證書銷售渠道,可以享受市場價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:028-86922220(備注:SSL證書合作)期待與您的合作!
class?Order
{
int?id;
String?name;
double?price;
}
//在main方法中,新建存放數(shù)據(jù)的數(shù)組
Scanner?scan=new?Scanner(System.in);
Order[]?list=new?Order[5];
for(int?i=0;ilist.size();i++)
{
list[i]=new?Order();
//為每一個(gè)數(shù)據(jù)賦值,通過鍵盤或者預(yù)設(shè),這個(gè)你自己決定嘍
list[i].id=i+1;;
list[i].name=scan.next();
list[i].price=scan.nextDouble();
}
//不知道你是怎么安排業(yè)務(wù)邏輯的,我舉個(gè)例子
double?allPrice=0;
System.out.println("Input?the?id?of?food");
//循環(huán)...這里不好明寫,輸入id
int?now=scan.nextInt();
allPrice+=list[now-1].id;
//循環(huán)結(jié)束,輸出
System.out.println(allPrice);
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class MyMenu extends JFrame{
JMenuBar jmbar=new JMenuBar();
JMenu jmenu=new JMenu("顏色");
JMenuItem jmt1=new JMenuItem("紅色"),
jmt2=new JMenuItem("黃色"),
jmt3=new JMenuItem("藍(lán)色");
JPanel jp=new JPanel();
MyMenu(){
setTitle("菜單測試");
setSize(400,300);
setJMenuBar(jmbar);
jmbar.add(jmenu);
jmenu.add(jmt1);
jmenu.add(jmt2);
jmenu.add(jmt3);
add(jp);
jmt1.addActionListener(new MenuAction(this));
jmt2.addActionListener(new MenuAction(this));
jmt3.addActionListener(new MenuAction(this));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
public static void main(String[] args) {
new MyMenu();
}
}
class MenuAction implements ActionListener{
MyMenu m;
MenuAction(MyMenu m){
this.m=m;
}
public void actionPerformed(ActionEvent e){
String color=e.getActionCommand();
if(color=="紅色")m.jp.setBackground(Color.red);
else if(color=="黃色")m.jp.setBackground(Color.yellow);
else if(color=="藍(lán)色")m.jp.setBackground(Color.blue);
}
}
不知道你要什么事件代碼,我寫了個(gè)比較簡單的你看適合不。
import java.util.*;
public class s {
static int x,xx,y,yy; static double sum=0;
public static void main(String[] args)
{
String answer="y";double h=0;
Scanner input=new Scanner(System.in);
System.out.println("請輸入客戶數(shù):");
int m=input.nextInt();
int n=m*3;
tostring();
do
{
order();
h+=(s(x,xx))+(d(y,yy));
System.out.println("是否繼續(xù):");
answer=input.next();
if(answer.equals("n"))
break;
}while(true);
System.out.println(h+n);
}
static void tostring()
{
System.out.println("菜單");
System.out.println("食品:");
System.out.println("1咖喱牛肉飯¥40.00");
System.out.println("2壽司套餐¥65.00");
System.out.println("3揚(yáng)州市消防3米¥45.00");
System.out.println("4沙朗牛排和意大利面¥72.00");
System.out.println("5雞肉蔬菜卷¥42.00");
System.out.println("飲料:");
System.out.println("21軟飲料¥10.00");
System.out.println("22紅葡萄酒¥15.00");
System.out.println("23啤酒¥15.00");
}
static double s(int f,int x)
{
double p=0;
switch(f)
{
case 1:p=40.00;break;
case 2:p=65.00;break;
case 3:p=45.00;break;
case 4:p=72.00;break;
case 5:p=42.00;break;
}
sum=p*x;
return sum;
}
static double d(int f,int x)
{
double p=0;
switch(f)
{
case 21:p=10.00;break;
case 22:p=15.00;break;
case 23:p=15.00;break;
}
sum=p*x;
return sum;
}
static void order()
{
Scanner input=new Scanner(System.in);
System.out.println("請選擇食品:");
x=input.nextInt();
System.out.println("請選擇份數(shù):");
xx=input.nextInt();
System.out.println("請選擇飲料:");
y=input.nextInt();
System.out.println("請選擇瓶數(shù):");
yy=input.nextInt();
}
}
加分?。。。?!
文章標(biāo)題:點(diǎn)菜簡單java代碼 基于java的餐廳點(diǎn)餐系統(tǒng)
地址分享:http://jinyejixie.com/article44/dohphee.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站建設(shè)、動(dòng)態(tài)網(wǎng)站、虛擬主機(jī)、網(wǎng)頁設(shè)計(jì)公司、外貿(mào)建站、用戶體驗(yàn)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)