java实现外卖订餐系统

网友投稿 244 2022-11-06


java实现外卖订餐系统

本文实例为大家分享了java实现外卖订餐系统的具体代码,供大家参考,具体内容如下

一、使用技术

javaSE

二、实现功能

外卖订餐系统

具体要求如下:

使用选择结构,循环结构,数组的知识实现一个外卖订餐系统

三、运行效果图

1.订餐功能

2.查看餐袋

3.签收订单

4.删除订单

5.点赞

6.退出

分析图片信息,可以看出我们需要创建一个菜单类,查看餐带类和点赞菜单类

1.首先我们创建一个菜单类,用来定义菜单的属性,使用到封装,构造方法,和toString方法。

public class Food {//菜单

@Override

public String toString() {

return "Food{" +

"num=" + num +

", name='" + name + '\'' +

", price=" + price +

'}';

}

private int num;

private String name;

private double price;

public Food() {

}

public Food(int num, String name, double price) {

this.num = num;

this.name = name;

this.price = price;

}

public int getNum() {

return num;

}

public void setNum(int num) {

this.num = num;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public double getPrice() {

return price;

}

public void setPrice(double price) {

this.price = price;

}

}

2.其次,我们在创建一个查看餐袋类

public class SeeFood {//查看餐带

private int num;//序号

private String name;//订餐人

//private String information;//信息

private String food;//菜品

private int num1;//份数

private int date;//送餐日期

private String address;//送餐地址

private double money;//金额

private String state;//订单状态

@Override

public String toString() {

return "SeeFood{" +

"num=" + num +

", name='" + name + '\'' +

", food='" + food + '\'' +

", num1=" + num1 +

", date='" + date + '\'' +

", address='" + address + '\'' +

", money=" + money +

", state='" + state + '\'' +

'}';

}

public int getNum() {

return num;

}

public void setNum(int num) {

this.num = num;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getFood() {

return food;

}

public void setFood(String food) {

this.food = food;

}

public int getNum1() {

return num1;

}

public void setNum1(int num1) {

this.num1 = num1;

}

public int getDate() {

return date;

}

public void setDate(int date) {

this.date = date;

}

public String getAddress() {

return address;

}

public void setAddress(String address) {

this.address = address;

}

public double getMoney() {

return money;

}

public void setMoney(double money) {

this.money = money;

}

public String getState() {

return state;

}

public void setState(String state) {

this.state = state;

}

public SeeFood() {

}

public SeeFood(int num, String name, String food,

int num1, int date, String address,

double money, String state) {

this.num = num;

this.name = name;

this.food = food;

this.num1 = num1;

this.date = date;

this.address = address;

this.money = money;

this.state = state;

}

}

3.再创建一个点赞菜单类

public class FabulousFood {//点赞菜单

private int num;//序号

private String name;

private double price;

private int numfabulous;//点赞序号

private String fabtlcYqulous;

@Override

public String toString() {

return "FabulousFood{" +

"num=" + num +

", name='" + name + '\'' +

", price=" + price +" "+

numfabulous +

fabulous + '\'' +

'}';

}

public FabulousFood() {

}

public FabulousFood(int num, String name, double price, int numfabulous, String fabulous) {

this.num = num;

this.name = name;

this.price = price;

this.numfabulous = numfabulous;

this.fabulous = fabulous;

}

public int getNum() {

return num;

}

public void setNum(int num) {

this.num = num;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public double getPrice() {

return price;

}

public void setPrice(double price) {

this.price = price;

}

public int getNumfabulous() {

return numfabulous;

}

public void setNumfabulous(int numfabulous) {

this.numfabulous = numfabulous;

}

public String getFabulous() {

return fabulous;

}

public void setFabulous(String fabulous) {

this.fabulous = fabulous;

}

}

4.创建点餐系统实现其功能,每个功能都使用方法来实现

import java.util.ArrayList;

import java.util.Iterator;

import java.util.Scanner;

public class OrderFood {//点餐

static Scanner sc=new Scanner(System.in);

static int date;//送餐时间

static int number=0;//餐带序号

public static void main(String[] args) {

ArrayList list = new ArrayList<>();

list.add(new Food(1, "红烧茄子", 24));

list.add(new Food(2, "红烧排骨", 36));

list.add(new Food(3, "鱼香肉丝", 32));

ArrayList list2 = new ArrayList<>();

list2.add(new FabulousFood(1, "红烧茄子", 24,0,"赞"));

list2.add(new FabulousFood(2, "红烧排骨", 36,0,"赞"));

list2.add(new FabulousFood(3, "鱼香肉丝", 32,0,"赞"));

ArrayList list1 = new ArrayList<>();

System.out.println(" 欢迎使用“外卖点餐系统”");

System.out.println("*******************************");

orderFood(list,list1,list2);

}

public static void orderFood(ArrayList list1,ArrayList list2,ArrayList list3){//点餐系统界面

// System.out.println(" 欢迎使用“外卖点餐系统”");

//System.out.println("*******************************");

System.out.println("1、我要点餐");

System.out.println("2、查看餐带");

System.out.println("3、签收订单");

System.out.println("4、删除订单");

System.out.println("5、我要点赞");

System.out.println("6、退出系统");

System.out.println(http://"*******************************");

System.out.println("请选择:");

String num=sc.next();

if (num.equals("1")){

orderingFood(list1,list2,list3);

}else if (num.equals("2")){

seeFood(list1, list2,list3);

}else if (num.equals("3")){

signFor(list1, list2,list3);

}else if (num.equals("4")){

deletFood(list1,list2,list3);

}else if (num.equals("5")){

fabulousFood(list1,list2,list3);

}else if (num.equals("6")){

System.out.println("谢谢使用,欢迎下次光临!");

return;

}else {

System.out.println("输出错误,请重新输入!");

orderFood(list1,list2,list3);

}

}

public static void fabulousFood(ArrayList list,ArrayList list2,ArrayList list3){//点赞

System.out.println("******我要点赞******");

System.out.println("序号 菜名 单价");

Iterator it = list3.iterator();

while (it.hasNext()){

System.out.println(it.next());

}

System.out.println("请选择您要点赞的菜品序号:");

int num=sc.nextInt();

for (int i = 0; i

if (num==list.get(i).getNum()){

list3.get(i).setNumfabulous((list3.get(i).getNumfabulous()+1));

}

}

System.out.println("点赞成功!");

System.out.println("输入0返回");

int b=sc.nextInt();

if (b==0){

orderFood(list,list2,list3);

}

}

public static void deletFood(ArrayList list,ArrayList list2,ArrayList list3){//删除订单

System.out.println("请输入要删除的订单序号");

int a=sc.nextInt();

for (int i = 0; i

if (a==list2.get(i).ghttp://etNum()){

list2.remove(list2.get(i));

}

}

System.out.println("删除订单成功!");

System.out.println("输入0返回");

int b=sc.nextInt();

if (b==0){

orderFood(list,list2,list3);

}

}

public static void signFor(ArrayList list,ArrayList list2,ArrayList list3){//签收订单

System.out.println("请输入要签收的的订单序号:");

int sign=sc.nextInt();

for (int i = 0; i

if (sign==(list.get(i).getNum())){

list2.get(i).setState("已签收");

}

}

System.out.println("订单签收成功!");

System.out.println("输入0返回");

int a=sc.nextInt();

if (a==0){

orderFood(list,list2,list3);

}

}

public static void seeFood(ArrayList list,ArrayList list2,ArrayList list3){//查看餐带

System.out.println("******查看餐带******");

System.out.println(" 序号 订餐人 餐品信息 送餐日期 " +

" 送餐地址 总金额 订单状态");

Iterator it = list2.iterator();

while (it.hasNext()){

System.out.println(it.next());

}

System.out.println("输入0返回");

int a=sc.nextInt();

if (a==0){

orderFood(list,list2,list3);

}

}

public static void orderingFood(ArrayList list1,ArrayList list2,ArrayList list3){//订餐

System.out.println("我要订餐");

System.out.println("请输入订餐人的姓名:");

String name=sc.next();

System.out.println("序号 菜名 单价");

Iterator it = list1.iterator();

while (it.hasNext()){

System.out.println(it.next());

}

System.out.println("请输入您要点的菜品编号");

int num=sc.nextInt();

System.out.println("请选择您需要的份数");

int num1=sc.nextInt();

foodDelilvery();

int num3=date;//送餐时间

System.out.println("请输入送餐地址");

String address=sc.next();

System.out.println("订餐成功!");

number++;//餐带序号

System.out.print("您订的是:");

String food=list1.get(num-1).getName();//菜品

System.out.println(food+" "+num1+"份");

System.out.println("送餐时间:"+date+"点");

double money=list1.get(num-1).getPrice()*num1;//餐费

System.out.println("餐费:"+money

+"元,送餐费6.0元,总计:"+(money+6)+"元");

//姓名,份数,时间,地址,菜品,餐费

list2.add(new SeeFood(number,name,food,num1,num3,address,(money+6),"已预定"));

System.out.println("输入0返回:");

String input=sc.next();

if (input.equals("0")){

orderFood(list1,list2,list3);

}else {

System.out.println("欢迎下次光临");

}

}

static public void foodDelilvery(){//送餐时间

System.out.println("请输入送餐的时间(送餐时间是10点至20点间整点送餐):");

int num2=sc.nextInt();

date=num2;

if (num2<10||num2>20){

System.out.println("不在送餐时间!");

foodDelilvery();

}

}

}

1.点餐功能

2.查看餐带

3.签收订单

4.删除订单

5.我要点赞

6.退出系统

if (num==list.get(i).getNum()){

list3.get(i).setNumfabulous((list3.get(i).getNumfabulous()+1));

}

}

System.out.println("点赞成功!");

System.out.println("输入0返回");

int b=sc.nextInt();

if (b==0){

orderFood(list,list2,list3);

}

}

public static void deletFood(ArrayList list,ArrayList list2,ArrayList list3){//删除订单

System.out.println("请输入要删除的订单序号");

int a=sc.nextInt();

for (int i = 0; i

if (a==list2.get(i).ghttp://etNum()){

list2.remove(list2.get(i));

}

}

System.out.println("删除订单成功!");

System.out.println("输入0返回");

int b=sc.nextInt();

if (b==0){

orderFood(list,list2,list3);

}

}

public static void signFor(ArrayList list,ArrayList list2,ArrayList list3){//签收订单

System.out.println("请输入要签收的的订单序号:");

int sign=sc.nextInt();

for (int i = 0; i

if (sign==(list.get(i).getNum())){

list2.get(i).setState("已签收");

}

}

System.out.println("订单签收成功!");

System.out.println("输入0返回");

int a=sc.nextInt();

if (a==0){

orderFood(list,list2,list3);

}

}

public static void seeFood(ArrayList list,ArrayList list2,ArrayList list3){//查看餐带

System.out.println("******查看餐带******");

System.out.println(" 序号 订餐人 餐品信息 送餐日期 " +

" 送餐地址 总金额 订单状态");

Iterator it = list2.iterator();

while (it.hasNext()){

System.out.println(it.next());

}

System.out.println("输入0返回");

int a=sc.nextInt();

if (a==0){

orderFood(list,list2,list3);

}

}

public static void orderingFood(ArrayList list1,ArrayList list2,ArrayList list3){//订餐

System.out.println("我要订餐");

System.out.println("请输入订餐人的姓名:");

String name=sc.next();

System.out.println("序号 菜名 单价");

Iterator it = list1.iterator();

while (it.hasNext()){

System.out.println(it.next());

}

System.out.println("请输入您要点的菜品编号");

int num=sc.nextInt();

System.out.println("请选择您需要的份数");

int num1=sc.nextInt();

foodDelilvery();

int num3=date;//送餐时间

System.out.println("请输入送餐地址");

String address=sc.next();

System.out.println("订餐成功!");

number++;//餐带序号

System.out.print("您订的是:");

String food=list1.get(num-1).getName();//菜品

System.out.println(food+" "+num1+"份");

System.out.println("送餐时间:"+date+"点");

double money=list1.get(num-1).getPrice()*num1;//餐费

System.out.println("餐费:"+money

+"元,送餐费6.0元,总计:"+(money+6)+"元");

//姓名,份数,时间,地址,菜品,餐费

list2.add(new SeeFood(number,name,food,num1,num3,address,(money+6),"已预定"));

System.out.println("输入0返回:");

String input=sc.next();

if (input.equals("0")){

orderFood(list1,list2,list3);

}else {

System.out.println("欢迎下次光临");

}

}

static public void foodDelilvery(){//送餐时间

System.out.println("请输入送餐的时间(送餐时间是10点至20点间整点送餐):");

int num2=sc.nextInt();

date=num2;

if (num2<10||num2>20){

System.out.println("不在送餐时间!");

foodDelilvery();

}

}

}

1.点餐功能

2.查看餐带

3.签收订单

4.删除订单

5.我要点赞

6.退出系统

if (a==list2.get(i).ghttp://etNum()){

list2.remove(list2.get(i));

}

}

System.out.println("删除订单成功!");

System.out.println("输入0返回");

int b=sc.nextInt();

if (b==0){

orderFood(list,list2,list3);

}

}

public static void signFor(ArrayList list,ArrayList list2,ArrayList list3){//签收订单

System.out.println("请输入要签收的的订单序号:");

int sign=sc.nextInt();

for (int i = 0; i

if (sign==(list.get(i).getNum())){

list2.get(i).setState("已签收");

}

}

System.out.println("订单签收成功!");

System.out.println("输入0返回");

int a=sc.nextInt();

if (a==0){

orderFood(list,list2,list3);

}

}

public static void seeFood(ArrayList list,ArrayList list2,ArrayList list3){//查看餐带

System.out.println("******查看餐带******");

System.out.println(" 序号 订餐人 餐品信息 送餐日期 " +

" 送餐地址 总金额 订单状态");

Iterator it = list2.iterator();

while (it.hasNext()){

System.out.println(it.next());

}

System.out.println("输入0返回");

int a=sc.nextInt();

if (a==0){

orderFood(list,list2,list3);

}

}

public static void orderingFood(ArrayList list1,ArrayList list2,ArrayList list3){//订餐

System.out.println("我要订餐");

System.out.println("请输入订餐人的姓名:");

String name=sc.next();

System.out.println("序号 菜名 单价");

Iterator it = list1.iterator();

while (it.hasNext()){

System.out.println(it.next());

}

System.out.println("请输入您要点的菜品编号");

int num=sc.nextInt();

System.out.println("请选择您需要的份数");

int num1=sc.nextInt();

foodDelilvery();

int num3=date;//送餐时间

System.out.println("请输入送餐地址");

String address=sc.next();

System.out.println("订餐成功!");

number++;//餐带序号

System.out.print("您订的是:");

String food=list1.get(num-1).getName();//菜品

System.out.println(food+" "+num1+"份");

System.out.println("送餐时间:"+date+"点");

double money=list1.get(num-1).getPrice()*num1;//餐费

System.out.println("餐费:"+money

+"元,送餐费6.0元,总计:"+(money+6)+"元");

//姓名,份数,时间,地址,菜品,餐费

list2.add(new SeeFood(number,name,food,num1,num3,address,(money+6),"已预定"));

System.out.println("输入0返回:");

String input=sc.next();

if (input.equals("0")){

orderFood(list1,list2,list3);

}else {

System.out.println("欢迎下次光临");

}

}

static public void foodDelilvery(){//送餐时间

System.out.println("请输入送餐的时间(送餐时间是10点至20点间整点送餐):");

int num2=sc.nextInt();

date=num2;

if (num2<10||num2>20){

System.out.println("不在送餐时间!");

foodDelilvery();

}

}

}

1.点餐功能

2.查看餐带

3.签收订单

4.删除订单

5.我要点赞

6.退出系统

if (sign==(list.get(i).getNum())){

list2.get(i).setState("已签收");

}

}

System.out.println("订单签收成功!");

System.out.println("输入0返回");

int a=sc.nextInt();

if (a==0){

orderFood(list,list2,list3);

}

}

public static void seeFood(ArrayList list,ArrayList list2,ArrayList list3){//查看餐带

System.out.println("******查看餐带******");

System.out.println(" 序号 订餐人 餐品信息 送餐日期 " +

" 送餐地址 总金额 订单状态");

Iterator it = list2.iterator();

while (it.hasNext()){

System.out.println(it.next());

}

System.out.println("输入0返回");

int a=sc.nextInt();

if (a==0){

orderFood(list,list2,list3);

}

}

public static void orderingFood(ArrayList list1,ArrayList list2,ArrayList list3){//订餐

System.out.println("我要订餐");

System.out.println("请输入订餐人的姓名:");

String name=sc.next();

System.out.println("序号 菜名 单价");

Iterator it = list1.iterator();

while (it.hasNext()){

System.out.println(it.next());

}

System.out.println("请输入您要点的菜品编号");

int num=sc.nextInt();

System.out.println("请选择您需要的份数");

int num1=sc.nextInt();

foodDelilvery();

int num3=date;//送餐时间

System.out.println("请输入送餐地址");

String address=sc.next();

System.out.println("订餐成功!");

number++;//餐带序号

System.out.print("您订的是:");

String food=list1.get(num-1).getName();//菜品

System.out.println(food+" "+num1+"份");

System.out.println("送餐时间:"+date+"点");

double money=list1.get(num-1).getPrice()*num1;//餐费

System.out.println("餐费:"+money

+"元,送餐费6.0元,总计:"+(money+6)+"元");

//姓名,份数,时间,地址,菜品,餐费

list2.add(new SeeFood(number,name,food,num1,num3,address,(money+6),"已预定"));

System.out.println("输入0返回:");

String input=sc.next();

if (input.equals("0")){

orderFood(list1,list2,list3);

}else {

System.out.println("欢迎下次光临");

}

}

static public void foodDelilvery(){//送餐时间

System.out.println("请输入送餐的时间(送餐时间是10点至20点间整点送餐):");

int num2=sc.nextInt();

date=num2;

if (num2<10||num2>20){

System.out.println("不在送餐时间!");

foodDelilvery();

}

}

}

1.点餐功能

2.查看餐带

3.签收订单

4.删除订单

5.我要点赞

6.退出系统


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:顺丰速运查询API(顺丰速运查询系统)
下一篇:时间查询API(时间查询怎么写)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~