Java实现商品出入库

 

package com.lty;

import java.util.Scanner;

public class Main {
    Scanner sc=new Scanner(System.in);

    public static  void  show(){
        System.out.println("***********************************************************");
        System.out.println("石家庄铁道大学前进22软件开发有限公司");
        System.out.println("仓库管理系统2022版");
        System.out.println("***********************************************************");
        System.out.println("1、商品入库管理");
        System.out.println("2、商品信息修改");
        System.out.println("3、商品出库管理");
        System.out.println("4、仓库盘点管理");
        System.out.println("**********************************************************");
    }
    public static void main(String[] args) {

        Scanner sc=new Scanner(System.in);
        com.lty.WarehouseManagement t=new com.lty.WarehouseManagement();
        t=new com.lty.WarehouseManagement();
        while(true){
            show();
            int n=sc.nextInt();
            if(n==1){
                t.input();//入库
            }else if(n==2){
                t.change();//改变
            }else if(n==3){
                t.output();//出库
            }else if(n==4){
                t.endpower();break;//盘点并结束
            }else{
                System.out.println("输入的序号错误,请重新输入!");
            }
        }
    }
}
/*-----------------------------------------信息类--------------*/
class WarehouseInformation{
    private String itemno,itemname,suppliername,warehousingtime,shipmenttime,warehousenumber,warehouseplace;
    private int itemnumber,outnumber;
    public  int cnt=0;
    public WarehouseInformation(){
        itemno="";
        itemname="";
        suppliername="";
        shipmenttime="";
        warehousenumber="";
        warehouseplace="";
        itemnumber=0;outnumber=0;
    }
    public String getItemname(){
        return itemname;
    }

    public void setItemname(String itemname) {
        this.itemname = itemname;
    }

    public String getWarehousingtime() {
        return warehousingtime;
    }

    public void setWarehousingtime(String warehousingtime) {
        this.warehousingtime = warehousingtime;
    }

    public int getItemnumber() {
        return itemnumber;
    }
    public void setItemnumber(int a){
        this.itemnumber=a;
    }

    public void setOutnumber(int outnumber) {
        this.outnumber = outnumber;
    }

    public int getOutnumber() {
        return outnumber;
    }

    public String getItemno() {
        return itemno;
    }

    public void setItemno(String itemno) {
        this.itemno = itemno;
    }

    public String getShipmenttime() {
        return shipmenttime;
    }

    public void setShipmenttime(String shipmenttime) {
        this.shipmenttime = shipmenttime;
    }

    public String getSuppliername() {
        return suppliername;
    }

    public void setSuppliername(String suppliername) {
        this.suppliername = suppliername;
    }

    public String getWarehousenumber() {
        return warehousenumber;
    }

    public void setWarehousenumber(String warehousenumber) {
        this.warehousenumber = warehousenumber;
    }

    public String getWarehouseplace() {
        return warehouseplace;
    }

    public void setWarehouseplace(String warehouseplace) {
        this.warehouseplace = warehouseplace;
    }
}

/*-------------------------------------执行类--------------------*/
class WarehouseManagement extends com.lty.WarehouseInformation {
    com.lty.WarehouseInformation[] ans=new com.lty.WarehouseInformation[5];
    public int cnt=0;
    Scanner sc=new Scanner(System.in);
    public void input(){
        while(true) {
            System.out.println("***********************************************************");
            System.out.println("石家庄铁道大学前进22软件开发有限公司");
            System.out.println("仓库管理系统2022版");
            System.out.println("***********************************************************");
            System.out.println("商品编号:");
            String k;
            com.lty.WarehouseInformation s = new com.lty.WarehouseInformation();
            k = sc.next();
            s.setItemno(k);
            if (s.getItemno().length() != 8) {
                System.out.println("输入错误,请重新输入(八位):");
                k = sc.next();s.setItemno(k);
            }
            System.out.println("商品名称:");
            k = sc.next();
            s.setItemname(k);
            System.out.println("供货商信息:");
            k = sc.next();
            s.setSuppliername(k);
            System.out.println("入库时间:");
            k = sc.next();
            s.setWarehousingtime(k);
            if (s.getWarehousingtime().length() != 8) {
                System.out.println("输入错误,请重新输入(八位):");
                k = sc.next();
                s.setWarehousingtime(k);
            }
            System.out.println("仓库编号:");
            k = sc.next();
            s.setWarehousenumber(k);
            if (s.getWarehousenumber().length() != 3) {
                System.out.println("输入错误,请重新输入(八位):");
                k = sc.next();
                s.setWarehousenumber(k);
            }
            System.out.println("存放位置信息:");
            k = sc.next();
            s.setWarehouseplace(k);
            if (s.getWarehouseplace().length() != 8) {
                System.out.println("输入错误,请重新输入(八位):");
                k = sc.next();
                s.setWarehouseplace(k);
            }
            System.out.println("入库商品数量:");
            int y=sc.nextInt();
            s.setItemnumber(y+s.getItemnumber());
            System.out.println("**********************************************************");

            System.out.println("***********************************************************");
            System.out.println("石家庄铁道大学前进22软件开发有限公司");
            System.out.println("仓库管理系统2022版");
            System.out.println("***********************************************************");
            System.out.println("商品编号:");
            System.out.println(s.getItemno());
            System.out.println("商品名称:");
            System.out.println(s.getItemname());
            System.out.println("供货商信息:");
            System.out.println(s.getSuppliername());
            System.out.println("入库时间:");
            System.out.println(s.getWarehousingtime());
            System.out.println("仓库编号:");
            System.out.println(s.getWarehousenumber());
            System.out.println("存放位置信息:");
            System.out.println(s.getWarehouseplace());
            System.out.println("入库商品数量:");
            System.out.println(s.getItemnumber());
            System.out.println("该商品入库操作已完成,是否提交(Y/N)");
            System.out.println("**********************************************************");
            String c = sc.next();
            if (c.equals("Y")) {
                ans[cnt++] = s;
                break;
            } else {
                continue;
            }
        }
    }
    public void output(){
        while(true) {
            int i;
            com.lty.WarehouseInformation s=ans[0];
            System.out.println("***********************************************************");
            System.out.println("石家庄铁道大学前进22软件开发有限公司");
            System.out.println("仓库管理系统2022版");
            System.out.println("***********************************************************");
            System.out.println("请输入商品编号:");
            String k;
            k = sc.next();
            System.out.println("***********************************************************");
            boolean f=false;
            for(i=0;i7){
                        System.out.println("数据不存在!");
                        f=true;break;
                    }else{
                        System.out.println("***********************************************************");
                        System.out.println("石家庄铁道大学前进22软件开发有限公司");
                        System.out.println("仓库管理系统2022版");
                        System.out.println("***********************************************************");
                        System.out.println("1商品编号:");
                        System.out.println(s.getItemno());
                        System.out.println("2商品名称:");
                        System.out.println(s.getItemname());
                        System.out.println("3供货商信息:");
                        System.out.println(s.getSuppliername());
                        System.out.println("4入库时间:");
                        System.out.println(s.getWarehousingtime());
                        System.out.println("5仓库编号:");
                        System.out.println(s.getWarehousenumber());
                        System.out.println("6存放位置信息:");
                        System.out.println(s.getWarehouseplace());
                        System.out.println("7入库商品数量:");
                        System.out.println(s.getItemnumber());
                        System.out.println("请选择需要修改的信息编号(1-7):");
                        System.out.println(n);
                        System.out.println("请输入修改后的商品名称:");
                        if(n==1){String id=sc.next();
                            ans[i].setItemno(id);
                        }else if(n==2){String id=sc.next();
                            ans[i].setItemname(id);
                        }else if(n==3){String id=sc.next();
                            ans[i].setSuppliername(id);
                        }else if(n==4){String id=sc.next();
                            ans[i].setWarehousingtime(id);
                        }else if(n==5){String id=sc.next();
                            ans[i].setWarehousenumber(id);
                        }else if(n==6){String id=sc.next();
                            ans[i].setWarehouseplace(id);
                        }else{int id=sc.nextInt();
                            ans[i].setItemnumber(id);
                        }
                        System.out.println("***********************************************************");
                        break;
                    }
                }
            }
            if(f)
                continue;
            else
                break;
        }
    }
    public void endpower(){
        System.out.println("***********************************************************");
        System.out.println("石家庄铁道大学前进22软件开发有限公司");
        System.out.println("仓库管理系统2022版");
        System.out.println("***********************************************************");
        for(int i=0;i

你可能感兴趣的:(java,开发语言,jvm)