Java外卖点餐系统「附全部代码」
Posted Java小叮当
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Java外卖点餐系统「附全部代码」相关的知识,希望对你有一定的参考价值。
前言
傻瓜式外卖点餐系统(无数据库)
tips:
- 菜品类(菜品id,菜品名,菜品类型,上架时间,单价,月销售,总数量)
- 管理员类(管理员id,账号,密码)
- 客户类(客户id,客户名,性别,密码,送餐地址,手机号,创建时间)
- 订单类(订单号,订单创建时间,菜品id,购买数,客户id,总价格,订单状态)
说明:
- 菜品类型可自行设计数据类型(int或String),如1:面食 2:米饭 3:湘菜 …
- 菜品上架时间、客户创建时间、订单创建时间根据添加时间自动分配系统时间
- 订单状态类型为int(0:未支付 1:已支付 2:配送中 3:已完成)
要求实现如下功能: - 实现不同角色用户登录系统
(1) 管理员登录系统看到如下菜单:① 添加菜品② 查看所有菜品信息(包含分页功能)③ 查看指定类别的菜品信息④ 根据菜品id修改菜品价格⑤ 删除指定id的菜品⑥ 添加客户⑦ 查看客户列表⑧ 删除指定id的客户⑨ 订单列表显示⑩ 根据订单id修改订单状态11 退出(2) 客户登录看到如下菜单:① 显示所有菜品(按菜品销量从高到低排序输出)-------->点餐(输入菜品id和购买数量)② 根据菜品类别显示所有菜品③ 查看所有订单(当前登录用户的)④ 修改密码(当前登录用户的)⑤ 个人信息显示
以上就是全部要求,首先咱们可以先建一个接口,方便对四个管理类进行操作;
package com.softeem.lesson23.test2;
import java.util.List;
public interface DAO<T>
void insert(T t);
T findById(String id);
List<T> findAll();
void delete(String id);
一、再根据要求,先把四个类的属性类建立起来:
1. Admin类(管理员类)
package com.softeem.lesson23.test2;
public class Admin
private String aID;
private String account;
private String apwd;
public Admin()
// TODO Auto-generated constructor stub
public Admin(String aID, String account, String apwd)
super();
this.aID = aID;
this.account = account;
this.apwd = apwd;
public String getaID()
return aID;
public void setaID(String aID)
this.aID = aID;
public String getAccount()
return account;
public void setAccount(String account)
this.account = account;
public String getApwd()
return apwd;
public void setApwd(String apwd)
this.apwd = apwd;
@Override
public String toString()
return "Admin [aID=" + aID + ", account=" + account + ", apwd=" + apwd + "]";
2. Dishes类(菜品类)
package com.softeem.lesson23.test2;
import java.time.LocalDate;
public class Dishes
private String dID;
private String dname;
private String dtype;
private LocalDate dtime;
private double price;
private int dsales;
private int dstocks;
public Dishes()
// TODO Auto-generated constructor stub
public Dishes(String dID, String dname, String dtype, LocalDate dtime, double price, int dsales, int dstocks)
super();
this.dID = dID;
this.dname = dname;
this.dtype = dtype;
this.dtime = dtime;
this.price = price;
this.dsales = dsales;
this.dstocks = dstocks;
public String getdID()
return dID;
public void setdID(String dID)
this.dID = dID;
public String getDname()
return dname;
public void setDname(String dname)
this.dname = dname;
public String getDtype()
return dtype;
public void setDtype(String dtype)
this.dtype = dtype;
public LocalDate getDtime()
return dtime;
public void setDtime(LocalDate dtime)
this.dtime = dtime;
public double getPrice()
return price;
public void setPrice(double price)
this.price = price;
public int getDsales()
return dsales;
public void setDsales(int dsales)
this.dsales = dsales;
public int getDstocks()
return dstocks;
public void setDstocks(int dstocks)
this.dstocks = dstocks;
@Override
public String toString()
return "Dishes [菜品id:" + dID + ", 菜品名:" + dname + ", 菜品类型:" + dtype + ", 上架时间:" + dtime + ", 单价:" + price
+ ", 月销量:" + dsales + ", 总数量:" + dstocks + "]";
3. Order类(订单类)
package com.softeem.lesson23.test2;
import java.time.LocalDateTime;
public class Order
private String OrderID;
private LocalDateTime utime;
private Dishes dishes;
private int Ordernum;
private String uID;
private Double Orderprice;
private int OrderValue;
public Order()
// TODO Auto-generated constructor stub
public Order(String orderID, LocalDateTime utime, Dishes dishes, int ordernum, String uID, Double orderprice,
int orderValue)
super();
OrderID = orderID;
this.utime = utime;
this.dishes = dishes;
Ordernum = ordernum;
this.uID = uID;
Orderprice = orderprice;
OrderValue = orderValue;
public String getOrderID()
return OrderID;
public void setOrderID(String orderID)
OrderID = orderID;
public LocalDateTime getUtime()
return utime;
public void setUtime(LocalDateTime utime)
this.utime = utime;
public Double getOrderprice()
return Orderprice;
public void setOrderprice(Double orderprice)
Orderprice = orderprice;
public Dishes getDishes()
return dishes;
public void setDishes(Dishes dishes)
this.dishes = dishes;
public int getOrdernum()
return Ordernum;
public void setOrdernum(int ordernum)
Ordernum = ordernum;
public String getuID()
return uID;
public void setuID(String uID)
this.uID = uID;
public int getOrderValue()
return OrderValue;
public void setOrderValue(int orderValue)
OrderValue = orderValue;
@Override
public String toString()
return "Order [OrderID=" + OrderID + ", utime=" + utime + ", dishes=" + dishes + ", Ordernum=" + Ordernum
+ ", uID=" + uID + ", Orderprice=" + Orderprice + ", OrderValue=" + OrderValue + "]";
4. User类(用户类)
package com.softeem.lesson23.test2;
import java.time.LocalDateTime;
public class User
private String uID;
private String uname;
private String usex;
private String upwd;
private String uadress;
private String utel;
private LocalDateTime utime;
public User()
// TODO Auto-generated constructor stub
public User(String uID, String uname, String usex, String upwd, String uadress, String utel, LocalDateTime utime)
super();
this.uID = uID;
this.uname = uname;
this.usex = usex;
this.upwd = upwd;
this.uadress = uadress;
this.utel = utel;
this.utime = utime;
public String getuID()
return uID;
public void setuID(String uID)
this.uID = uID;
public String getUname()
return uname;
public void setUname(String uname)
this.uname = uname;
public String getUsex()
return usex;
public void setUsex(String usex)
this.usex = usex;
public String getUpwd()
return upwd;
public void setUpwd(String upwd)
this.upwd = upwd;
public String getUadress()
return uadress;
public void setUadress(String uadress)
this.uadress = uadress;
public String getUtel()
return utel;
public void setUtel(String utel)
this.utel = utel;
public LocalDateTime getUtime()
return utime;
public void setUtime(LocalDateTime utime)
this.utime = utime;
@Override
public String toString()
return "User [uID=" + uID + ", uname=" + uname + ", usex=" + usex + ", upwd=" + upwd + ", uadress=" + uadress
+ ", utel=" + utel + ", utime=" + utime + "]";
这一步没什么难度,直接把每一个属性都设置一下,然后设置为私有,注意属性的数据类型,这个很重要,方便后期管理类对其进行操作。
二、属性管理类
这个是整个demo比较难得地方,我的想法是建立Admin属性管理类,Order属性管理类,Dishes属性类,User属性管理类,再在Admin属性管理类里把Order属性管理类,Dishes属性类,User属性管理类先new出来,然后,每个属性管理类实现各自的方法,只需要在Admin属性管理类中调用各个属性管理类的方法,就可以实现通过Admin类管理其他类的数据,但是,每个类需要建一个Map集合,存储各自的元素,此处应该注意每个属性管理类Map的键方便后期对Map进行操作,然后建立菜单类,规定User和Admin能调用的方法。
话不多说,直接上代码,一下代码是通过Admin管理类延伸的,所以先看Admin管理类。
1. Admin管理类
package com.softeem.lesson23.test2;
import java.time.LocalDate;
import java.time.LocalDateTime;
//import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
//import java.util.Set;
public class AdminSys implements DAO<Admin>
static Map<String, Admin> map = new HashMap<>();
// static Set<String> keys = map.keySet();
UserSys u = new UserSys();
OrderSys o = new OrderSys();
DishesSys d = new DishesSys();
Scanner sc = new Scanner(System.in);
/**
* 添加菜品
*/
public void addDishes()
System.out.println("请输入您要添加的菜品:(按照:菜品ID/菜品名/菜品类型/单价/月销量/总数量)");
String str = sc.next();
String[] info = str.split("/");
//
if (info.length < 6)
System.out.println("天啦撸,输入失败啦,请重新输入!");
addDishes();
else
LocalDate dtime = LocalDate.now();
Dishes t = new Dishes(info[0], info[1], info[2], dtime, Double.parseDouble(info[3]),
Integer.parseInt(info[4]), Integer.parseInt(info[5]));
d.insert(t);
System.out.println("小主,恭喜你!添加成功了");
/**
* 查看所有菜品信息(包含分页功能)
*/
public void showAllDishes(int pageSize)
List<Dishes> list = d.findAll();
int start = 0;
//先写一个死循环,进入else后break掉
while (true)
if (list.size() > (pageSize + start))
System.out.println(list.subList(start, pageSize + start));
else
System.out.println(list.subList(start, list.size()));
break;
start = start + pageSize;
/**
* 查看指定类别的菜品信息
*
*/
public void selecBytypeOfAdmin()
System.out.println("请输入您要查询菜品的类别:");
String typename = sc.next();
d.selectBytype(typename);
/**
* 根据菜品id修改菜品价格
*/
public void selectByDishesID()
System.out.println("请输入您要查询的菜品id:");
String id = sc.next();
Dishes dish = d.findById(id);
if (dish == null)
System.out.println("没有当前id的菜品呢");
else
System.out.println("当前菜品为:" + dish);
System.out.println("请输入新的菜品单价:");
double newprice = sc.nextDouble();
Dishes t = new Dishes(dish.getdID(), dish.getDname(), dish.getDtype(), dish.getDtime(), newprice,
dish.getDsales(), dish.getDstocks());
d.insert(t);
System.out.println("修改成功" + d.findById(t.getdID()));
/**
* 删除指定id的菜品
*
* @param args
*/
public void deleteDishes()
System.out.println("请输入您要删除的菜品id");
String id = sc.next();
d.delete(id);
System.out.println("删除成功!!");
/**
* 添加客户
*/
public void addUser()
System基于SpringBoot的外卖点餐管理系统的设计与实现(附源码)
计算机毕业设计-基于javaweb的外卖点餐系统-基于jsp的外卖系统源代码-校园外卖点餐系统java-骑手送外卖商家统计项目代码