作者:比刀郎还冲动啊 | 来源:互联网 | 2023-09-12 08:06
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication3
{
class Goods
{
private string _goodsName;
public string GoodsName
{
get { return _goodsName; }
set { _goodsName = value; }
}
private string _goodsPlace;
public string GoodsPlace
{
get { return _goodsPlace; }
set { _goodsPlace = value; }
}
private double _goodsPrice;
public double GoodsPrice
{
get { return _goodsPrice; }
set { _goodsPrice = value; }
}
private int _goodsPleased;
public int GoodsPleased
{
get { return _goodsPleased; }
set { _goodsPleased = value; }
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication3
{
class Storage
{
Goods goods = new Goods();
Goods[] good = new Goods[3];
//初始化信息
public void Initial()
{
good[0] = new Goods();
good[0].GoodsName = "杯子";
good[0].GoodsPlace = "第一仓库第一排";
good[0].GoodsPleased = 85;
good[0].GoodsPrice = 15;
good[1] = new Goods();
good[1].GoodsName = "花瓶";
good[1].GoodsPlace = "第一仓库第二排";
good[1].GoodsPleased = 99;
good[1].GoodsPrice = 17.25;
good[2] = new Goods();
good[2].GoodsName = "热水器";
good[2].GoodsPlace = "第一仓库第三排";
good[2].GoodsPleased = 89;
good[2].GoodsPrice = 100;
}
//输出库存的货物名称
public void ShowGoods()
{
Console.WriteLine("库存货品清单列表");
Console.WriteLine("-------------------------------");
foreach (Goods item in good)
{
Console.WriteLine("货品名称:" + item.GoodsName);
}
Console.WriteLine("-------------------------------");
}
//根据货物名称获取货物位置
public bool GetGoodsPlace()
{
bool flag=false;
Console.WriteLine("请输入货品名称");
string name = Console.ReadLine();
foreach (Goods item in good)
{
if (item.GoodsName.Equals(name))
{
flag = true;
Console.WriteLine(item.GoodsPlace);
}
}
return flag;
}
//满意度最高的信息
private void GetMaxPlease()
{
goods=GetPlease();
string goodsName = String.Format("客户满意度最高的货品:{0} 摆放在:{1} 满意度:{2} 价格:{3}", goods.GoodsName, goods.GoodsPlace, goods.GoodsPleased, goods.GoodsPrice);
Console.WriteLine("温馨提示:");
Console.WriteLine(goodsName);
}
private Goods GetPlease()
{
goods.GoodsPleased = 0;
foreach (Goods item in good)
{
if (item.GoodsPleased > goods.GoodsPleased)
{
goods.GoodsName = item.GoodsName;
goods.GoodsPlace = item.GoodsPlace;
goods.GoodsPleased = item.GoodsPleased;
goods.GoodsPrice = item.GoodsPrice;
}
}
return goods;
}
//显示菜单
public void ShowMenu()
{
string option = "";
do
{
Console.WriteLine("==================欢迎使用库存管理系统==================");
Console.WriteLine("1:根据货物名称获取货物位置 2:取得客户满意度最高的货品 3:退出");
Console.WriteLine("========================================================");
Console.WriteLine("请选择:");
option =Console.ReadLine();
switch (option)
{
case "1":
if (GetGoodsPlace() == false)
Console.WriteLine("您输入的货品名称不正确!");
continue;;
case "2":
GetMaxPlease();
continue;
case "3":
Console.WriteLine("已退出库存管理系统,谢谢您的使用");
break;
default:
Console.WriteLine("菜单选择错误,请重新输入选择!");
continue;
}
break;
} while (true);
}
}
}
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 storage = new Storage();
storage.Initial();
storage.ShowGoods();
storage.ShowMenu();
Console.ReadLine();
}
}
}