namespace 仓库类
{
class CangKu
{
//第一个功能:存储货物
//list[0]存储Acer笔记本电脑
//list[1]存储三星手机
//list[2]存储酱油
//list[3]存储香蕉
//List<FatherProduct> list1 = new List<FatherProduct>();
List<List<FatherProduct>> list = new List<List<FatherProduct>>();//这里的List<FatherProduct>相当于货柜
/// <summary>
/// 在创建仓库对象的时候,向仓库中添加货架
/// </summary>
public CangKu()
{
list.Add(new List<FatherProduct>());
list.Add(new List<FatherProduct>());
list.Add(new List<FatherProduct>());
list.Add(new List<FatherProduct>());
}
//进货
public static void GetProducts(string type,int count)
{
for (int i = 0; i < count; i++)
{
switch(type)
{
case "Acer":list[0].Add(new Acer(Guid.NewGuid().ToString(), 4000, "宏基笔记本"));
break;
case "Samsung":list[1].Add(new Samsung(Guid.NewGuid().ToString(), 3000, "三星手机"));
break;
case "Banana":list[2].Add(new Banana(Guid.NewGuid().ToString(), 10, "香蕉"));
break;
case "JiangYou":list[3].Add(new JiangYou(Guid.NewGuid().ToString(), 20, "老抽"));
break;
}
}
}
}
}
什么原因呢?