Java實(shí)現(xiàn)簡(jiǎn)單點(diǎn)餐系統(tǒng)
用Java實(shí)現(xiàn)簡(jiǎn)單點(diǎn)餐系統(tǒng),供大家參考,具體內(nèi)容如下
程序控制分析:
1、歡迎頁(yè)循環(huán):do-while
2、Scanner 控制輸入
3、選擇頁(yè)循環(huán):switch-case
要求:
訂單信息:String 二維數(shù)組
序號(hào)、姓名、餐品名稱、份數(shù)、價(jià)格、總價(jià)、地址、時(shí)間(10-20)、狀態(tài)(已預(yù)定、已完成)、熱度(int型)
簽收訂單:改變訂單狀態(tài),已預(yù)定可以簽收,如果已經(jīng)完成則不能再次簽收。
刪除訂單:不能刪除未完成訂單,序號(hào)要隨之改變。
我要點(diǎn)贊:對(duì)相應(yīng)的餐品點(diǎn)贊,并展示。
package Practice; import java.util.Scanner; public class Obj { ? ? public static void main(String[] args) { ? ? ? ? Scanner sc=new Scanner(System.in); ? ? ? ? String dishes[]={"紅燒肉","燒熊掌","清蒸魚","白斬雞","烤乳鴿"}; ? ? ? ? int price[]={58,88,45,56,44}; ? ? ? ? int honors[]={50,100,20,12,44}; ? ? ? ? int hot[]={5,4,3,2,0}; ? ? ? ? String orders[][]=new String[1024][]; ? ? ? ? int chose=0; ? ? ? ? System.out. println("歡迎關(guān)嶺紅浪漫餐廳"); ? ? ? ? do { ? ? ? ? ? ? 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("請(qǐng)選擇:"); ? ? ? ? ? ? chose=sc.nextInt(); //訂餐流程------------------------------------------------------------------------------------- ? ? ? ? ? ? switch (chose) { ? ? ? ? ? ? ? ? case 1: ? ? ? ? ? ? ? ? ? ? System.out.println("***我要訂餐***"); ? ? ? ? ? ? ? ? ? ? System.out.println("請(qǐng)輸入訂餐人姓名:"); ? ? ? ? ? ? ? ? ? ? String name=sc.next(); ? ? ? ? ? ? ? ? ? ? System.out.println("序號(hào) ? ? 菜品 ? ?單價(jià) ? 熱度"); ? ? ? ? ? ? ? ? ? ? for (int i = 0; i < dishes.length; i++) { ? ? ? ? ? ? ? ? ? ? ? ? System.out.println(i+1+"\t\t"+dishes[i]+"\t"+price[i]+"元\t"+"\t"+hot[i]); ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? int dishNum=0; ? ? ? ? ? ? ? ? ? ? do{ ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("菜品編號(hào)"); ? ? ? ? ? ? ? ? ? ? ? ? dishNum=sc.nextInt(); ? ? ? ? ? ? ? ? ? ? ? ? if ((dishNum<1||dishNum>dishes.length)){ ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("對(duì)不起,輸入有誤,請(qǐng)重新輸入!"); ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? }while (dishNum<1||dishNum>dishes.length); ? ? ? ? ? ? ? ? ? ? int pcs=0; ? ? ? ? ? ? ? ? ? ? do { ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("份數(shù)"); ? ? ? ? ? ? ? ? ? ? ? ? pcs=sc.nextInt(); ? ? ? ? ? ? ? ? ? ? ? ? if (pcs<1){ ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("對(duì)不起,輸入有誤,請(qǐng)重新輸入!"); ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? }while (pcs<1); ? ? ? ? ? ? ? ? ? ? int time; ? ? ? ? ? ? ? ? ? ? do { ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("送餐時(shí)間"); ? ? ? ? ? ? ? ? ? ? ? ? time=sc.nextInt(); ? ? ? ? ? ? ? ? ? ? ? ? if (time<10||time>22){ ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("對(duì)不起,輸入有誤,請(qǐng)重新輸入!"); ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? }while (time<10||time>22); ? ? ? ? ? ? ? ? ? ? System.out.println("地址"); ? ? ? ? ? ? ? ? ? ? String addres=sc.next(); ? ? ? ? ? ? ? ? ? ? System.out.println("success!"); ? ? ? ? ? ? ? ? ? ? System.out.println( ? ? ? ? ? ? ? ? ? ? ? ? ? ? "您定的商品信息是:" +dishes[dishNum]+ "\t" +dishNum+"份"); ? ? ? ? ? ? ? ? ? ? System.out.println("送餐時(shí)間為"+time); ? ? ? ? ? ? ? ? ? ? double cost=price[dishNum-1]*pcs; ? ? ? ? ? ? ? ? ? ? double sent=cost>50?0:6; ? ? ? ? ? ? ? ? ? ? double total=cost+sent; ? ? ? ? ? ? ? ? ? ? System.out.println("餐費(fèi)共計(jì)"+total+" 其中快遞費(fèi)"+sent+"元"); ? ? ? ? ? ? ? ? ? ? for (int i = 0; i < orders.length; i++) { ? ? ? ? ? ? ? ? ? ? ? ? if (orders[i]==null){ ? ? ? ? ? ? ? ? ? ? ? ? ? ? orders[i]=new String[3]; ? ? ? ? ? ? ? ? ? ? ? ? ? ? orders[i][0]=name+"\t"+dishes[dishNum-1]+"\t" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? +pcs+"份\t"+time+"\t"+addres+"\t"+cost+"元"; ?//orders第一存儲(chǔ) 菜品信息 ? ? ? ? ? ? ? ? ? ? ? ? ? ? orders[i][1]="已預(yù)定"; ? ? ? ? ? ? ? ? ? ? ?//orders第二存儲(chǔ) 訂單信息 ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? break; //查看餐袋------------------------------------------------------------------------------ ? ? ? ? ? ? ? ? case 2: ? ? ? ? ? ? ? ? ? ? System.out.println("***查看餐袋***"); ? ? ? ? ? ? ? ? ? ? System.out.println("序號(hào)\t訂餐人 ?餐品信息 時(shí)間 地址 總金額 ? ?訂單狀態(tài)"); ? ? ? ? ? ? ? ? ? ? for (int i = 0; i < orders.length; i++) { ? ? ? ? ? ? ? ? ? ? ? ? if (orders[i]!=null){ ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println(i+1+"\t"+orders[i][0]+"\t\t"+orders[i][1]); ? ? ? ? ? ? ? ? ? ? ? ? }else{ ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? break; //訂單簽收---------------------------------------------------------------------------- ? ? ? ? ? ? ? ? case 3: ? ? ? ? ? ? ? ? ? ? System.out.println("***簽收訂單***"); ? ? ? ? ? ? ? ? ? ? int num; ? ? ? ? ? ? ? ? ? ? int end=0; ? ? ? ? ? ? ? ? ? ? System.out.println("序號(hào)\t訂餐人 ?餐品信息 時(shí)間 地址 總金額 ? ?訂單狀態(tài)"); ? ? ? ? ? ? ? ? ? ? for (int i = 0; i < orders.length; i++) { ? ? ? ? ? ? ? ? ? ? ? ? if (orders[i]!=null){ ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println(i+1+"\t"+orders[i][0]+"\t\t"+orders[i][1]); ? ? ? ? ? ? ? ? ? ? ? ? }else{ ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? do { ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("請(qǐng)輸入要簽收訂單序號(hào):"); ? ? ? ? ? ? ? ? ? ? ? ? for (int i = 0; i < orders.length; i++) { ? ? ? ? ? ? ? ? ? ? ? ? ? ? if (orders[i]==null){ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? end=i+1; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? num=sc.nextInt(); ? ? ? ? ? ? ? ? ? ? ? ? if (num<0||num>end){ ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("輸入有誤"); ? ? ? ? ? ? ? ? ? ? ? ? }else if ("已預(yù)定".equals(orders[num-1][1])){ ? ? ? ? ? ? ? ? ? ? ? ? ? ? orders[num-1][1]="已完成"; ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("訂單已完成"); ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? ? ? }else{ ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("訂單已簽收,不能重復(fù)簽收"); ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? }while (num<1||num>end||"已預(yù)定".equals(orders[num-1][1])); ? ? ? ? ? ? ? ? ? ? break; //刪除訂單------------------------------------------------------------------------ ? ? ? ? ? ? ? ? case 4: ? ? ? ? ? ? ? ? ? ? System.out.println("***刪除訂單***"); ? ? ? ? ? ? ? ? ? ? int n=0; ? //輸入數(shù)字 ? ? ? ? ? ? ? ? ? ? int e=0; ?// 訂單的最大數(shù)量 ? ? ? ? ? ? ? ? ? ? System.out.println("序號(hào)\t訂餐人 \t餐品信息 \t送餐時(shí)間 \t地址 \t總金額 \t狀態(tài)"); ? ? ? ? ? ? ? ? ? ? for (int i = 0; i < orders.length; i++) { ? ? ? ? ? ? ? ? ? ? ? ? if (orders[i]!=null){ ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.print(i+1+"\t"+orders[i][0]+"\t"+orders[i][1]+"\t"); ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("\t ?"+orders[i][1]); ? ? ? ? ? ? ? ? ? ? ? ? }else{ ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? do { ? ? ? ? ? ? ? ? ? ? ? ? for (int i = 0; i < orders.length; i++) { ? ? ? ?//確定訂單的最大數(shù)量 ? ? ? ? ? ? ? ? ? ? ? ? ? ? if (orders[i]==null){ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? e=i; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("要?jiǎng)h除的訂單編號(hào):"); ? ? ? ? ? ? ? ? ? ? ? ? n=sc.nextInt(); ? ? ? ? ? ? ? ? ? ? if (n<1||n>e){ ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("err"); ? ? ? ? ? ? ? ? ? ? }else if ( ! "已完成".equals(orders[n-1][1])){ ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("訂單未完成,不能刪除"); ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? }else{ ? ? ? ? ? ? ? ? ? ? ? ? boolean isDelete=false; ? ? ? ? ? ? ? ? ? ? ? ? for (int i = n-1; i < orders.length; i++) { ? ? ? ? ? ? ? ? ? ? ? ? ? ? if (i==orders.length-1){ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? orders[i]=null; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? isDelete=true; ? ? ? ? ?// ? ? ? ? ? ? ? ? ? ? ? ? ? ? }else{ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? orders[i]=orders[i+1]; ? //前移 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? if (orders[i]==null){ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? isDelete=true; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? }while (n<1||n>e||"已完成".equals(orders[n][1])); ? ? ? ? ? ? ? ? ? ? break; //我要點(diǎn)贊---------------------------------------------------------------------------- ? ? ? ? ? ? ? ? case 5: ? ? ? ? ? ? ? ? ? ? System.out.println("***我要點(diǎn)贊***"); ? ? ? ? ? ? ? ? ? ? int hp=0; ? ? ? ? ? ? ? ? ? ? System.out.println("請(qǐng)選擇點(diǎn)贊菜品:"); ? ? ? ? ? ? ? ? ? ? hp=sc.nextInt(); ? ? ? ? ? ? ? ? ? ? if (hp<1||hp>dishes.length){ ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("對(duì)不起,輸入有誤,請(qǐng)重新輸入!"); ? ? ? ? ? ? ? ? ? ? }else{ ? ? ? ? ? ? ? ? ? ? ? ? hot[hp-1]++; ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? break; //退出系統(tǒng)------------------------------------------------------------------------------------ ? ? ? ? ? ? ? ? default: ? ? ? ? ? ? ? ? ? ? System.out.println("6、退出系統(tǒng)"); ? ? ? ? ? ? } //switch結(jié)束-------------------------------------------------------------------------------------- ? ? ? ? ? ? if (chose>0&&chose<6){ ? ? ? ? ? ? ? ? System.out.println("輸入0返回!"); ? ? ? ? ? ? ? ? chose=sc.nextInt(); ? ? ? ? ? ? }else { ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? } //----------------------------------------------------------------------------- ? ? ? ? }while (chose==0); ? ? ? ? System.out.println("輸入0返回!"); ? ? } }
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Java前后端分離的在線點(diǎn)餐系統(tǒng)實(shí)現(xiàn)詳解
- Java 實(shí)戰(zhàn)項(xiàng)目之在線點(diǎn)餐系統(tǒng)的實(shí)現(xiàn)流程
- Java 實(shí)戰(zhàn)項(xiàng)目之在線點(diǎn)餐系統(tǒng)的實(shí)現(xiàn)流程
- Java Swing實(shí)現(xiàn)餐廳點(diǎn)餐系統(tǒng)源碼(收藏版)
- Java實(shí)現(xiàn)KFC點(diǎn)餐系統(tǒng)過程解析
- Java實(shí)現(xiàn)餐廳點(diǎn)餐系統(tǒng)的實(shí)例代碼
- java實(shí)現(xiàn)可視化界面肯德基(KFC)點(diǎn)餐系統(tǒng)代碼實(shí)例
- java實(shí)現(xiàn)KFC點(diǎn)餐系統(tǒng)
相關(guān)文章
Java編程實(shí)現(xiàn)提取文章中關(guān)鍵字的方法
這篇文章主要介紹了Java編程實(shí)現(xiàn)提取文章中關(guān)鍵字的方法,較為詳細(xì)的分析了Java提取文章關(guān)鍵字的原理與具體實(shí)現(xiàn)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-11-11SpringBoot CountDownLatch多任務(wù)并行處理的實(shí)現(xiàn)方法
本篇文章主要介紹了SpringBoot CountDownLatch多任務(wù)并行處理的實(shí)現(xiàn)方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來(lái)看看吧2018-04-04springboot項(xiàng)目打成war包部署到tomcat遇到的一些問題
這篇文章主要介紹了springboot項(xiàng)目打成war包部署到tomcat遇到的一些問題,需要的朋友可以參考下2017-06-06Springboot+netty實(shí)現(xiàn)Web聊天室
這篇文章主要介紹了利用springboot+netty實(shí)現(xiàn)一個(gè)簡(jiǎn)單Web聊天室,文中有非常詳細(xì)的代碼示例,對(duì)正在學(xué)習(xí)Java的小伙伴們有非常好的幫助,需要的朋友可以參考下2021-12-12controller接口跳轉(zhuǎn)到另一個(gè)controller接口的實(shí)現(xiàn)
這篇文章主要介紹了controller接口跳轉(zhuǎn)到另一個(gè)controller接口的實(shí)現(xiàn)方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2021-09-09spring中的特殊注解@RequiredArgsConstructor詳解
這篇文章主要介紹了spring中的特殊注解@RequiredArgsConstructor,包括注解注入,構(gòu)造器注入及setter注入,結(jié)合示例代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下2022-04-04