本文整理匯總了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);
}
示例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);
}