/// <summary> /// 取货 /// </summary> /// <param name="strType">货物类型</param> /// <param name="count">数量</param> /// <returns></returns> public ProductFather[] GetPro(string strType, int count) { ProductFather[] proGet = new ProductFather[count]; for (int i = 0; i < proGet.Length; i++) { switch (strType) { case "Acer": proGet[i] = list[0][0]; list[0].RemoveAt(0); break; case "Banana": proGet[i] = list[1][0]; list[1].RemoveAt(0); break; case "SamSung": proGet[i] = list[2][0]; list[2].RemoveAt(0); break; case "Jiang": proGet[i] = list[3][0]; list[3].RemoveAt(0); break; } } return(proGet); }
/// <summary> /// 取货 /// </summary> /// <param name="strType">货物类型</param> /// <param name="count">货物数量</param> public ProductFather[] QuPros(string strType, int count) { ProductFather[] pros = new ProductFather[count]; for (int i = 0; i < count; i++) { switch (strType) { case "Acer": pros[i] = list[0][0]; list[0].RemoveAt(0); break; case "SamSung": pros[i] = list[1][0]; list[1].RemoveAt(0); break; case "JiangYou": pros[i] = list[2][0]; list[2].RemoveAt(0); break; case "Banana": pros[i] = list[3][0]; list[3].RemoveAt(0); break; } } return(pros); }
/// <summary> /// 取货 /// </summary> /// <param name="strType">取货类型</param> /// <param name="count">取货数</param> /// <returns></returns> public ProductFather[] GetProducts(string strType, int count) { //因为取货数量知道为count,所以定义为一个数组取数据 ProductFather[] pros = new ProductFather[count]; for (int i = 0; i < count; i++) { switch (strType) { case "Acer": pros[i] = list[0][0]; list[0].RemoveAt(0); break; case "SamSung": pros[i] = list[1][0]; list[1].RemoveAt(0); break; case "banana": pros[i] = list[2][0]; list[2].RemoveAt(0); break; case "Sauce": pros[i] = list[3][0]; list[3].RemoveAt(0); break; } } return(pros); }
/// <summary> /// 从仓库取货 /// </summary> /// <param name="strType">货物类型</param> /// <param name="count">货物数量</param> /// <returns></returns> public ProductFather [] OutputPros(string strType, int count) { ProductFather[] Pros = new ProductFather[count]; for (int i = 0; i < Pros.Length; i++) { switch (strType) { case "Acer": Pros[i] = wh[0][0]; ///Warehouse[0][0],Warehouse[0]是存储Acer的货架,Warehouse[0][0]是货架上的第一个元素 wh[0].RemoveAt(0); break; case "SamSung": Pros[i] = wh[1][0]; wh[1].RemoveAt(0); break; case "Napkin": Pros[i] = wh[2][0]; wh[2].RemoveAt(0); break; case "Banana": Pros[i] = wh[3][0]; wh[3].RemoveAt(0); break; } } return(Pros); }
/// <summary> /// 取货 /// </summary> /// <param name="strType"></param> /// <param name="count"></param> public ProductFather[] QuPros(string strType, int count) { //List<ProductFather> list1 = new List<ProductFather>(); //因为数量确定为count,所以用数组 ProductFather[] pros = new ProductFather[count]; for (int i = 0; i < count; i++) { switch (strType) { case "Acer": if (list[0].Count != 0) { pros[i] = list[0][0]; //每次都拿货架list[0]的第一个,取后自动补偿(只是读取,后面需要删除) list[0].RemoveAt(0); //删除第一个 //list1.Add(list[0][0]); } break; case "SamSung": if (list[1].Count != 0) { pros[i] = list[1][0]; list[1].RemoveAt(0); } break; case "JiangYou": if (list[2].Count != 0) { pros[i] = list[2][0]; list[2].RemoveAt(0); } break; case "Banana": if (list[3].Count != 0) { pros[i] = list[3][0]; list[3].RemoveAt(0); } break; } } return(pros); }
/// <summary> /// 取货 /// </summary> /// <param name="price">取货的名称</param> /// <param name="count">取货的数量</param> /// <returns></returns> public ProductFather[] Getproduct(string price, int count) { //我们需要定义一个数组接收我们取出来的货物 ProductFather[] pf = new ProductFather[count]; for (int i = 0; i < count; i++) { switch (price) { //判断取出的是什么货物, //list[0]代表取出的是第一个货物 //list[0][0]后面那个0是代表取这个货物的第一个货物 //取完货物我们应该把这个货删除了 case "Acer": if (list[0].Count != 0) { pf[i] = list[0][0]; list[0].RemoveAt(0); } else { Console.WriteLine("对不起,货物暂时不足!"); } break; case "SamSung": if (list[0].Count != 0) { pf[i] = list[1][0]; list[1].RemoveAt(0); } else { Console.WriteLine("对不起,货物暂时不足!"); } break; case "Sauce": if (list[0].Count != 0) { pf[i] = list[2][0]; list[2].RemoveAt(0); } else { Console.WriteLine("对不起,货物暂时不足!"); } break; case "Banana": if (list[0].Count != 0) { pf[i] = list[3][0]; list[3].RemoveAt(0); } else { Console.WriteLine("对不起,货物暂时不足!"); } break; } } return(pf); }