public override Product GetProduct() { if (!this.IsAlive) { throw new Exception("Swine cannot produce, it is already dead!");} var producedProduct = new Food(string.Format(this.Id + "Product"), ProductType.PorkMeat, FoodType.Meat, productionQuantity, healthEffect); this.Health = 0; return producedProduct; }
public override Product GetProduct() { if (!this.IsAlive) { throw new Exception("Cow" + Id + "Is dead, cannot produce milk"); } this.Health -= 2; var producedProduct = new Food(string.Format(Id + "Product"), ProductType.Milk, FoodType.Organic, productionQuantity,4); return producedProduct; }
public override Product GetProduct() { if (this.IsAlive) { this.Health -= 2; var pr = new Food(this.Id + "Product", PrType, FType, ProductionQuantity, HealthEffect); return pr; } throw new ArgumentException("Cow is not alive!"); }
public override Product GetProduct() { if (!this.IsAlive) { throw new InvalidOperationException("Swine is dead!"); } var product = new Food(this.Id + "Product", ProductType.PorkMeat, FoodType.Meat, this.ProductionQuantity, 5); this.Health = 0; return product; }
public override Product GetProduct() { if (!this.IsAlive) { throw new InvalidOperationException("Cherry tree is dead!"); } var product = new Food(this.Id + "Product", ProductType.Cherry, FoodType.Organic, this.ProductionQuantity, 2); return product; }
public override Product GetProduct() { if (!this.IsAlive) { throw new InvalidOperationException("Cow is dead!"); } var product = new Food(this.Id + "Product", ProductType.Milk, FoodType.Organic, this.ProductionQuantity, 4); this.Health -= 2; return product; }
public override Product GetProduct() { if (this.IsAlive) { Product product = new Food( this.Id + "Product", ProductType.PorkMeat, FoodType.Meat, this.ProductionQuantity, SwineBaseHealthEffect); this.Health = 0; return product; } else { throw new InvalidOperationException("Currently the operation is not alowed"); } }
protected virtual void AddObjectToFarm(string[] inputCommands) { string type = inputCommands[1]; string id = inputCommands[2]; switch (type) { case "Grain": { var food = new Food(id, ProductType.Grain, FoodType.Organic, 10, 2); this.farm.AddProduct(food); } break; default: break; } }
public static Product ProduceProduct(string originalID, ProductType productType) { string productID = originalID + PlantValues.PlantProductIDIndex; Product currentProduct; switch (productType) { case ProductType.Grain: { currentProduct = new Food(productID); LoadGrainProductValues(currentProduct as Food); return currentProduct as Food; } case ProductType.Tobacco: { currentProduct = new Product(productID); LoadTobaccoProductValues(currentProduct); return currentProduct; } case ProductType.Cherry: { currentProduct = new Food(productID); LoadCherryProductValues(currentProduct as Food); return currentProduct; } case ProductType.Milk: { currentProduct = new Food(productID); LoadMilkProductValues(currentProduct as Food); return currentProduct as Food; } case ProductType.PorkMeat: { currentProduct = new Food(productID); LoadPorkMeatProductValues(currentProduct as Food); return currentProduct as Food; } default: { throw new NotImplementedException("Unknown product type " + productType); } } }
private static void LoadPorkMeatProductValues(Food currentProduct) { currentProduct.Quantity = AnimalValues.SwineProductQuantity; currentProduct.FoodType = FoodType.Meat; currentProduct.HealthEffect = AnimalValues.SwineProductHealthEffect; }
private static void LoadMilkProductValues(Food currentProduct) { currentProduct.Quantity = AnimalValues.CowProductQuantity; currentProduct.FoodType = FoodType.Organic; currentProduct.HealthEffect = AnimalValues.CowProductHealthEffect; }
private static void LoadGrainProductValues(Food currentProduct) { currentProduct.Quantity = FoodPlantValues.GrainQuantity; currentProduct.ProductType = ProductType.Grain; currentProduct.HealthEffect = FoodPlantValues.GrainHealthEffect; currentProduct.FoodType = FoodType.Organic; }
private static void LoadCherryProductValues(Food currentProduct) { currentProduct.Quantity = FoodPlantValues.CherryTreeProductQuantity; currentProduct.FoodType = FoodType.Organic; currentProduct.ProductType = ProductType.Cherry; currentProduct.HealthEffect = FoodPlantValues.CherryTreeProductHealthEffect; }
public override Product GetProduct() { if (!this.IsAlive) { throw new Exception("CherryTree is dead, it cannot produce a product");} var producedProduct = new Food(string.Format(this.Id + "Product"), ProductType.Cherry, FoodType.Organic, productionQuantity, healthEffect); return producedProduct; }