百姓实惠超市部分

    xiaoxiao2021-12-12  2

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication2 { class Storage { Goods user = new Goods(); Goods[] userGroup = new Goods[3]; public void chushihua() { userGroup[0] = new Goods(); userGroup[0].Name = "杯子"; userGroup[0].Weizhi = "第一仓库第一排"; userGroup[1] = new Goods(); userGroup[1].Name = "花瓶"; userGroup[1].Weizhi = "第一仓库第二排"; userGroup[2] = new Goods(); userGroup[2].Name = "热水器"; userGroup[2].Weizhi = "第一仓库第三排"; Console.WriteLine("库存货品清单列表"); Console.WriteLine("-----------------"); foreach (Goods item in userGroup) { string a = string.Format("货品名称:{0}", item.Name); Console.WriteLine(a); } Console.WriteLine("-----------------"); } public void Menu()//显示货品菜单 { do { Console.WriteLine("=====================欢迎使用库存管理系统======================"); Console.WriteLine("1:根据货品名称获取货品位置2:取得客户满意度最高的货品3:退出"); Console.WriteLine("==============================================================="); Console.WriteLine("请选择:"); string xuan = Console.ReadLine(); switch (xuan) { case "1": if (GetGoodsplace() == false) Console.WriteLine("您输入的货品名称不正确!"); break; case "2": break; case "3": break; default: Console.WriteLine("菜单选择错误,请重新输入选项!"); break; } } while (true); } private bool GetGoodsplace() { bool flag = false; Console.WriteLine("请输入货品名称:"); string goods = Console.ReadLine(); foreach (Goods item in userGroup) { if (item.Name.Equals(goods)) { flag = true; Console.WriteLine(item.Weizhi); } } return flag; } } } using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication2 { class Goods { private string name = "";//货品名称 public string Name { get { return name; } set { name = value; } } private string weizhi = "";//货品位置 public string Weizhi { get { return weizhi; } set { weizhi = value; } } } } using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { Storage s = new Storage(); s.chushihua(); s.Menu(); } } }
    转载请注明原文地址: https://ju.6miu.com/read-900198.html

    最新回复(0)