C#练习--库存管理

class Storage
    {
        Goods o = new Goods();
        Goods [] g=new Goods[3];
        public void Initial() { 
        g[0]=new Goods();
        g[0].Name = "杯子";
        g[0].Where = "第一仓库第一排";
        g[0].Money = 10.1;
        g[0].Manyidu = 90;
        g[1] = new Goods();
        g[1].Name = "花瓶";
        g[1].Where = "第二仓库第二排";
        g[1].Money = 12.1;
        g[1].Manyidu = 95;
        g[2] = new Goods();
        g[2].Name = "热水器";
        g[2].Where = "第三仓库第三排";
        g[2].Money = 11.1;
        g[2].Manyidu = 97;
        foreach (Goods item in g)
        {
            string a = string.Format("货品名称:{0}", item.Name, item.Name, item.Name);
         Console.WriteLine(a);
        }
       
        
        
        
        }
        public void ShowMenu() {
            bool con=false;
            do{
            Console.WriteLine("==========================欢迎使用库存管理系统==========================");
            Console.WriteLine("1:根据货品名称获取货品位置  2:取得客户满意度最高的货品  3:退出");
            Console.WriteLine("请选择:");
            int x = int.Parse(Console.ReadLine());
            if(x==1){
                if (GetGoodsPlace() == false)
                    Console.WriteLine("您输入的货品名称不正确!");
            con=true;
            }else if(x==2){

                GetMaxPleased();
                
                con=true;
            }
            else if (x == 3)
            {
                Console.WriteLine("谢谢使用!");
                con = false;
            }else{
           
                Console.WriteLine("输入e停止购物,输入其他任意键继续购物!");
               
                con=true;
            }
            }while(con);
            
            
            
            
            
            }
        
        
        
    
        
        
        public void ShowGoods() {
            Console.WriteLine("----------------------------");
            foreach (Goods iteming in g)
	{
		 Console.WriteLine("货品名称:"+iteming.Name);
	}
            Console.WriteLine("-----------------------------");
        
        
        }
        
        public bool GetGoodsPlace(){
            bool ton = false;
            Console.WriteLine("请输入商品名称:");
            string goods = Console.ReadLine();
            foreach (Goods ite in g)
            {
             if(ite.Name.Equals(goods)){

                 ton = true;
                 Console.WriteLine(ite.Where);
             }
            }
            return ton;
        
        
        
        
        }
        public void GetMaxPleased() {
            o = GetPleased();
            string goodsname = string.Format("客户满意度最高的货品:{0}摆放在:{1}满意度:{2}价格:{3}",o.Name,o.Where,o.Manyidu,o.Money);
            Console.WriteLine(goodsname);
        
        
        
        
        
        }
        private Goods GetPleased() {
            o.Manyidu = 0;
            foreach (Goods itt in g)
            {
                if(itt.Manyidu>o.Manyidu){
                    o.Manyidu = itt.Manyidu;
                    o.Name = itt.Name;
                    o.Money = itt.Money;
                    o.Where = itt.Where;
                
                }
            }
            return o;
        
        
        
        
        }
class Goods
    {
        private string name;

        public string Name
        {
            get { return name; }
            set { name = value; }
        }
        private string where;

        public string Where
        {
            get { return where; }
            set { where = value; }
        }
        private double money;

        public double Money
        {
            get { return money; }
            set { money = value; }
        }
        private int manyidu;

        public int Manyidu
        {
            get { return manyidu; }
            set { manyidu = value; }
        }




    }

static void Main(string[] args)
        {
            Storage s = new Storage();
            s.Initial();
            s.ShowMenu();
           
            Console.ReadLine();



        }


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值