示例#1
0
文件: Program.cs 项目: weiliji/.net
        public static Food CreateFood(string type)
        {
            Food food = null;
            if (type.Equals("土豆肉丝"))
            {
                food = new ShreddedPorkWithPotatoes();
            }
            else if (type.Equals("西红柿炒蛋"))
            {
                food = new TomatoScrambledEggs();
            }

            return food;
        }
示例#2
0
            public static Food CreateFood(string type)
            {
                Food food = null;

                if (type.Equals("土豆肉丝"))
                {
                    food = new ShreddedPorkWithPotatoes();
                }
                else if (type.Equals("西红柿炒蛋"))
                {
                    food = new TomatoScrambledEggs();
                }

                return(food);
            }
        public static Food CreateFood(string type)
        {
            Food food = null;

            switch (type)
            {
            case "西红柿炒鸡蛋":
                food = new TomatoScrambledEggs();
                break;

            case "土豆肉丝":
                food = new ShreddedPorkWithPotatoes();
                break;

            default: break;
            }
            return(food);
        }