庫存管理系統

大炮的大炮沒有大炮發表於2016-11-15
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication3
{
    class Goods
    {
        private string ming;

        public string Ming
        {
            get { return ming; }
            set { ming = value; }
        }
        private string weizhi;

        public string Weizhi
        {
            get { return weizhi; }
            set { weizhi = value; }
        }

        private int manyidu;

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

        public double Jiage
        {
            get { return jiage; }
            set { jiage = value; }
        }

        
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication3
{
    class Storage
    {
        Goods s = new Goods();
        Goods[] j = new Goods[3];
        public void show1()
        {
            j[0] = new Goods();
            j[0].Ming = "杯子";
            j[0].Weizhi = "第一行第一排";
            j[0].Manyidu = 99;
            j[0].Jiage = 17.25;
            j[1] = new Goods();
            j[1].Ming = "花瓶";
            j[1].Weizhi = "第六行第六排";
            j[1].Manyidu = 100;
            j[1].Jiage = 1000;
            j[2] = new Goods();
            j[2].Ming = "熱水器";
            j[2].Weizhi = "第八行第八排";
            j[2].Manyidu = 98;
            j[2].Jiage = 787;
            Console.WriteLine("庫存貨品清單列表");
            Console.WriteLine("-----------------------");
            foreach (Goods i in j)
            {
                string a = string.Format("貨幣名稱:{0}", i.Ming);
                Console.WriteLine(a);
            }
            Console.WriteLine("-----------------------");
        }
        public void menu()
        {

            do
            {
                Console.WriteLine("=====================歡迎使用庫存管理系統============================");
                Console.Write("1:根據貨物名稱獲取貨品位置");
                Console.Write("2:取得客戶滿意度最高的貨品");
                Console.WriteLine("3:退出");
                Console.WriteLine("=====================================================================");
                int shu = 0;
                Console.WriteLine("請選擇:");
                shu = int.Parse(Console.ReadLine());
                if (shu == 1)
                {
                    sho();
                }
                else if (shu == 2)
                {
                    show5();
                }
                else if (shu == 3)
                {
                    Console.WriteLine("謝謝您的使用");
                    break;
                }
                else
                {
                    Console.WriteLine("選單輸入錯誤,請重新輸入選項");
                    continue;
                }
            } while (true);
        }

        private bool sho()
        {
            string ming = "";
            Console.WriteLine("請輸入專案名稱:");
            ming = Console.ReadLine();

            bool dui = false;
            foreach (Goods item in j)
            {
                if (ming.Equals(item.Ming))
                {
                    dui = true;
                    Console.WriteLine(item.Weizhi);
                }
                else
                {
                    dui = false;
                    Console.WriteLine("輸入錯誤");
                    break;
                }
                
            }
            return dui;
          
        }
        public void show5()
        {
            s = show4();
            Console.WriteLine("客戶滿意度最高的貨品:{0}擺放在{1}滿意度{2}價格{3}", s.Ming, s.Weizhi, s.Manyidu, s.Jiage);
        
        }
        private Goods show4()
        {

            foreach (Goods item in j)
            {
                if(item.Manyidu>s.Manyidu)
                {
                    s.Ming = item.Ming;
                    s.Weizhi = item.Weizhi;
                    s.Manyidu = item.Manyidu;
                    s.Jiage = item.Jiage;
                }
            }

            return s;
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            Storage c = new Storage();
            c.show1();
            c.menu();
            Console.ReadLine();

        }
    }
}

相關文章