예제 #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);
            }
예제 #3
0
        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);
        }