import java.util.Scanner;
public class jj {
static Scanner sc = new Scanner(System.in);
String name;
String caipin;
int time;
String address;
int zhuang;
int price;
static String[] caipin1 = {"鱼香肉丝", "锅包肉", "糖醋里脊"};
static int[] jiage = {12, 24, 25};
static int[] dianzan = new int[3];
static jj[] pp = new jj[10];
public jj(String name, String caipin, int time, String address, int zhuang, int price) {
this.name = name;
this.caipin = caipin;
this.time = time;
this.address = address;
this.zhuang = zhuang;
this.price = price;
}
@Override
public String toString() {
System.out.println("jj{" +
"name='" + name + '\'' +
", caipin='" + caipin + '\'' +
", time=" + time +
", address='" + address + '\'' +
", zhuang=" + zhuang +
", price=" + price +
'}');
return null;
}
public static void hhh(jj[] o) {
o[0] = new jj("张三", "鱼香肉丝", 12, "北京", 0, 12);
o[1] = new jj("李四", "锅包肉", 24, "北京", 1, 24);
o[2] = new jj("王五", "糖醋里脊", 25, "北京", 1, 25);
}
public static void main(String[] args) {
hhh(pp);
boolean fa = false;
int k = 0;
do {
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.退出系统");
int next = sc.nextInt();
switch (next) {
case 1:
add();
break;
case 2:
cha();
break;
case 3:
qian();
break;
case 4:
shan();
break;
case 5:
zan();
break;
case 6:
k=1;
break;
}
if (!(next >= 1 && next <= 6)) {
System.out.println("输入0返回");
k = sc.nextInt();
}
} while (k == 0);
}
private static void zan() {
System.out.println("我要点赞");
for (int i = 0; i < caipin1.length; i++) {
int zan = dianzan[i] > 0 ? dianzan[i] : 0;
System.out.println((i + 1) + caipin1[i] + zan + "赞");
}
System.out.println("请选择要点赞的编号");
int dian = sc.nextInt();
for (int i = 0; i < caipin1.length; i++) {
if((dian-1)==i){
dianzan[dian-1]+=1;
System.out.println("点赞成功");
return;
}
}
}
private static void shan() {
System.out.println("请选择要删除的订单");
int shan = sc.nextInt();
for (int i = 0; i < pp.length; i++) {
if((shan-1) == i){
pp[shan-1]=null;
System.out.println("删除成功");
}
}
}
private static void qian() {
System.out.println("签收订单");
System.out.println("请选择签收的编号");
int qian = sc.nextInt();
for (int i = 0; i < pp.length; i++) {
if((qian-1) == i){
pp[qian-1].zhuang=1;
System.out.println("签收成功");
return;
}
}
}
private static void cha() {
for (int i = 0; i < pp.length; i++) {
if (pp[i] != null) {
pp[i].toString();
}
}
}
private static void add() {
System.out.println("我要订餐");
boolean faal = false;
for (int i = 0; i < pp.length; i++) {
if (pp[i] == null) {
faal = true;
System.out.println("请输入您的姓名");
String name1 = sc.next();
System.out.println("序号\t\t菜名\t\t单价\t\t点赞数\t\t");
for (int j = 0; j < caipin1.length; j++) {
int zan = dianzan[j] > 0 ? dianzan[j] : 0;
System.out.println((j + 1) + caipin1[j] + jiage[j] + zan + "赞");
}
System.out.println("请输入您选的菜品编号");
int ciapin = sc.nextInt();
System.out.println("请输入你要的份数");
int fen1 = sc.nextInt();
System.out.println("请输入为您送达的时间");
int time = sc.nextInt();
System.out.println("请输入您的地址");
String address1 = sc.next();
int zongja = jiage[ciapin - 1] * fen1;
int caifen = 5;
if (zongja < 50) {
caifen = 0;
}
System.out.println("订餐成功");
System.out.println("您定的餐品为" + caipin1[ciapin - 1] + "份数为" + fen1 + "时间为" + time + "价格为" + zongja + "配送费为" + caifen + "总价为" + (zongja + caifen));
for (int j = 0; j < pp.length; j++) {
if (pp[i] == null) {
pp[i] = new jj(name1, caipin1[ciapin - 1], time, address1, 0, (zongja + caifen));
return;
}
}
}
}
}
}
java小练习
最新推荐文章于 2024-08-16 23:08:28 发布