一个简单的仓库管理系统

学Java有两周了,自己做了一个简单的仓库管理系统

Product类为商品类,Admin类为管理员类,这里就不发出来了

 

Function类为主要方法的实现,用主方法调用就可以是用了

public class Function {
    boolean log=false;//默认未登录
    Admin ad=new Admin();
    int io=0;//商品id
    static ArrayList<Product> a = new ArrayList<Product>();
    public void zhuYe(){
        System.out.println(
        "*******欢迎进入仓库管理********"+"\n"+
        "*****【1】管理员登录*****"+"\n"+
        "*****【2】商品信息录入*****"+"\n"+
        "*****【3】查询所有商品信息*****"+"\n"+
        "*****【4】根据类别查询商品****"+"\n"+
        "*****【5】查询所有上架(1)或下架(0)的商品*"+"\n"+
        "*****【6】显示所有库存不足的商品***"+"\n"+
        "*****【7】根据商品id修改商品价格***"+"\n"+
        "*****【8】根据商品id修改商品库存***"+"\n"+
        "*****【0】退出登录************"+"\n"+
        "请选择操作");
        Scanner sc = new Scanner(System.in);
        int i = sc.nextInt();
        switch (i) {
        case 1:
            dengLu();
            zhuYe();
            break;
        case 2:
            yanZheng();
            luRu();
            zhuYe();
            break;
        case 3:
            yanZheng();
            allChaXun();
            zhuYe();
            break;
        case 4:
            yanZheng();
            classChaXun();
            zhuYe();
            break;
        case 5:
            yanZheng();
            putChaXun();
            zhuYe();
            break;
        case 6:        
            yanZheng();
            countChaXun();
            zhuYe();
            break;
        case 7:
            yanZheng();
            idChangePrice();
            zhuYe();
            break;
        case 8:
            yanZheng();
            countChangeCount();
            zhuYe();
            break;
        case 0:
            log=false;
            zhuYe();
            break;
        
        }
    }
    
    /**
     * 根据id改库存
     */
    private void countChangeCount() {
        System.out.println("输入要更改商品的id");
        Scanner sc1=new Scanner(System.in);
        int a1=sc1.nextInt();
        System.out.println("请重新输入库存");
        int p1 = sc1.nextInt();
        for (int i = 0; i < a.size(); i++) {
            if (a.get(i).getId()== a1) {
                a.get(i).setPcount(p1);;;
            }else{System.out.println("要我变出来?");}
        }
        
    }
    /**
     * 根据id改价格
     */
    private void idChangePrice() {
        System.out.println("输入要更改商品的id");
        Scanner sc1=new Scanner(System.in);
        int a1=sc1.nextInt();
        System.out.println("请重新输入价格");
        int p1 = sc1.nextInt();
        for (int i = 0; i < a.size(); i++) {
            if (a.get(i).getId()== a1) {
                a.get(i).setPprice(p1);;
            }else{System.out.println("要我变出来?");}
        }
        
        
        
    }

    /**
     * 查询库存不足
     */
    private void countChaXun() {
        for(int i=0;i<a.size();i++){
            if(0==a.get(i).getPcount()){
                System.out.println(a.get(i));
            }else{System.out.println("要我变出来?");}
        }
        
    }

    /**
     * 根据状态查询
     */
    private void putChaXun() {
        System.out.println("输入要查询的商品状态");
        Scanner sc1=new Scanner(System.in);
        int put1=sc1.nextInt();
        for(int i=0;i<a.size();i++){
            if(put1==a.get(i).getPput()){
                System.out.println(a.get(i));
            }else{System.out.println("要我变出来?");}
        }
        
    }

    /**
     * 根据类别查询
     */
    private void classChaXun() {
        System.out.println("输入商品类别");
        Scanner sc1=new Scanner(System.in);
        String class1=sc1.next();
        for(int i=0;i<a.size();i++){
            if(Objects.equals(class1,a.get(i).getPclass())){
                System.out.println(a.get(i));
            }else{System.out.println("要我变出来?");}
        }
        
    }

    /**
     * 查询所有
     */
    private void allChaXun() {
        if(a.size()==0){
            System.out.println("要我变出来?");
        }
        System.out.println(a);
        
    }

    private void luRu() {
        Scanner sc = new Scanner(System.in);
        
        System.out.println("商品名");
        String b1=sc.next();
        System.out.println("商品类别");
        String c1=sc.next();
        System.out.println("商品单价");
        double d1=sc.nextDouble();        
        System.out.println("商品库存");
        int e1=sc.nextInt();
        System.out.println("商品状态");
        int f1=sc.nextInt();        
        System.out.println("管理员id");
        int g1=sc.nextInt();
        
        io++;
        Product p = new Product();
        p.setId(io);
        p.setPname(b1);
        p.setPclass(c1);
        p.setPprice(d1);
        p.setPcount(e1);
        p.setPput(f1);
        p.setId(g1);
        a.add(p);
        
    }
    /**
     * 验证是否登录
     */
    private void yanZheng() {
        if(log==false){
            dengLu();
        }
        
    }
    
    /**
     * 登录
     */
    private void dengLu() {
        System.out.println("欢迎登陆,请输入账号");
        Scanner sc=new Scanner(System.in);
        String a1=sc.next();
        if(Objects.equals(a1, ad.getAno())){
            System.out.println("请输入密码");
        }else{
            System.out.println("玩得账号都忘了?");
            dengLu();
        }
        Scanner sc1=new Scanner(System.in);
        String a2=sc.next();
        if(Objects.equals(a2, ad.getApassword())){
            System.out.println("登陆成功");
        }else{
            System.out.println("你怕不是盗号的--");
            dengLu();
        }
        log=true;
        
        
    }

}
 

  • 9
    点赞
  • 49
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值