getZheKou() {
if (score < 200) {
zhekou = 0.9;
} else if (score >= 200 && score < 400) {
zhekou = 0.8;
} else if (score >= 400 && score < 800) {
zhekou = 0.7;
} else if (score >= 800) {
zhekou = 0.6;
}
return zhekou;
}
/***************************************************************************
* 用户在选择 “保存商品订单”的时候,用来下订单,根据用户积分来算折扣,然后求出实际应该付的钱数
*
* @param money:
* 用户输入的钱数
*
*/
public double payPrice() { // 打折后的价格
pay = zhekou * allMoney;
return pay;
}
// 用户窗体菜单类,调用总金额,积分,折扣等方法
public void saveMenu() {
String answer = "";
System.out.println("您购买商品的总价为:\t" + allMoney + "元");
System.out.println("您目前的积分是:\t" + score + "分");
System.out.println("根据您购物的金额,您享有:\t" + zhekou + "的折扣优惠!");
System.out.println("您最后应付款为:\t" + pay);
do {
System.out.println("请输入您要付款的金额:\t");
double money = input.nextDouble();
if (money < pay) { // 输入的金额不足时
System.out.println("不好意思您输入的金额不足!不能完成交易!" + "\n是否继续交易(y/n):");
answer = input.next();
} else {
System.out.println("您好!交易成功!!" + "\n找回您:" + (money - pay));
System.out.println("感谢您的购物,你可以享受本超市的抽奖活动!");
System.out.println("规则:输入1~3"); // 结账完了进行抽奖活动
int shuzi = input.nextInt();
int random = (int) ((Math.random() * 3) + 1);
if (random == shuzi) {
System.out.println("恭喜你,获得苹果电脑一台!!欢迎下次光临");
} else {
System.out.println("谢谢参与,欢迎下次光临!!");
}
break;
}
} while (answer.equals("y"));
}
}
import java.util.Scanner;
public class ShopCar_Manager {
String userName = "manager"; // 定义管理员的用户名和密码
String password = "0000";
String user = ""; // 定义输入的管理员用户名和密码
String pwd = "";
public int i = 0; // 用来记录输入的管理员用户名或密码错误的次数.定义成全局的是为了在测试类中能用到
public int[] quotID = new int[10]; // 商品编号
public String[] quotName = new String[10]; // 商品名称
public int[] quotNum = new int[10]; // 商品数量
public String[] quotInfo = new String[10]; // 商品介绍
public int[] quotPrice = new int[10]; // 商品价格
Scanner input = new Scanner(System.in);
/**
* 初始化库存的商品信息
*/
public void initial() {
quotID[0] = 1;
quotName[0] = "java";
quotNum[0] = 20;
quotInfo[0] = "真是太牛了!!!";
quotPrice[0] = 87;
quotID[1] = 2;
quotName[1] = "net";
quotNum[1] = 28;
quotInfo[1] = "太好
e = input.nextInt(); // 添加货架上的商品价格
if(shopPrice<=0){
System.out.print("您输入的价格不合理,返回菜单!!");
menu();
break;
}
quotID[index] = bianhao;
quotName[index] = shopName;
quotNum[index] = shopNum;
quotInfo[index] = shopInfo;
quotPrice[index] = shopPrice;
System.out.println("商品添加成功,返回主菜单查看!!");
answer="n";
menu();
break;
}while(answer.equals("y"));
}
// 修改菜单
public void rework(){ // 从键盘输入接收一个编号
boolean big=true;
System.out.print("请输入你要修改的商品编号:");
int shopid=input.nextInt();
for(int i=0;i
),如果你是管理员请选择(<2>)");
System.out.println("***************************************************************************");
}
public static void main(String[] args) {
ShopCar_Client client = new ShopCar_Client(); // 定义前台用户类的对象
client.manager.initial();
Scanner input = new Scanner(System.in);
String con = "";
con = "no";
do {
if (con == "no") {
client.manager.initial();
} // 先初始化库存中的商品信息
mainMenu(); // 显示系统主菜单
int num = input.nextInt();
if (num == 1) { // 显示执行前台用户
client.showShop(client.manager.quotID, client.manager.quotName, client.manager.quotNum, client.manager.quotInfo,client.manager. quotPrice);
client.goumai(client.manager.quotID, client.manager.quotName,
client.manager.quotNum, client.manager.quotInfo, client.manager.quotPrice);
} else if (num == 2) {
client.manager.login();
} else {
System.out.println("没有你所选的选项!!!");
}
System.out.println("是否重新选择进入购物管理系统(yes/no)");
con = input.next();
} while (con.equals("yes"));
System.out.println("谢谢您的使用,欢迎下次光临!!");
}
}
本文来源:https://www.2haoxitong.net/k/doc/f9679721a5e9856a5612605a.html