C#第五章

Goods:
  using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication5
{
    class Goods
    {
        private int goodpleased;
        public int _goodpleased
        {
            get { return goodpleased; }
            set { goodpleased = value; }
        }
        private double goodprise;
        public double _goodprise
        {
            get { return goodprise; }
            set { goodprise = value; }
         
          
        }
        private string goodname;
        public string _goodname
        {
            get { return goodname; }
            set { goodname = value; }


        }
        private string goodplace;
        public string _goodplace
        {
            get { return goodplace; }
            set { goodplace = value; }


        }

    }
}
storge类:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication5
{
    class Storage
    {
        Goods good = new Goods();
        Goods[] o = new Goods[3];
        public void zong() 
        {
            o[0] = new Goods();
            o[0]._goodname = "杯子";
            o[0]._goodplace = "第一仓库第三排左上";
            o[0]._goodpleased = 99;
            o[0]._goodprise = 15.25f;

            o[1] = new Goods();
            o[1]._goodname = "花瓶";
            o[1]._goodplace = "第一仓库第二排左下";
            o[0]._goodpleased = 96;
            o[0]._goodprise = 12.25f;
            o[2] = new Goods();
            o[2]._goodname= "热水器";
            o[2]._goodplace= "第一仓库第三排左中";
            o[0]._goodpleased = 96;
            o[0]._goodprise = 17.25f;
        }
        public void zong1() 
        { 
                Console.WriteLine("库存清单列表");
                Console.WriteLine("________________________");
                foreach(Goods oo in o)
               {
               
                Console.WriteLine("商品名称:{0}",oo._goodname);
                Console.WriteLine();
             }
                Console.WriteLine("_________________________");
        }
        public void show2()
        {
            string option=" ";
            do{
                
                Console.WriteLine("==================欢迎使用库存管理系统==================");
                Console.WriteLine("1:根据货品名称获取货品位置 2:取得客户满意度最高的货品 3:退出");
                Console.WriteLine("========================================================");
                Console.WriteLine("请选择:");
                option = Console.ReadLine();
                switch(option)
                {
                    case "1":
                       if(show11()==false)
                        {
                             Console.WriteLine("你输入的货品名称不正确");
                        }
                        continue;
                    case "2":
                      show22();
                        continue;
                    case "3":
                        break;
                    default:
                        Console.WriteLine("输入错误");
                        continue;

                }


                break;


            }while(true);
            
        }
        private bool show11()
        {
            bool flag = false;
            string name1;
            Console.WriteLine("请输入商品名称");
            name1 = Console.ReadLine();
            foreach (Goods n in o) 
            {
                if(n._goodname.Equals(name1) )
                {
                    flag = true;
                    Console.WriteLine(good._goodplace);
                }
                   
            }
            return flag;
        }


        private void show22()
        {
           
            good = getpleased();
            string name2=string.Format("客户满意度最高的商品: {0}摆放在: {1}满意度: {2}价格:",good._goodname,good._goodplace,good._goodpleased,  good._goodprise );
            Console.WriteLine(name2);
    }


        private Goods getpleased()
        {
            
            good._goodpleased = 0;
            foreach (Goods nn in o)
            {
                if (nn._goodpleased > good._goodpleased)
                {
                    good._goodname = nn._goodname;
                    good._goodplace = nn._goodplace;
                    good._goodpleased = nn._goodpleased;
                    good._goodprise = nn._goodprise;
                }
               
            }
           return good;

        }

          
    }
}
调用:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication5
{
    class Storage
    {
        Goods good = new Goods();
        Goods[] o = new Goods[3];
        public void zong() 
        {
            o[0] = new Goods();
            o[0]._goodname = "杯子";
            o[0]._goodplace = "第一仓库第三排左上";
            o[0]._goodpleased = 99;
            o[0]._goodprise = 15.25f;

            o[1] = new Goods();
            o[1]._goodname = "花瓶";
            o[1]._goodplace = "第一仓库第二排左下";
            o[0]._goodpleased = 96;
            o[0]._goodprise = 12.25f;
            o[2] = new Goods();
            o[2]._goodname= "热水器";
            o[2]._goodplace= "第一仓库第三排左中";
            o[0]._goodpleased = 96;
            o[0]._goodprise = 17.25f;
        }
        public void zong1() 
        { 
                Console.WriteLine("库存清单列表");
                Console.WriteLine("________________________");
                foreach(Goods oo in o)
               {
               
                Console.WriteLine("商品名称:{0}",oo._goodname);
                Console.WriteLine();
             }
                Console.WriteLine("_________________________");
        }
        public void show2()
        {
            string option=" ";
            do{
                
                Console.WriteLine("==================欢迎使用库存管理系统==================");
                Console.WriteLine("1:根据货品名称获取货品位置 2:取得客户满意度最高的货品 3:退出");
                Console.WriteLine("========================================================");
                Console.WriteLine("请选择:");
                option = Console.ReadLine();
                switch(option)
                {
                    case "1":
                       if(show11()==false)
                        {
                             Console.WriteLine("你输入的货品名称不正确");
                        }
                        continue;
                    case "2":
                      show22();
                        continue;
                    case "3":
                        break;
                    default:
                        Console.WriteLine("输入错误");
                        continue;

                }


                break;


            }while(true);
            
        }
        private bool show11()
        {
            bool flag = false;
            string name1;
            Console.WriteLine("请输入商品名称");
            name1 = Console.ReadLine();
            foreach (Goods n in o) 
            {
                if(n._goodname.Equals(name1) )
                {
                    flag = true;
                    Console.WriteLine(good._goodplace);
                }
                   
            }
            return flag;
        }


        private void show22()
        {
           
            good = getpleased();
            string name2=string.Format("客户满意度最高的商品: {0}摆放在: {1}满意度: {2}价格:",good._goodname,good._goodplace,good._goodpleased,  good._goodprise );
            Console.WriteLine(name2);
    }


        private Goods getpleased()
        {
            
            good._goodpleased = 0;
            foreach (Goods nn in o)
            {
                if (nn._goodpleased > good._goodpleased)
                {
                    good._goodname = nn._goodname;
                    good._goodplace = nn._goodplace;
                    good._goodpleased = nn._goodpleased;
                    good._goodprise = nn._goodprise;
                }
               
            }
           return good;

        }

          
    }
}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值