private void AmericanoRadio_CheckedChanged(object sender, EventArgs e) { if (((RadioButton)sender).Checked == true) { rAmericano = ((RadioButton)sender).Name; } if (rAmericano == "NormalAmericano") { Baverages bev = new Americano(); string x = string.Format("{0} - ${1}", bev.GetDescription(), bev.GetPrice() * Convert.ToDouble(AmericanoUpDown.Value)); AmericanoOrder.Text = x; } if (rAmericano == "ExtraAmericano") { Baverages bev = new Americano(); bev = new Milk(bev); string x = string.Format("{0} - ${1}", bev.GetDescription(), bev.GetPrice() * Convert.ToDouble(AmericanoUpDown.Value)); AmericanoOrder.Text = x; } }
public void AmericanoClass_ShouldInheritCoffeeAbstractClass() { // Arrange var coffeeSize = CoffeSizeType.Medium; // Act var obj = new Americano(coffeeSize); // Assert Assert.That(obj, Is.InstanceOf <Coffee>()); }
public void AmericanoClass_Countructor_ShouldInitializeObjectCorrectly() { // Arrange var coffeeSize = CoffeSizeType.Medium; // Act var obj = new Americano(coffeeSize); // Assert Assert.That(obj, Is.InstanceOf <Americano>()); }
public void AmericanoClass_FullDescriptionProperty_ShouldExists() { // Arrange var coffeeSize = CoffeSizeType.Medium; // Act var obj = new Americano(coffeeSize); // Assert Assert.That(obj, Has.Property("FullDescription")); }
public void AmericanoClass_ShouldImplementICoffeeInterface() { // Arrange var coffeeSize = CoffeSizeType.Medium; // Act var obj = new Americano(coffeeSize); // Assert Assert.That(obj, Is.InstanceOf <ICoffee>()); }
public void AmericanoClass_IdProperty_ShouldReturnCorrectId() { // Arrange var coffeeSize = CoffeSizeType.Medium; var expectedId = "AM"; // Act var obj = new Americano(coffeeSize); // Assert Assert.That(obj, Has.Property("Id").EqualTo(expectedId)); }
public void AmericanoClass_CostMethod_ShouldReturnCorrectPriceBasedOnCoffeSize(CoffeSizeType coffeeSize) { // Arrange var basePrice = 3.10m; var expectedCost = basePrice + (((int)coffeeSize / 100) * basePrice); // Act var obj = new Americano(coffeeSize); // Assert Assert.That(obj.Cost(), Is.EqualTo(expectedCost)); }
public void AmericanoClass_Countructor_ShouldSetSizeCorrectly() { // Arrange var coffeeSize = CoffeSizeType.Medium; var expectedSize = coffeeSize.ToString(); // Act var obj = new Americano(coffeeSize); // Assert Assert.That(obj.FullDescription, Does.Contain(expectedSize)); }
private static void RunDecorateTest() { Console.WriteLine("Decorate"); Beverage beverage = new Water(); Console.WriteLine("beverage Cost:{0}", beverage.Cost()); Beverage milk = new Milk(beverage); Console.WriteLine("milk Cost:{0}", milk.Cost()); Beverage mixBeverage = new Americano(milk); Console.WriteLine("Milk And Americano Cost:{0}", mixBeverage.Cost()); }
public void AmericanoClass_FullDescriptionProperty_ShouldReturnCorrectFullDescription() { // Arrange var coffeeSize = CoffeSizeType.Medium; var expectedDescription = "Americano"; var expectedSize = coffeeSize.ToString(); var expectedFullDescription = expectedSize + " " + expectedDescription; // Act var obj = new Americano(coffeeSize); // Assert Assert.That(obj, Has.Property("FullDescription").EqualTo(expectedFullDescription)); }
public void Americano_ReturnedCorrectly() { var coffee = new Americano(_baseCoffee); bool condition = coffee.Temperature == 37; Assert.True(condition, "Coffee should be 37 Degs"); Assert.True(coffee.Name == "Americano", $"Should be called Americano not ${coffee.Name}"); coffee.Name = "Chilled Americano"; Assert.True(coffee.Name == "Chilled Americano", $"Should be called Chilled Americano not ${coffee.Name}"); Assert.Equal(330, coffee.Liquid); coffee.Drink(); Assert.Equal(320, coffee.Liquid); coffee.Drink(); Assert.Equal(310, coffee.Liquid); }
public void StarbuzzCafe() { //Beverage beverage = new Americano(); //Console.WriteLine(beverage.GetDescription() + " $" + beverage.Cost()); //beverage = new Mocha(beverage); //Console.WriteLine(beverage.GetDescription() + " $" + beverage.Cost()); Beverage beverage1 = new Americano(); beverage1 = new Mocha(beverage1); beverage1 = new Mocha(beverage1); beverage1 = new Whip(beverage1); //beverage1 = new DarkRoast(); Console.WriteLine(beverage1.GetDescription() + " $" + beverage1.Cost()); }
/// <summary> /// 模板方法 /// </summary> static void TemplateMethod() { Console.WriteLine($"模板方法模式{Environment.NewLine}-------------------------------------------"); Console.WriteLine("开始制作:[意式浓缩咖啡]"); CoffeTemplate coffe = new Espresso(); coffe.MakeCoffe(); Console.WriteLine($"制作完毕{Environment.NewLine}"); Console.WriteLine("开始制作:[美式咖啡]"); coffe = new Americano(); coffe.MakeCoffe(); Console.WriteLine($"制作完毕{Environment.NewLine}"); Console.WriteLine("开始制作:[拿铁咖啡]"); coffe = new Latte(); coffe.MakeCoffe(); Console.WriteLine($"制作完毕{Environment.NewLine}"); Console.ReadKey(); }
private void CreateTxt_Click(object sender, RoutedEventArgs e) { Divida divida = new Divida(double.Parse(txtMontante.Text, NumberStyles.Currency), double.Parse(txtJuros.Text.Replace("%", "")), int.Parse(txtNParcelas.Text)); IAmortizacao amortizacao = null; Models.AmortizacaoPDF pdf = null; string _title = "Tabela"; switch (cbTipo.SelectedIndex) { case 0: amortizacao = new SAC(); pdf = new Models.AmortizacaoPDF(typeof(SAC)); _title = "Tabela SAC"; break; case 1: amortizacao = new Price(); pdf = new Models.AmortizacaoPDF(typeof(Price)); _title = "Tabela Price"; break; case 2: amortizacao = new Americano(); pdf = new Models.AmortizacaoPDF(typeof(Americano)); _title = "Tabela Americano"; break; } divida = amortizacao.Calcular(divida); pdf.Source = divida; gridPDF grid = new gridPDF(pdf); grid.Title = _title; grid.Show(); }
public void Reset() { coffee = new Americano(); }
private void GiveOrder_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(Customer.Text)) { MessageBox.Show("Please specify a name!", "Warning!!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { bool control = false; foreach (string choice in ProductList.CheckedItems) { string CustomerSent = Customer.Text; if (choice == "TastingSude") { Baverages tasting = new LeShokaladeSude(); tasting = new Tasting(tasting); DatabaseInsert insert = new DatabaseInsert(); insert.Connection(); insert.InsertTakeAway(CustomerSent, choice, tasting.GetPrice()); insert.Execute(); insert.Close(); control = true; } if (choice == "FillingSude") { Baverages filling = new LeShokaladeSude(); filling = new Filling(filling); DatabaseInsert insert = new DatabaseInsert(); insert.Connection(); insert.InsertTakeAway(CustomerSent, choice, filling.GetPrice()); insert.Execute(); insert.Close(); control = true; } if (choice == "TastingNeriman") { Baverages tasting = new LeShokaladeNeriman(); tasting = new Tasting(tasting); DatabaseInsert insert = new DatabaseInsert(); insert.Connection(); insert.InsertTakeAway(CustomerSent, choice, tasting.GetPrice()); insert.Execute(); insert.Close(); control = true; } if (choice == "FillingNeriman") { Baverages filling = new LeShokaladeNeriman(); filling = new Filling(filling); DatabaseInsert insert = new DatabaseInsert(); insert.Connection(); insert.InsertTakeAway(CustomerSent, choice, filling.GetPrice()); insert.Execute(); insert.Close(); control = true; } if (choice == "Lemonade") { Baverages bev = new Lemonade(); DatabaseInsert insert = new DatabaseInsert(); insert.Connection(); insert.InsertTakeAway(CustomerSent, bev.GetDescription(), bev.GetPrice()); insert.Execute(); insert.Close(); control = true; } if (choice == "Americano") { Baverages bev = new Americano(); DatabaseInsert insert = new DatabaseInsert(); insert.Connection(); insert.InsertTakeAway(CustomerSent, bev.GetDescription(), bev.GetPrice()); insert.Execute(); insert.Close(); control = true; } if (choice == "MilkyAmericano") { Baverages bev = new Americano(); bev = new Milk(bev); DatabaseInsert insert = new DatabaseInsert(); insert.Connection(); insert.InsertTakeAway(CustomerSent, bev.GetDescription(), bev.GetPrice()); insert.Execute(); insert.Close(); control = true; } } if (control) { MessageBox.Show("Your order has been received.", "Thank you :)"); AbstractStore store = new LeShokaladeDukkan(); Box.Text = store.OrderDessert("sude").Box(); for (int i = 0; i < ProductList.Items.Count; i++) { ProductList.SetItemChecked(i, false); } Orders.Text = " "; Customer.Text = "Your Name"; } else { MessageBox.Show("You did not choose any order!", "Warning!!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
public static bool BuyCoffee() { string userInput = ""; if (firstTime == true) { Console.WriteLine("Which coffee do you want? (Black coffee/Coffee with milk/Cappuccino/Latte/Americano/Espresso)"); } else if (firstTime == false) { Console.WriteLine("This is not an option, please try again. (Black coffee/Coffee with milk/Cappuccino/Latte/Americano/Espresso)"); } firstTime = true; userInput = Console.ReadLine(); Console.Clear(); //Coffee types if (userInput == "Black coffee") { var BlackCoffee = new BlackCoffee(); BlackCoffee.afterPurchase(); } else if (userInput == "Coffee with milk") { var CoffeeWithMilk = new CoffeeWithMilk(); CoffeeWithMilk.afterPurchase(); } else if (userInput == "Cappuccino") { var Cappuccino = new Cappuccino(); Cappuccino.afterPurchase(); } else if (userInput == "Latte") { var Latte = new Latte(); Latte.afterPurchase(); } else if (userInput == "Americano") { var Americano = new Americano(); Americano.afterPurchase(); } else if (userInput == "Espresso") { var Espresso = new Espresso(); Espresso.afterPurchase(); } else { firstTime = false; BuyCoffee(); } Console.WriteLine("Do you wish to continue? (yes/no)"); userInput = Console.ReadLine(); Console.Clear(); if (userInput == "yes") { return(true); } else { Environment.Exit(0); } return(false); }
public AmericanoBuilder() { americano = new Americano(); }
private void Order_Click(object sender, EventArgs e) { bool control = false; if (LemonCheck.Checked) { Baverages bev = new Lemonade(); DatabaseInsert insert = new DatabaseInsert(); insert.Connection(); insert.InsertOrders(Table, bev.GetDescription(), bev.GetPrice() * Convert.ToDouble(LemonUpDown.Value), Convert.ToInt32(LemonUpDown.Value)); insert.Execute(); insert.Close(); control = true; } if (AmericanoCheck.Checked) { if (NormalAmericano.Checked) { Baverages bev = new Americano(); DatabaseInsert insert = new DatabaseInsert(); insert.Connection(); insert.InsertOrders(Table, bev.GetDescription(), bev.GetPrice() * Convert.ToDouble(AmericanoUpDown.Value), Convert.ToInt32(AmericanoUpDown.Value)); insert.Execute(); insert.Close(); control = true; } if (ExtraAmericano.Checked) { Baverages bev = new Americano(); bev = new Milk(bev); DatabaseInsert insert = new DatabaseInsert(); insert.Connection(); insert.InsertOrders(Table, bev.GetDescription(), bev.GetPrice() * Convert.ToDouble(AmericanoUpDown.Value), Convert.ToInt32(AmericanoUpDown.Value)); insert.Execute(); insert.Close(); control = true; } } if (TCoffeeCheck.Checked) { if (SugarFree.Checked) { Baverages bev = new TurkishCoffee(); bev = new SugarFree(bev); DatabaseInsert insert = new DatabaseInsert(); insert.Connection(); insert.InsertOrders(Table, bev.GetDescription(), bev.GetPrice() * Convert.ToDouble(TCoffeeUpDown.Value), Convert.ToInt32(TCoffeeUpDown.Value)); insert.Execute(); insert.Close(); control = true; } if (MidSugar.Checked) { Baverages bev = new TurkishCoffee(); bev = new MidSugar(bev); DatabaseInsert insert = new DatabaseInsert(); insert.Connection(); insert.InsertOrders(Table, bev.GetDescription(), bev.GetPrice() * Convert.ToDouble(TCoffeeUpDown.Value), Convert.ToInt32(TCoffeeUpDown.Value)); insert.Execute(); insert.Close(); control = true; } if (Sugary.Checked) { Baverages bev = new TurkishCoffee(); bev = new Sugary(bev); DatabaseInsert insert = new DatabaseInsert(); insert.Connection(); insert.InsertOrders(Table, bev.GetDescription(), bev.GetPrice() * Convert.ToDouble(TCoffeeUpDown.Value), Convert.ToInt32(TCoffeeUpDown.Value)); insert.Execute(); insert.Close(); control = true; } } if (control) { MessageBox.Show("Your order has been received."); LemonCheck.Checked = false; AmericanoCheck.Checked = false; TCoffeeCheck.Checked = false; } else { MessageBox.Show("You did not choose any order!", "Warning!!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public AmericanoBuilder() { coffee = new Americano(); }