static void Main(string[] args) { try { var FirstOwner = new Customer("Stefan", "Petrov"); var SecondOwner = new Customer("Ivan", "Ivanov"); var ThirdOwner = new Customer("Simeon", "Georgiev"); var BronzeCard = new BronzeCard(FirstOwner, 0); var SilverCard = new SilverCard(SecondOwner, 600); var GoldCard = new GoldCard(ThirdOwner, 1500); var PurchaseOne = new Purchase("HDD", 150); var PurchaseTwo = new Purchase("Huawei", 850); var PurchaseThree = new Purchase("Lenovo Y530", 1300); Purchase.PrintInfo(BronzeCard, PurchaseOne); Purchase.PrintInfo(SilverCard, PurchaseTwo); Purchase.PrintInfo(GoldCard, PurchaseThree); Console.ReadKey(); } catch (Exception e) { Console.WriteLine("Error:{0}", e.Message); } }
static void Main(string[] args) { BronzeCard bronzeCard = new BronzeCard() { Turnover = 0, PurchaseValue = 150 }; SilverCard silverCard = new SilverCard() { Turnover = 600, PurchaseValue = 850 }; GoldCard goldCard = new GoldCard() { Turnover = 1500, PurchaseValue = 1300 }; Console.WriteLine("1.Bronze"); Console.WriteLine(FormatString(bronzeCard)); Console.WriteLine("2.Silver"); Console.WriteLine(FormatString(silverCard)); Console.WriteLine("3.Gold"); Console.WriteLine(FormatString(goldCard)); }
static void Main(string[] args) { var user = new User("Ivan Ivanov"); var bronzeCard = new BronzeCard(user); var sivelrCard = new SilverCard(user); var goldCard = new GoldCard(user); try { bronzeCard.SetTurnover(0); sivelrCard.SetTurnover(600); goldCard.SetTurnover(1500); } catch (Exception e) { throw new InvalidOperationException(e.Message); } try { var purchaseWithBronze = new Purchase(bronzeCard, 150); var purchaseWithSilver = new Purchase(sivelrCard, 850); var purchaseWithGold = new Purchase(goldCard, 1300);; Console.WriteLine(purchaseWithBronze.Report()); Console.WriteLine(purchaseWithSilver.Report()); Console.WriteLine(purchaseWithGold.Report()); } catch (Exception e) { throw new InvalidOperationException(e.Message); } }
public static void Main() { var bronzeCard = new BronzeCard(0, 150); var silverCard = new SilverCard(600, 850); var goldCard = new GoldCard(1500, 1300); Console.WriteLine(bronzeCard.CalculateDiscount()); Console.WriteLine(silverCard.CalculateDiscount()); Console.WriteLine(goldCard.CalculateDiscount()); }
static void Main(string[] args) { BronzeCard bronzeCardOwner = new BronzeCard(1, 0); SilverCard silverCardOwner = new SilverCard(1, 600); GoldCard goldCardOwner = new GoldCard(3, 1500); Console.WriteLine("Bronze:"); bronzeCardOwner.CurrentPurchase(150); Console.WriteLine("Silver:"); silverCardOwner.CurrentPurchase(850); Console.WriteLine("Gold:"); goldCardOwner.CurrentPurchase(1300); }
static void Main(string[] args) { BronzeCard bc = new BronzeCard(0, 150); Console.WriteLine(bc.GetCardInformation()); Console.WriteLine(); SilverCard sc = new SilverCard(600, 850); Console.WriteLine(sc.GetCardInformation()); Console.WriteLine(); GoldCard gc = new GoldCard(1500, 1300); Console.WriteLine(gc.GetCardInformation()); }
static void Main(string[] args) { Cards bronzeCard = new BronzeCard(0, 150); bronzeCard.PrintData(); Cards silverCard = new SilverCard(600, 850); silverCard.PrintData(); Cards goldCard = new GoldCard(1500, 1300); goldCard.PrintData(); Console.Read(); }
static void Main(string[] args) { DiscountCard card; card = new BronzeCard("Ivan Dragiev", 102); card.setValueOfPurchase(250); card.getCardInfo(); card = new SilverCard("Georgi", 428); card.setValueOfPurchase(325); card.getCardInfo(); card = new GoldCard("Ivan", 850); card.setValueOfPurchase(1999); card.getCardInfo(); }
static void Main(string[] args) { var baseClient = new Client(Constants.baseClientName, Constants.baseClientAge); var bronze = new BronzeCard(baseClient, 0); PrintInfo(bronze, 150); var silver = new SilverCard(baseClient, 600); PrintInfo(silver, 850); var gold = new GoldCard(baseClient, 1500); PrintInfo(gold, 1300); }
static void Main() { //With the examples below I aim to cover all the posibilities. //Example 1 var bronzeCard = new BronzeCard("Daniel Ivanov", 0, 150); Console.WriteLine(bronzeCard.ToString()); //Example 2 var silverCard = new SilverCard("Pesho Peshev", 600, 850); Console.WriteLine(silverCard.ToString()); //Example 3 var goldCard = new GoldCard("Ivan Ivanov", 1500, 1300); Console.WriteLine(goldCard.ToString()); //Example 4 var silverCard2 = new SilverCard("Mariq Lubeva", 150, 500); Console.WriteLine(silverCard2.ToString()); //Example 5 var bronzeCard2 = new BronzeCard("Christian Dior", 150, 700); Console.WriteLine(bronzeCard2.ToString()); //Example 6 var bronzeCard3 = new BronzeCard("Petar Jordanov", 301, 600); Console.WriteLine(bronzeCard3.ToString()); //Example 7 var goldCard2 = new GoldCard("Ken Sanchez", 300, 1000); Console.WriteLine(goldCard2.ToString()); //Error Example var errorCard = new GoldCard("", -1, -1); }
public static void Main(string[] args) { Console.Write("Owner: "); string owner = Console.ReadLine(); try { Console.Write("Turnover: "); decimal turnover = decimal.Parse(Console.ReadLine() ?? throw new InvalidOperationException()); Console.Write("Purchase value: "); decimal purchaseValue = decimal.Parse(Console.ReadLine() ?? throw new InvalidOperationException()); Console.WriteLine(new string('-', 30)); Card card = new GoldCard(owner, turnover); decimal discount = card.CalculateDiscount(purchaseValue); decimal total = purchaseValue - discount; Console.WriteLine($"Purchase value: ${purchaseValue:f2}"); Console.WriteLine($"Discount rate: {card.DiscountRate:f1}%"); Console.WriteLine($"Discount: ${discount:f2}"); Console.WriteLine($"Total: ${total:f2}"); } catch (FormatException) { Console.WriteLine("Please enter the correct values!"); } catch (InvalidOperationException) { Console.WriteLine("Invalid operation! Please enter the correct values!"); } catch (IOException) { Console.WriteLine("Output exception!"); } catch (Exception) { Console.WriteLine("Something went wrong. Please contact with the admin!"); } }
static void Main(string[] args) { IPrintOutput printOutput = new PrintOutput(); try { BronzeCard bronzeCard = new BronzeCard(printOutput, 0); bronzeCard.TotalPurchase(150); } catch (RangeException ex) { Console.WriteLine(ex.Message); } try { SilverCard silverCard = new SilverCard(printOutput, 600); silverCard.TotalPurchase(850); } catch (RangeException ex) { Console.WriteLine(ex.Message); } try { GoldCard goldCard = new GoldCard(printOutput, 1500); goldCard.TotalPurchase(1300); } catch (RangeException ex) { Console.WriteLine(ex.Message); } Console.ReadLine(); }
public static void Output() { string typeOfCard = Console.ReadLine(); Card card = null; switch (typeOfCard.ToLower()) { case "bronze": card = new BronzeCard(); break; case "silver": card = new SilverCard(); break; case "gold": card = new GoldCard(); break; default: break; } if (card != null) { card.Turnover = Decimal.Parse(Console.ReadLine()); PurchaseValue = Decimal.Parse(Console.ReadLine()); decimal discountOfCurrentPurchase = PurchaseValue * card.GetDiscountRate(); decimal total = PurchaseValue - discountOfCurrentPurchase; Console.WriteLine($"Purchase value: ${String.Format("{0:0.00}", PurchaseValue)}\n" + $"Discount rate: {String.Format("{0:0.0}", card.GetDiscountRate() * 100)}%\n" + $"Discount: ${String.Format("{0:0.00}", discountOfCurrentPurchase)}\n" + $"Total: ${String.Format("{0:0.00}", total)}"); } }