protected override void AddObjectToFarm(string[] inputCommands)
        {
            string type = inputCommands[1];
            string id = inputCommands[2];

            switch (type)
            {
                case "TobaccoPlant":
                    {
                        var plant = new TobaccoPlant(id);
                        (this.farm as Farm).AddPlant(plant);
                    }
                    break;
                case "CherryTree":
                    {
                        var cherry = new CherryTree(id);
                        (this.farm as Farm).AddPlant(cherry);
                    }
                    break;
                case "Cow":
                    {
                        var cow = new Cow(id);
                        (this.farm as Farm).AddAnimal(cow);
                    }
                    break;
                case "Swine":
                    {
                        var swine = new Swine(id);
                        (this.farm as Farm).AddAnimal(swine);
                    }
                    break;
                default: base.AddObjectToFarm(inputCommands);
                    break;
            }
        }
示例#2
0
 protected override void AddObjectToFarm(string[] inputCommands)
 {
     string type = inputCommands[1];
     string id = inputCommands[2];
     switch (type)
     {
         case "CherryTree":
             var cherryTree= new CherryTree(id);
             base.farm.Plants.Add(cherryTree);
             break;
         case "TobaccoPlant":
             var tabaccoPlant= new TobaccoPlant(id);
             base.farm.Plants.Add(tabaccoPlant);
             break;
         case "Cow":
             var cow= new Cow(id);
             base.farm.Animals.Add(cow);
             break;
         case "Swine":
             var swine= new Swine(id);
             base.farm.Animals.Add(swine);
             break;
         default: base.AddObjectToFarm(inputCommands);
             break;
     }
 }
        protected override void AddObjectToFarm(string[] inputCommands)
        {
            string type = inputCommands[1];
            string id = inputCommands[2];

            switch (type)
            {
                case "TobaccoPlant":
                    {
                        var tobacco = new TobaccoPlant(id, 12, 10, 4);
                        this.farm.AddPlant(tobacco);
                    }
                    break;
                case "CherryTree":
                    {
                        var cherryTree = new CherryTree(id, 14, 4, 2, 3);
                        this.farm.AddPlant(cherryTree);
                    }
                    break;
                case "Cow":
                    {
                        var cow = new Cow(id, 15, 6, 4);
                        this.farm.AddAnimal(cow);
                    }
                    break;
                case "Swine":
                    {
                        var swine = new Swine(id, 20, 1, 5);
                        this.farm.AddAnimal(swine);
                    }
                    break;
                default:
                    base.AddObjectToFarm(inputCommands);
                    break;
            }
        }