说了会再见,最近好吗?无论你在哪里>也许你在温暖的家,或许你在身在异乡的城市;或许你高高的峰顶放生高歌,或许你还在陡峭的山峰半空努力攀爬.......相信我们都会登上顶峰,"会当凌绝顶,一览众山小"..
今天给大家分享===>库存管理系统
如图(部分):
01.首先我们得先创建一个仓库类,定义些属性>>
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace Day01{ public class Goods { //神器类 public string name; public string difang; public double price; public double high; }}
02.然后我们再创建顾客类>>
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace Day01{ public class Custor { Goods[] goods = new Goods[3]; public void Initial() { //01.数组的值 //1 Goods goods1 = new Goods(); goods1.name = "葵花宝典"; goods1.difang = "天庭"; goods1.price = 1.28; goods1.high = 90; goods[0] = goods1; //2 Goods goods2 = new Goods(); goods2.name = "独孤九剑"; goods2.difang = "人间"; goods2.price = 3.50; goods2.high = 90; goods[1] = goods2; //3 Goods goods3 = new Goods(); goods3.name = "吸星大法"; goods3.difang = "魔界"; goods3.price = 12.65; goods3.high = 90; goods[2] = goods3; } public void ShowMenu() { //02.输出神器清单 Console.WriteLine("=====神器清单列表=====>>>"); Console.WriteLine(); foreach (Goods item in goods) { if (item != null) { Console.WriteLine("商品名称:{0}", item.name); Console.WriteLine("============================="); } } } public void Welcome() { Console.WriteLine("=====欢迎使用神器系统=====>>>"); Console.WriteLine("1.根据神器名称获取神器地址 2.取得客户满意度最高的货品 3.退出"); Console.WriteLine("请选择:"); int num = int.Parse(Console.ReadLine()); switch (num) { case 1: // GetGoodsPlace(); break; case 2: Console.WriteLine(); break; case 3: Console.WriteLine("退出"); break; } } public void GetGoodsPlace() { //03.查询神器位置 bool flag1 = false; Console.WriteLine("请输入货品名称:"); string name1 = Console.ReadLine(); for (int i = 0; i <goods.Length; i++) { if (goods[i].name==name1) { flag1 = true; goods[i].high++; Console.WriteLine("此神器在:{0}",goods[i].difang); Console.WriteLine("自动转换为主页面==>>"); Welcome(); break; } } if (flag1 == false) { Console.WriteLine("没有此神器!"); Console.WriteLine("自动转换为主页面==>>"); Welcome(); } } public void GetMaxPleased()
{ //04.获取客户满意度(当满意度相同的时候) if (goods[0].high > goods[1].high && goods[1].high >= goods[2].high || goods[0].high >= goods[1].high && goods[1].high > goods[2].high) { Console.WriteLine("客户满意度最高的货品:{0}\t摆放在:{1}\t满意度:{2}\t价格:{3}", goods[0].name, goods[0].difang, goods[0].high, goods[0].price); } if (goods[0].high == goods[1].high && goods[1].high == goods[2].high) { Console.WriteLine("未能判断出最高满意度!他们的满意度都为:{0}", goods[0].high); } if (goods[1].high > goods[0].high && goods[0].high >= goods[2].high || goods[1].high >= goods[0].high && goods[0].high > goods[2].high) { Console.WriteLine("客户满意度最高的货品:{0}\t摆放在:{1}\t满意度:{2}\t价格:{3}", goods[1].name, goods[1].difang, goods[1].high, goods[1].price); } if (goods[2].high > goods[0].high && goods[0].high >= goods[1].high || goods[2].high >= goods[0].high && goods[0].high > goods[1].high) { Console.WriteLine("客户满意度最高的货品:{0}\t摆放在:{1}\t满意度:{2}\t价格:{3}", goods[2].name, goods[2].difang, goods[2].high, goods[2].price); } if (goods[0].high > goods[2].high && goods[2].high >= goods[1].high || goods[0].high >= goods[2].high && goods[2].high > goods[1].high) { Console.WriteLine("客户满意度最高的货品:{0}\t摆放在:{1}\t满意度:{2}\t价格:{3}", goods[0].name, goods[0].difang, goods[0].high, goods[0].price); } } }}
02-2大家是不是好麻烦的样子,有可能你会花好长时间,不要这样,教你一个简单的方法(当满意度不同的时候):
//01.首先先给满意度goods[i].high赋不同的值 public double GetMaxPleased2() { //02.利用冒泡排序找出最大值 for (int i = 0; i < goods.Length-1; i++) { for (int j = 0; j <goods.Length-1-i; j++) { if (goods[j].high>goods[j+1].high) { double temp = goods[j].high; goods[j].high = goods[j + 1].high; goods[j + 1].high = temp; } } } return goods[2].high;//返回最大的值 //03.最后在main方法中接收并输出....... }
是不是有种豁然开朗的感觉,不用谢,可能在你们高手的眼里这都是不值一提的.......见谅吧!
03.最后我们就可以在main方法中调用>>
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace Day01{ public class Program { static void Main(string[] args) { Custor custor = new Custor(); custor.Initial(); custor.ShowMenu(); custor.Welcome(); Console.ReadLine(); } }}
谢谢!我亲爱的朋友们!如果我有不对的地方或你有好的建议和意见,望赐教哟!
时间有限,下约楼!!!!!!!
QQ:1907832004