public static string ToRoman(this int value) { return(Evaluator.Assert(value) .Also((n) => OneThousand.Evaluate(n)) .Also((n) => FiveHundred.Evaluate(n)) .Also((n) => OneHundred.Evaluate(n)) .Also((n) => Fifty.Evaluate(n)) .Also((n) => Ten.Evaluate(n)) .Also((n) => Five.Evaluate(n)) .Also((n) => One.Evaluate(n)) .Resolve()); }
private void Calculate_Click(object sender, RoutedEventArgs e) { var IsValidatePrice = Double.TryParse(InputPrice.Text, out var price); var IsValidateCustomerPay = Double.TryParse(InputCustomerPay.Text, out var customerPay); var change = sut.ComputeChange(price, customerPay); var result = sut.GetChangeBankNotesAndCoins(change); result.BankNotesAndCoins.TryGetValue(BankNotesAndCoinsInSatang.Thousand, out var Thousand); result.BankNotesAndCoins.TryGetValue(BankNotesAndCoinsInSatang.FiveHundreds, out var FiveHundred); result.BankNotesAndCoins.TryGetValue(BankNotesAndCoinsInSatang.Hundred, out var Hundred); result.BankNotesAndCoins.TryGetValue(BankNotesAndCoinsInSatang.Fifty, out var Fifty); result.BankNotesAndCoins.TryGetValue(BankNotesAndCoinsInSatang.Twenty, out var Twenty); result.BankNotesAndCoins.TryGetValue(BankNotesAndCoinsInSatang.Ten, out var Ten); result.BankNotesAndCoins.TryGetValue(BankNotesAndCoinsInSatang.Five, out var Five); result.BankNotesAndCoins.TryGetValue(BankNotesAndCoinsInSatang.One, out var One); result.BankNotesAndCoins.TryGetValue(BankNotesAndCoinsInSatang.TwentyFifth, out var TwentyFiveStang); result.BankNotesAndCoins.TryGetValue(BankNotesAndCoinsInSatang.Fiftieth, out var FiftyStang); if (IsValidatePrice && IsValidateCustomerPay && price >= 0 && customerPay >= 0 && customerPay >= price) { MoneyChangeResult.Text = result.RoundedChange.ToString(); countThousand.Text = Thousand.ToString(); countFiveHundred.Text = FiveHundred.ToString(); countHundred.Text = Hundred.ToString(); countFifty.Text = Fifty.ToString(); countTwenty.Text = Twenty.ToString(); countTen.Text = Ten.ToString(); countFive.Text = Five.ToString(); countOne.Text = One.ToString(); countTwentyFiveStang.Text = TwentyFiveStang.ToString(); countFiftyStang.Text = FiftyStang.ToString(); StatusChange.Text = "จ่ายเงินเรียบร้อย"; } else { MoneyChangeResult.Text = ""; countThousand.Text = ""; countFiveHundred.Text = ""; countHundred.Text = ""; countFifty.Text = ""; countTwenty.Text = ""; countTen.Text = ""; countFive.Text = ""; countOne.Text = ""; countTwentyFiveStang.Text = ""; countFiftyStang.Text = ""; StatusChange.Text = ""; StatusChange.Text = "กรอกจำนวนเงินไม่ถูกต้อง"; } }
public void GetPercentageDifference() { // Arrange const double OneHundred = 100.0; const double Fifty = 50.0; // Act var result1 = OneHundred.GetPercentageDifference(44.4); var result2 = OneHundred.GetPercentageDifference(55.5); var result3 = OneHundred.GetPercentageDifference(50.0); var result4 = Fifty.GetPercentageDifference(50.0); // Assert Assert.AreEqual(44.4, result1); Assert.AreEqual(55.500000000000007, result2); Assert.AreEqual(50.0, result3); Assert.AreEqual(100.0, result4); }
public static void SaveRoms(string path) { using (FileStream file = new FileStream(path, FileMode.Open)) { using (ZipArchive archive = new ZipArchive(file, ZipArchiveMode.Update)) { var simm = ArchiveType(archive); var buffer = new byte[0x800000]; Ten.Save(archive, simm, buffer); Twenty.Save(archive, simm, buffer); Thirty.Save(archive, simm); ThirtyOne.Save(archive, simm); Forty.Save(archive, simm); FortyOne.Save(archive, simm); Fifty.Save(archive, simm); FiftyOne.Save(archive, simm); } } }
static void Uri1018(string[] args) { int N; int Change; int Hundred, Fifty, Twenty, Ten, Five, Two, One; N = int.Parse(Console.ReadLine()); Change = N; Hundred = Change / 100; Change = Change - (Hundred * 100); Fifty = Change / 50; Change = Change - (Fifty * 50); Twenty = Change / 20; Change = Change - (Twenty * 20); Ten = Change / 10; Change = Change - (Ten * 10); Five = Change / 5; Change = Change - (Five * 5); Two = Change / 2; Change = Change - (Two * 2); One = Change / 1; Change = Change - (One * 1); Console.WriteLine(N.ToString()); Console.WriteLine(Hundred.ToString() + " nota (s) de R$ 100,00"); Console.WriteLine(Fifty.ToString() + " nota (s) de R$ 50,00"); Console.WriteLine(Twenty.ToString() + " nota (s) de R$ 20,00"); Console.WriteLine(Ten.ToString() + " nota (s) de R$ 10,00"); Console.WriteLine(Five.ToString() + " nota (s) de R$ 5,00"); Console.WriteLine(Two.ToString() + " nota (s) de R$ 2,00"); Console.WriteLine(One.ToString() + " nota (s) de R$ 1,00"); }
/// <summary> /// Gives me money. /// </summary> /// <param name="money">The money.</param> public static void GiveMeMoney(int money) { // Setup entities Cash hundred = new Hundred(); Cash fifty = new Fifty(); Cash twenty = new Twenty(); Cash ten = new Ten(); Cash five = new Five(); // Setup Chain of Responsibility hundred.SetSuccessor(fifty); fifty.SetSuccessor(twenty); twenty.SetSuccessor(ten); ten.SetSuccessor(five); // Generate and process ATM requests int moneyInBank = 1000; var bank = new Bank(moneyInBank / 100, moneyInBank / 50, moneyInBank / 20, moneyInBank / 10, moneyInBank / 5); // hundred.ProcessRequest(money, bank); // Testing multiple requests for (int i = 1; i < 150; i++) { // Request #i Console.WriteLine("Request #{0}\n", i); Console.WriteLine("Amount requested: {0}€", money); Console.WriteLine("Amount available: {0}€\n", bank.GetTotal()); hundred.ProcessRequest(money, bank); Console.WriteLine("\nEnd Of Request #{0}\n-----------------\n", i); var randomNumber = new Random().Next(5, 200); money = ((int)(randomNumber / 5)) * 5; } // Wait for user Console.ReadKey(); }
public void FiftyCodeTest() { Fifty fifty = new Fifty(); Assert.AreEqual(fifty.Code, "$50"); }