Exemplo n.º 1
0
        public void FitManyRandomSizesInto5TimesBiggerCircle()
        {
            var sizes  = Thousand.Times(RandomSize).ToArray();
            var space  = sizes.Aggregate(0, (sum, size) => sum + size.Area());
            var radius = Math.Sqrt(5 * space / Math.PI);

            var rects = sizes.Select(layouter.PutNextRectangle);

            rects.SelectMany(x => x.Points())
            .Select(x => x.DistanceTo(center))
            .All(x => x < radius)
            .Should().BeTrue();
        }
Exemplo n.º 2
0
        public void FitManySameSizesInto2TimesBiggerCircle()
        {
            var size   = new Size(24, 120);
            var space  = size.Area() * Thousand;
            var radius = Math.Sqrt(2 * space / Math.PI);

            var rects = Thousand.Times(() => layouter.PutNextRectangle(size));

            rects.SelectMany(x => x.Points())
            .Select(x => x.DistanceTo(center))
            .All(x => x < radius)
            .Should().BeTrue();
        }
Exemplo n.º 3
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         = "กรอกจำนวนเงินไม่ถูกต้อง";
            }
        }
Exemplo n.º 4
0
        //Main starts here
        //
        //**************************************************************************
        static void Main(string[] args)
        {
            Thousand yeah = new Thousand();
            int      test;

            Console.WriteLine("Please enter the amount of hours per week you plan on practicing.");
            //Input Validation to prevent any non Int or negative values from being entered
            while (!int.TryParse(Console.ReadLine(), out test))
            {
                Console.WriteLine("Invalid Input. Please enter a positive whole number.");
            }
            while (test < 0)
            {
                Console.WriteLine("Invalid Input. Please enter a positive whole number.");
                while (!int.TryParse(Console.ReadLine(), out test))
                {
                    Console.WriteLine("Invalid Input. Please enter a positive whole number.");
                }
            }

            yeah.calculateWeeks(test);
            yeah.tenThousandTimes(yeah.weeks);


            //Console.WriteLine(yeah.weeks);
            //Console.WriteLine(yeah.days);
            //Console.WriteLine(yeah.months);
            //Console.WriteLine(yeah.years);

            //DateTime is used to get the exact date when the program is run
            //The class variables are then used to add the time to the current date.
            //Variables are typecasted to integers in order for it to work
            DateTime now    = DateTime.UtcNow.Date;
            DateTime days   = now.AddDays((int)yeah.days);
            DateTime months = days.AddMonths((int)yeah.months);
            DateTime later  = months.AddYears((int)yeah.years);

            yeah.printResults();


            Console.Write("\nCurrent Date is : ");
            Console.WriteLine(now.ToString("MM/dd/yyyy"));
            Console.Write("You will reach your Ten Thousand Hours on : ");
            Console.WriteLine(later.ToString("MM/dd/yyyy"));
            Console.ReadLine();
        }