當前位置: 首頁>>代碼示例>>C#>>正文


C# AI.DefineMaxCountFaceValues方法代碼示例

本文整理匯總了C#中AI.DefineMaxCountFaceValues方法的典型用法代碼示例。如果您正苦於以下問題:C# AI.DefineMaxCountFaceValues方法的具體用法?C# AI.DefineMaxCountFaceValues怎麽用?C# AI.DefineMaxCountFaceValues使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在AI的用法示例。


在下文中一共展示了AI.DefineMaxCountFaceValues方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: TestThird

        public void TestThird()
        {
            var ai = new AI(new Settings(57, new List<int> { 1, 5, 10, 50 }));

            Assert.AreEqual(3, ai.DefineMaxCountFaceValues());
            var actual = new List<int>();
            foreach (var faceValue in ai.FindSequenceFaceValues(3))
            {
                for (var i = 0; i < faceValue.Amount; i++)
                {
                    actual.Add(faceValue.Value);
                }
            }
            CollectionAssert.AreEqual(new[] { 1, 1, 5, 50 }, actual);
        }
開發者ID:spbsmile,項目名稱:ATMSimulator,代碼行數:15,代碼來源:Tests.cs

示例2: Main

        public static void Main()
        {
            ConsoleKeyInfo readKey;
            do
            {
                Console.Title = "ATM Simulator";
                Console.WriteLine("Please enter face values for money.");
                var input = Console.ReadLine();
                var values = input.Split(' ');

                var faceValues = new List<int>();
                foreach (var valueStr in values.Where(value => !string.IsNullOrEmpty(value)))
                {
                    int value;
                    if (int.TryParse(valueStr, out value))
                    {
                        faceValues.Add(Convert.ToInt32(valueStr));
                    }
                    else
                    {
                        Console.WriteLine("No valid");
                        Main();
                    }
                }
                faceValues.Sort();

                Console.WriteLine("If your wish get money press enter");
                Console.ReadKey();

                Console.WriteLine("Insert your cash: ");

                int cash;
                while (!int.TryParse(Console.ReadLine(), out cash))
                {
                    Console.WriteLine("Please enter a valid number for cash.");
                    Console.WriteLine("Insert your cash: ");
                }

                var ai = new AI(new Settings(cash, faceValues));
                var countRequiredFaceValues = ai.DefineMaxCountFaceValues();
                Console.WriteLine("Max count of Face Values: " + countRequiredFaceValues);

                Console.WriteLine("Best use face value");
                foreach (var faceValue in ai.FindSequenceFaceValues(countRequiredFaceValues))
                {
                    Console.WriteLine(faceValue.Value + " x " +
                                      faceValue.Amount);
                }

                bool check;
                do
                {
                    Console.Write("\nYou wish to get money again? (yes/no) ");
                    readKey = Console.ReadKey(true);
                    check = !((readKey.Key == ConsoleKey.Y) || (readKey.Key == ConsoleKey.N));
                } while (check);
                switch (readKey.Key)
                {
                    case ConsoleKey.Y: Console.WriteLine("Yes"); break;
                    case ConsoleKey.N: Console.WriteLine("No"); break;
                }
            } while (readKey.Key != ConsoleKey.N);
        }
開發者ID:spbsmile,項目名稱:ATMSimulator,代碼行數:63,代碼來源:Program.cs


注:本文中的AI.DefineMaxCountFaceValues方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。