package yaungong;
import java.util.Scanner;
import yaungong.TestEMD.Employee;
public class ShopVip {
class Shops {
private String ID;//会员卡号
private String name;//姓名
private double discount;//折扣
private double price;//商品价格
public Shops() {//
// TODO Auto-generated constructor stub
}
//计算工资
public double endPrice(double price, double discount) {
return price - discount* price;
}
public String getID() {
return ID;
}
public void setID(String iD) {
ID = iD;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getDiscount() {
return discount;
}
public void setDiscount(double discount) {
this.discount = discount;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public Shops(String iD, String name, double discount, double price) {
super();
ID = iD;
this.name = name;
this.discount = discount;
this.price = price;
}
}
public static void main(String[] args) {
ShopVip shopVip = new ShopVip();
//开始界面
System.out.println("|-------欢迎来到商品会员折扣系统---------|");
System.out.println("|------1. 商品录入 ----------------------|");
System.out.println("|------2.查找持卡人的购买信息- ----------|");
System.out.println("|------0. 退出 --------------------------|");
System.out.println("|----------------|");
//业务选择
label : while(true) {
System.out.println("请选择业务:");
int select = sc.nextInt();
switch (select) {
case 1: //输入你的商品信息
shopVip.addShops();
break;
case 2: //根据kahao查找雇员信息
shopVip.findShops();
break;
case 0: //退出
System.out.println("退出成功!");
}
}
}
static int len = -1;
static Shops[] shopsArr = new Shops[50];
static Scanner sc = new Scanner(System.in);
public void addShops() {
Shops shops = null;
System.out.println("---输入你的会员信息---");
System.out.print("请输入你的会员卡号编号:");
String id = sc.next();
System.out.print("请输入商品名称:");
String name = sc.next();
System.out.print("请输入他的会员折扣:");
double discount = sc.nextDouble();
System.out.print("请输入商品的价格:");
double price = sc.nextDouble();
shops = new Shops();//实例化一个对象
shops.setID(id);
shops.setName(name);
shops.setDiscount(discount);
shops.setPrice(price);
//len先加1后使用,变为shopsArr[0]
int i = ++len;
shopsArr[i] = shops;
printShops(shopsArr[len]);
// System.out.println("添加成功!");
}
/**
* 员工信息
* @param em
*/
public void printShops(Shops shops) {
System.out.print(" 会员卡号: " + shops.getID());
System.out.print(" 商品名称: " + shops.getName());
System.out.print(" 会员折扣等级 : " + shops.getDiscount());
//参数
double sum = shops.endPrice(shops.getPrice(),shops.getDiscount());
System.out.println(" 最终支付:" + sum);
}
/**
* 根据姓名查找员工信息
*/
public void findShops() {
System.out.println("----查找持卡人的购买信息------");
System.out.println("---请输入客户会员卡号:---");
//设置一个boolean类型的flg标志,若查找不到则为false
boolean flg = false;
String ID = sc.next();
for( int i=0; i<len; i++) {//for循环遍历
if(shopsArr[i].getID().equals(ID)) {
printShops(shopsArr[i]);
System.out.println("查找成功!");
flg = true;
break;
}
}
if(!flg) {
System.out.println("查无此人,请重新输入:");
findShops();
}
}
}
最近下载更多
最近浏览更多
shaohuaqingfu LV3
2024年11月6日
gql0720 LV1
2024年9月25日
kenhomeliu LV29
2024年4月30日
Kaiaahh LV2
2023年12月30日
aaaaooa LV4
2023年11月3日
微信网友_6683317591494656
2023年10月8日
暂无贡献等级
熬夜选手不能熬夜 LV2
2023年9月16日
dmyafda LV5
2023年9月8日
GT2002220 LV2
2023年6月9日
fewfsdaf LV4
2023年4月16日

