网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
代码编写
菜单类:
package com.oop.demo;
public abstract class Menu {
public abstract void show();//打印供选择的菜品/饮品信息
public abstract void add(int index, int num);//添加菜品/饮品
public abstract void check();//打印选择的菜品/饮品信息
}
菜品类(继承于菜单类):
package com.oop.demo;
/\*\*
\* 菜品类,继承于菜单类
\*
\*/
public class Cuisine extends Menu{
/\*菜品名称\*/
private String[] cuisine_Names = {"鱼香肉丝", "宫保鸡丁", "糖醋里脊", "糖醋排骨", "小鸡炖蘑菇", "红烧鱼"};
/\*菜品单价\*/
private double[] cuisine_Prices = {29, 30, 40, 45, 50, 60};
/\*选择菜品的名称\*/
private String[] choice_Cui_Names = new String[cuisine_Names.length];
/\*选择菜品的单价\*/
private double[] choice_Cui_Prices = new double[cuisine_Prices.length];
/\*选择菜品的份数\*/
private int[] num = new int[choice_Cui_Names.length];
/\*\*
\* 打印供选择菜品的信息
\*/
public void show() {
System.out.println("菜品序号\t菜品名称\t菜品单价");
for (int i = 0; i < cuisine_Names.length; i++) {
System.out.println((i + 1) + "\t" + cuisine_Names[i]
+ "\t" + cuisine_Prices[i]);
}
}
/\*\*
\* 添加菜品
\*/
public void add(int index, int num) {
for (int i = 0; i < choice_Cui_Names.length; i++) {
if (choice_Cui_Names[i] == null) {
choice_Cui_Names[i] = cuisine_Names[index - 1];
choice_Cui_Prices[i] = cuisine_Prices[index - 1];
this.num[i] = num;
break;
}
}
}
/\*\*
\* 打印选择的菜品信息
\*/
public void check() {
for (int i = 0; i < choice_Cui_Names.length; i++) {
if (choice_Cui_Names[i] != null) {
System.out.print("\t" + choice_Cui_Names[i]
+ "\t¥" + choice_Cui_Prices[i] + "\t " + num[i]);
}
}
}
}
饮品类(继承于菜单类):
package com.oop.demo;
/\*\*
\* 饮品类,继承于菜单类
\*
\*/
public class Beverage extends Menu{
/\*饮料名称\*/
private String[] beverage_Names = {"冰茶", "红茶", "绿茶", "蜜雪冰城", "矿泉水", "牛奶"};
/\*饮料单价\*/
private double[] beverage_Prices = {1.5, 2.5, 2.5, 10.0, 9.0, 12.0};
/\*选择的饮品名称\*/
private String[] choice_Bvg_Names = new String[beverage_Names.length];
/\*选择的饮品单价\*/
private double[] choice_Bvg_Prices = {beverage_Prices.length};
/\*选择的饮品份数\*/
private int[] num = new int[choice_Bvg_Names.length];
/\*\*
\* 打印供选择饮品的信息
\*/
public void show() {
System.out.println("菜单如下:");
System.out.println("饮品序号\t饮品名称\t饮品单价");
for (int i = 0; i < beverage_Names.length; i++) {
System.out.println((i + 1) + "\t" + beverage_Names[i] + "\t¥"
+ beverage_Prices[i]);
}
}
/\*\*
\* 添加饮品
\*/
public void add(int index, int num) {
for (int i = 0; i < choice_Bvg_Names.length; i++) {
if (choice_Bvg_Names[i] == null) {
choice_Bvg_Names[i] = beverage_Names[index - 1];
choice_Bvg_Prices[i] = beverage_Prices[index - 1];
this.num[i] = num;
break;
}
}
}
/\*\*
\* 打印选择的饮品信息
\*/
public void check() {
for (int i = 0; i < choice_Bvg_Names.length; i++) {
if (choice_Bvg_Names[i] != null) {
System.out.print("\t" + choice_Bvg_Names[i]
+ "\t¥" + choice_Bvg_Prices[i] + "\t " + num[i]);
}
}
}
}
订单类:
package com.oop.demo;
public class OrderForm {
private String name;//顾客昵称
private String tel;//顾客电话
private String addr;//顾客地址
Menu[] menu = new Menu[3];//初始化5个菜单信息
int[] states = new int[3];//订单状态
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTel() {
return tel;
}
public void setTel(String tel) {
this.tel = tel;
}
public String getAddr() {
return addr;
}
public void setAddr(String addr) {
this.addr = addr;
}
}
顾客类:
package com.oop.demo;
import java.util.Scanner;
/\*\*
\* 顾客类
\*
\*/
public class Customer {
Scanner sca = new Scanner(System.in);
OrderForm order_Form;
/\*\*
\* 修改信息
\* @param name 昵称
\* @param tel 电话号码
\* @param addr 地址
\*/
public void modify() {
if (order_Form.getName() == null) {
System.out.println("您还没有注册信息!");
} else {
System.out.println("请输入您的旧昵称:");
String name = sca.next();
System.out.println("请输入您的旧电话号码:");
String tel = sca.next();
System.out.println("请输入您的旧送餐地址:");
String addr = sca.next();
if (order_Form.getName().equals(name) && order_Form.getTel()
.equals(tel) && order_Form.getAddr().equals(addr)) {
System.out.println("请输入新的昵称:");
order_Form.setName(sca.next());
System.out.println("请输入新的电话号码:");
order_Form.setTel(sca.next());
System.out.println("请输入新的送餐地址:");
order_Form.setAddr(sca.next());
System.out.println("修改成功~");
} else {
System.out.println("输入信息于原有信息不符,修改失败!");
}
}
}
/\*\*
\* 删除订单
\*/
public void del() {
get();
if (order_Form.menu[0] != null) {
System.out.println("请输入要删除的订单序号:");
int num = sca.nextInt();
if (order_Form.states[num - 1] == 0) {
System.out.println("您选择的订单未签收,不可删除!");
} else {
for (int i = num - 1; i < this.order_Form.menu.length - 1; i++) {
this.order_Form.menu[i] = this.order_Form.menu[i + 1];
this.order_Form.states[i + 1] = this.order_Form.states[num - 1];
}
this.order_Form.menu[num - 1] = null;
System.out.println("删除成功~");
}
}
}
/\*\*
\* 签收订单
\*/
public void signFor() {
get();
if (order_Form.menu[0] != null) {
System.out.println("请输入要签收的订单序号:");
int num = sca.nextInt();
if (order_Form.states[num - 1] == 0) {
order_Form.states[num - 1] = 1;
System.out.println("签收成功~");
} else if (order_Form.states[num - 1] == 1) {
System.out.println("订单已签收无需重复签收!");
}
}
}
/\*\*
\* 查看订单信息
\*/
public void get() {
![img](https://img-blog.csdnimg.cn/img_convert/b496f8cc546bb3a6caf86762c03743e0.png)
![img](https://img-blog.csdnimg.cn/img_convert/886812f5a99ca9a2af607ceda514dff1.png)
![img](https://img-blog.csdnimg.cn/img_convert/286ae7b3ccf2d33ef82ebc4633e843fc.png)
**既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上大数据知识点,真正体系化!**
**由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新**
**[需要这份系统化资料的朋友,可以戳这里获取](https://bbs.csdn.net/topics/618545628)**
-bZjhzBAG-1715678334789)]
[外链图片转存中...(img-08fcK05a-1715678334789)]
[外链图片转存中...(img-KIFGBhxk-1715678334789)]
**既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上大数据知识点,真正体系化!**
**由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新**
**[需要这份系统化资料的朋友,可以戳这里获取](https://bbs.csdn.net/topics/618545628)**