private void GiveBirth(IPoultry femalePoultry) { RabbitProvider rabbitValidator = new RabbitProvider(femalePoultry, Date); int childLength = rabbitValidator.GetNumberOffSpring(); for (int i = 0; i < childLength; i++) { double randomValue = _random.NextDouble(); Poultry child = new Poultry(); if (randomValue > RabbitConstant.FemaleBirthRate) { child.isMale = false; } else { child.isMale = true; } child.isPregnant = false; child.BirthDate = Date; child.PoultryEnum = (int)PoultryEnum.Rabbit; _poultryList.Add(child); } }
public Taco(IngredientFactory ingredientFactory) { _poultry = ingredientFactory.GetPoultry(); _meat = ingredientFactory.GetMeat(); _vegetation = ingredientFactory.GetVegetation(); _cheese = ingredientFactory.GetCheese(); _guacomole = ingredientFactory.GetGuacomole(); _rice = ingredientFactory.GetRice(); _beans = ingredientFactory.GetBeans(); _creamCheese = ingredientFactory.GetCreamCheese(); _tomato = ingredientFactory.GetTomato(); _chili = ingredientFactory.GetChili(); }
List <IWine> IWinePairService.FindBestMatchingWines(IFood food) { List <IWine> bestMatch = new List <IWine>(); if (food == null) { food = new Poultry(); Console.WriteLine("Defaulting to Chicken"); } FillWineLists(food, bestMatch, null); return(bestMatch); }
static void Main(string[] args) { //SOLID Prensipleri=> Solid, beş önemli OOP prensiplerinin kısaltmasıdır. /* * Temiz, modüler ve genişletilebilir kod yazımında önemli kuralları tanımlar. * Aynı zamnda Agile yaızlım geliştirme için gereklidir. * * * SRP=> Single Responsibility Pricinple. * //Bir class sadece bir iş yapıyor olmalı. */ //Employee employee = new Employee(); //employee.ID = 1; //employee.FirstName = "Fatih"; //employee.LastName = "Günalp"; //employee.HireDate = new DateTime(2020, 02, 02); //BadEmployeeProcessor badEmployee = new BadEmployeeProcessor(); //badEmployee.InsertEmployee(employee); //Console.ReadKey(); //GoodEmployeeProcessor good = new GoodEmployeeProcessor(); //Console.WriteLine(good.InsertEmployee(employee) ? "Başarılır" : "Başarısız"); //Console.ReadKey(); //OCP=> Open/Closed Principle /* * Sınıflar ve metotlar genişletmeye açık değişikliğe kapalı olmalıdır. */ // BadCoffee badCoffee = new BadCoffee(); //decimal americano= badCoffee.GetTotalPrice(2, CoffeeType.Americano); // Console.WriteLine(americano.ToString()); // Console.ReadKey(); //GoodCoffee kahve1 = new Espresso(); //GoodCoffee kahve2 = new Americano(); //decimal price = 0; //price = kahve1.GetTotalPrice(5); //Console.WriteLine(price.ToString()); //Console.ReadKey(); //LSP=> Liskov's substution principle /* * Bir sınıftan türetilen sınıflar, base sınıfın yerine de kullanılabilmelidir. */ //BadReactangle reactangle = new BadReactangle(); //reactangle.Width = 2; //reactangle.Height = 3; //if (BadAreaCalculator.CalculateArea(reactangle) != 6) //{ // Console.WriteLine("Dörtgen alan hesaplamasında hatalı işlem"); //} //BadSquare square = new BadSquare(); //square.Height = 3; //if (BadAreaCalculator.CalculateArea(square) != 9) //{ // Console.WriteLine("Kare Alanı hesaplamasında hatalı işlem"); //} //Rectagle rectagle = new Rectagle(); //rectagle.Width = 2; //rectagle.Height = 3; //rectagle.Bildirim = "Dörtgen Oluşturuldu"; //if (rectagle.RectangleArea() != 6) //{ // Console.WriteLine("Dörtgen Alanı hesaplamasında hata var."); //} //Square square = new Square(); //square.Width = 4; //square.Bildirim = "Kare Oluşturuldu"; //if (square.SquareArea() != 16) //{ // Console.WriteLine("Kare Alanı hesaplamasında hata var."); //} //ISP => Interface Segregation Principle /* * sınıflar ihtiyaçları olmayan özellik ve davranışları içeren interfaceleri almamalıdır. */ //DIP=> Dependency Inversion Principle /* * Üst seviye sınıflar alt seviye sınıflara bağımlı olmamalıdır. * */ //BadRestaurant restaurant = new BadRestaurant(); //string instructions=restaurant.GenerateInstructions(); //Console.WriteLine(instructions); //Console.ReadKey(); Fish tuna = new Fish(); Poultry duck = new Poultry(); List <IProduct> urunler = new List <IProduct>(); urunler.Add(tuna); urunler.Add(duck); Restaurant restaurant = new Restaurant(urunler); restaurant.GenerateInstructions(); Console.WriteLine(restaurant.GenerateInstructions()); Console.ReadKey(); }
public SkillResponse GetWine(SkillRequest input, ILambdaContext context) { try { var requestType = input.GetRequestType(); if (requestType == typeof(IntentRequest)) { IFood request = null; var intentReq = input.Request as IntentRequest; if (intentReq.Intent.Name == "AMAZON.HelpIntent" || intentReq.Intent.Slots.ContainsKey("meat") == false) { return(ResponseBuilder.Ask("Try asking for a meat to pair.", new Reprompt("Would you like to pair a meat?"))); } string intentValue = intentReq.Intent.Slots["meat"].Value; if (intentValue.Contains("beef") || intentValue.Contains("steak") || intentValue.Contains("lamb") || intentValue.Contains("goat") || intentValue.Contains("veal")) { request = new RedMeat(); } else if (intentValue.Contains("cured") || intentValue.Contains("bacon") || intentValue.Contains("salami")) { request = new CuredMeat(); } else if (intentValue.Contains("pork") || intentValue.Contains("ham")) { request = new Pork(); } else if (intentValue.Contains("chicken") || intentValue.Contains("poultry") || intentValue.Contains("light meat") || intentValue.Contains("dark meat") || intentValue.Contains("duck") || intentValue.Contains("turkey") || intentValue.Contains("goose")) { request = new Poultry(); } else if (intentValue.Contains("mollusk") || intentValue.Contains("clam") || intentValue.Contains("oyster") || intentValue.Contains("mussel") || intentValue.Contains("scallop")) { request = new Mollusk(); } else if (intentValue.Contains("shellfish") || intentValue.Contains("shrimp") || intentValue.Contains("lobster") || intentValue.Contains("crab")) { request = new Shellfish(); } else if (intentValue.Contains("fish") || intentValue.Contains("seafood") || intentValue.Contains("salmon")) { request = new Fish(); } if (request == null) { Console.WriteLine("Null request sent to matching service with intentValue: " + intentValue); } var matches = _winePair.FindBestMatchingWines(request); IWine match1, match2 = match1 = null; if (matches.Count >= 2) { match1 = matches[0]; match2 = matches[1]; } else if (matches.Count == 1) { match1 = matches[0]; } if (match1 == null && match2 == null) { throw new Exception("Could not find matching wine."); } string response; if (match1 != null && match2 != null) { response = string.Format("You should try a {0} wine like {1} or a {2} wine like {3}", match1.Style.ToString(), match1.Name, match2.Style.ToString(), match2.Name); } else { response = string.Format("You should try a {0} wine like {1}", match1.Style.ToString(), match1.Name); } return(ResponseBuilder.Tell(response)); } else if (requestType == typeof(LaunchRequest)) { var response = ResponseBuilder.Ask("What can I pair for you?", new Reprompt("Would you like to pair a wine?")); response.Response.ShouldEndSession = false; return(response); } } catch (Exception e) { Console.Write("Exception Caught: "); Console.WriteLine(e); } return(ResponseBuilder.Ask("What would you like to pair?", new Reprompt("What would you like to pair?"))); }