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());
 }
示例#2
0
        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         = "กรอกจำนวนเงินไม่ถูกต้อง";
            }
        }
        /// <summary>
        /// Default constructor.
        /// </summary>
        public RoulettePlayer() : base()
        {
            // Cash/bets.
            _totalCash = Constants.InitialCashDollars;

            // Chips.
            _selectedChip           = ChipType.Undefined;
            OneChip                 = new One();
            FiveChip                = new Five();
            TwentyFiveChip          = new TwentyFive();
            OneHundredChip          = new OneHundred();
            FiveHundredChip         = new FiveHundred();
            OneThousandChip         = new OneThousand();
            FiveThousandChip        = new FiveThousand();
            TwentyFiveThousandChip  = new TwentyFiveThousand();
            OneHundredThousandChip  = new OneHundredThousand();
            FiveHundredThousandChip = new FiveHundredThousand();

            // Commands.
            ClearBetsCommand = new DelegateCommand(ClearBets).ObservesCanExecute(() => PlaceBets);
        }
示例#4
0
        /// <summary>
        /// The PlaceBet method is called to place a bet for the current selected chip.
        /// </summary>
        public void PlaceBet()
        {
            try
            {
                if (PlaceBets && SelectedChip != ChipType.Undefined)
                {
                    BetAmount = BetAmount + Chip.GetChipValue(SelectedChip);

                    // Create a chip at the bet location.
                    Chip chip = null;
                    switch (Bet.SelectedChip)
                    {
                    case ChipType.One:
                        chip = new One(Chips.Count());
                        break;

                    case ChipType.Five:
                        chip = new Five(Chips.Count());
                        break;

                    case ChipType.TwentyFive:
                        chip = new TwentyFive(Chips.Count());
                        break;

                    case ChipType.OneHundred:
                        chip = new OneHundred(Chips.Count());
                        break;

                    case ChipType.FiveHundred:
                        chip = new FiveHundred(Chips.Count());
                        break;

                    case ChipType.OneThousand:
                        chip = new OneThousand(Chips.Count());
                        break;

                    case ChipType.FiveThousand:
                        chip = new FiveThousand(Chips.Count());
                        break;

                    case ChipType.TwentyFiveThousand:
                        chip = new TwentyFiveThousand(Chips.Count());
                        break;

                    case ChipType.OneHundredThousand:
                        chip = new OneHundredThousand(Chips.Count());
                        break;

                    case ChipType.FiveHundredThousand:
                        chip = new FiveHundredThousand(Chips.Count());
                        break;
                    }

                    if (chip != null)
                    {
                        OnBetPlaced?.Invoke(chip.Value);    // Notify that the bet has been placed.
                        Chips.Add(chip);                    // Add the chip to the bet.
                        CombineChips();                     // Combine the chips.
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Bet.PlaceBet(object parameter): " + ex.ToString());
            }
        }