java實(shí)現(xiàn)簡易外賣訂餐系統(tǒng)
用java實(shí)現(xiàn)簡易外賣訂餐系統(tǒng),供大家參考,具體內(nèi)容如下
一、使用技術(shù)
javaSE
二、實(shí)現(xiàn)功能
外賣訂餐系統(tǒng)
具體要求如下:
使用選擇結(jié)構(gòu),循環(huán)結(jié)構(gòu),數(shù)組的知識(shí)實(shí)現(xiàn)一個(gè)外賣訂餐系統(tǒng)
三、運(yùn)行效果圖
1.訂餐功能

2.查看餐袋

3.簽收訂單

4.刪除訂單

5.點(diǎn)贊

6.退出

代碼實(shí)現(xiàn)
public class Order {
public static void main(String[] args) {
int zero = 1;
int x = 0;//訂單數(shù)組下標(biāo)
String[] name = new String[100];
int[] time = new int[100];//點(diǎn)餐時(shí)間
String[] menu = new String[100];
double[] price = new double[100];
int[] od = new int[100];//訂單序號(hào)
String[] adress = new String[100];//送餐地址
int[] menuNum = new int[100];//點(diǎn)菜份數(shù)
String[] yuDing = new String[100];//訂單狀態(tài)
int a = 0;//點(diǎn)贊數(shù)
int b = 0;//點(diǎn)贊數(shù)
int c = 0;//點(diǎn)贊數(shù)
int panduan = 0;//判斷是否有此訂單
Scanner sc = new Scanner(System.in);
do {
System.out.println("歡迎使用“外賣訂餐系統(tǒng)”");
System.out.println("******************************");
System.out.println("1.我要訂餐");
System.out.println("2.查看餐袋");
System.out.println("3.簽收訂單");
System.out.println("4.刪除訂單");
System.out.println("5.我要點(diǎn)贊");
System.out.println("6.退出系統(tǒng)");
System.out.println("******************************");
System.out.println("請選擇:");
int num = sc.nextInt();
while (num < 1 || num > 6) {
System.out.println("您輸入的選項(xiàng)沒有,重新輸入");
num = sc.nextInt();
}
if (num == 1) {
od[x] = x + 1;
yuDing[x] = "已預(yù)訂";
System.out.println("***我要訂餐***");
System.out.println("請輸入訂餐人姓名:");
name[x] = sc.next();
System.out.println("序號(hào)" + " " + "菜名" + " " + "單價(jià)");
System.out.println(1 + " " + "紅燒茄子" + " " + 24.00);
System.out.println(2 + " " + "糖醋排骨" + " " + 36.00);
System.out.println(3 + " " + "魚香肉絲" + " " + 32.00);
System.out.println("請選擇您想要點(diǎn)的菜品編號(hào):");
int bianHao = sc.nextInt();
while (bianHao < 1 || bianHao > 3) {
System.out.println("您選擇的菜品沒有,再次輸入");
bianHao = sc.nextInt();
}
if (bianHao == 1) {
menu[x] = "紅燒茄子";
price[x] = 24.00;
} else if (bianHao == 2) {
menu[x] = "糖醋排骨";
price[x] = 36.00;
} else if (bianHao == 3) {
menu[x] = "魚香肉絲";
price[x] = 32.00;
}
System.out.println("請選擇您需要的份數(shù):");
menuNum[x] = sc.nextInt();
while (menuNum[x] < 1) {
System.out.println("您輸入的數(shù)量不合法,再次選擇");
menuNum[x] = sc.nextInt();
}
System.out.println("請選輸入送餐時(shí)間(送餐時(shí)間是10點(diǎn)至20點(diǎn)間整點(diǎn)送餐):");
time[x] = sc.nextInt();
while (time[x] < 10 || time[x] > 20) {
System.out.println("您選擇的時(shí)間不在送餐時(shí)間內(nèi),再次選擇");
time[x] = sc.nextInt();
}
System.out.println("請輸入送餐地址");
adress[x] = sc.next();
System.out.println("訂餐成功?。?!");
System.out.println("您訂的是:" + menu[x] + " " + menuNum[x] + "份");
System.out.println("送餐時(shí)間:" + time[x] + "點(diǎn)");
System.out.println("餐費(fèi):" + menuNum[x] * price[x] + "元" + " "
+ "送餐費(fèi):6元" + " " + "總計(jì):" + (menuNum[x] * price[x] + 6) + "元");
System.out.println("輸入0返回:");
zero = sc.nextInt();
while (zero != 0) {
System.out.println("輸入錯(cuò)誤,再次輸入");
zero = sc.nextInt();
}
x++;
} else if (num == 2) {
zero = 1;
System.out.println("***查看餐帶***");
System.out.println("序號(hào)" + " " + "訂餐人" + " " + "餐品信息"
+ " " + "送餐時(shí)間" + " " + "送餐地址"
+ " " + "總金額" + " " + "訂單狀態(tài)");
for (int i = 0; i < x; i++) {
if (od[i] != -1) {
System.out.println(od[i] + " " + name[i] + " " + menu[i]
+ " " + time[i] + " " + adress[i]
+ " " + (menuNum[i] * price[i] + 6)
+ " " + yuDing[i]);
}
}
System.out.println("輸入0返回:");
zero = sc.nextInt();
while (zero != 0) {
System.out.println("輸入錯(cuò)誤,再次輸入");
zero = sc.nextInt();
}
} else if (num == 3) {
zero = 1;
System.out.println("***簽收訂單***");
System.out.println("請選擇要簽收的訂單的序號(hào):");
int numc = sc.nextInt();
for (int i = 0; i < od.length; i++) {
if (numc == od[i]) {
yuDing[i] = "已簽收";
System.out.println("訂單簽收成功!");
panduan = 1;
}
}
if (panduan != 1) {
System.out.println("無此訂單");
}
System.out.println("輸入0返回:");
zero = sc.nextInt();
while (zero != 0) {
System.out.println("輸入錯(cuò)誤,再次輸入");
zero = sc.nextInt();
}
} else if (num == 4) {
zero = 1;
panduan = 0;
System.out.println("***刪除訂單***");
System.out.println("請選擇要?jiǎng)h除的訂單的序號(hào):");
int numd = sc.nextInt();
for (int i = 0; i < od.length; i++) {
if (numd == od[i]) {
od[i] = -1;
System.out.println("訂單刪除成功!");
panduan = 1;
}
}
if (panduan != 1) {
System.out.println("無此訂單");
}
System.out.println("輸入0返回:");
zero = sc.nextInt();
while (zero != 0) {
System.out.println("輸入錯(cuò)誤,再次輸入");
zero = sc.nextInt();
}
} else if (num == 5) {
zero = 1;
System.out.println("***我要點(diǎn)贊***");
System.out.println("序號(hào)" + " " + "菜名" + " " + "單價(jià)");
System.out.println(1 + " " + "紅燒茄子" + " " + 24.00 + " " + a + "贊");
System.out.println(2 + " " + "糖醋排骨" + " " + 36.00 + " " + b + "贊");
System.out.println(3 + " " + "魚香肉絲" + " " + 32.00 + " " + c + "贊");
System.out.println("請選擇要點(diǎn)贊的菜品的序號(hào):");
int zan = sc.nextInt();
while (zan < 1 || zan > 3) {
System.out.println("您輸入的序號(hào)錯(cuò)誤,再次輸入");
zan = sc.nextInt();
}
if (zan == 1) {
a++;
} else if (zan == 2) {
b++;
} else if (zan == 3) {
c++;
}
System.out.println("輸入0返回:");
zero = sc.nextInt();
while (zero != 0) {
System.out.println("輸入錯(cuò)誤,再次輸入");
zero = sc.nextInt();
}
} else if (num == 6) {
zero = 1;
System.out.println("謝謝使用,歡迎下次光臨!");
return;
}
} while (zero == 0);
}
}
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
SpringBoot基于JAXB實(shí)現(xiàn)天地圖路徑規(guī)劃結(jié)果XML轉(zhuǎn)JSON
這篇文章主要為大家詳細(xì)介紹了SpringBoot如何基于JAXB實(shí)現(xiàn)將天地圖路徑規(guī)劃結(jié)果XML轉(zhuǎn)JSON功能,文中的示例代碼講解詳細(xì),需要的可以了解下2025-02-02
23種設(shè)計(jì)模式(12)java模版方法模式
這篇文章主要為大家詳細(xì)介紹了23種設(shè)計(jì)模式之java模版方法模式,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-11-11
使用Jenkins Pipeline自動(dòng)化構(gòu)建發(fā)布Java項(xiàng)目的方法
這篇文章主要介紹了使用Jenkins Pipeline自動(dòng)化構(gòu)建發(fā)布Java項(xiàng)目的方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2019-04-04
如何解決websocket開啟多個(gè)頁面訪問同一個(gè)連接會(huì)失效的問題
使用WebSocket時(shí),若多個(gè)頁面訪問同一個(gè)WebSocket連接可能會(huì)導(dǎo)致連接失效,遇到這個(gè)問題時(shí),可以通過在SpringBoot中使用@ServerEndpoint注解并添加@Component來解決,出現(xiàn)連接錯(cuò)誤通常是因?yàn)閃ebSocket連接接收到的是一個(gè)GET請求2024-09-09

