JAVA——超市后台管理系统


//第一部分
package com.company;

public class Article {
    /**
     * 商品类
     */

    //   名字   单价    库存   已卖数量
       public String name;
       public  double  price;
       public  int   amount;
       public  int  number;


    public void setArticle(String mingzi, double danjia,int kucun,int xiaoshou) {
        name = mingzi;
        price = danjia;
        amount = kucun;
        number = xiaoshou;
    }

        public void print(int index){
        System.out.println(index + "\t" + name + "\t" + price + "\t" + amount + "\t" +number);

    }


}


//第二部分
package com.company;

/**
 * 商品集合
 * 仓库进行管理商品
 */
public class ArticleSet {
    Article[] articles=new Article[50];
}


//第三部分

package com.company;

import java.util.Scanner;

public class ArticleManage {
    ArticleSet articleSet=new ArticleSet();
    //仓库初始化,放入一些商品
    public void  initial(){

     Article xiaomi11 =new Article();

       /**         xiaomi11.name="小米11";
         *         xiaomi11.number=30;
         *         xiaomi11.amount=0;
         *         xiaomi11.price=1999;
         *
         */

        xiaomi11.setArticle("小米11",1999,50,0);

        Article  xiaomipro=new Article();
        xiaomipro.setArticle("小米pro", 2999,60,  1);


        Article  xiaomiultra=new Article();
        xiaomiultra.setArticle("小米ultra", 2599,70,  3);


        articleSet.articles[0]=xiaomi11;
        articleSet.articles[1]=xiaomipro;
        articleSet.articles[2]=xiaomiultra;

    }
//启动菜单

    public void startMenu() {
        boolean flag;
        do {
            System.out.println("欢迎使用前台商城管理系统");
            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.退出");
            System.out.println("------------------------");
            System.out.println("请选择要执行的操作:");
            Scanner scanner = new Scanner(System.in);
           flag=true;
            int num = scanner.nextInt();
            switch (num) {
                case 1:
                    System.out.println("查看商品信息");
                    chaka();
                    break;
                case 2:
                    System.out.println("新增商品信息");
                    add();
                    break;
                case 3:
                    System.out.println("删除商品信息");
                    delete();
                    break;
                case 4:
                    System.out.println("卖出商品");
                    saleOut();
                    break;
                case 5:
                    System.out.println("商品销售排行榜");
                    leadeBand();
                    break;
                case 6:
                    System.out.println("谢谢使用");
                    flag=false;
                    break;
                default:
                    System.out.println("你输入错误,请再次输入");
            }
        }while (flag);
        }



    public void chaka(){
       System.out.println("编号  \t  名字  \t 单价 \t 库存  \t  已卖 \t  ");
       for (int i=0; i

你可能感兴趣的:(JAVA——超市后台管理系统)