本文整理汇总了C#中AI.FindSequenceFaceValues方法的典型用法代码示例。如果您正苦于以下问题:C# AI.FindSequenceFaceValues方法的具体用法?C# AI.FindSequenceFaceValues怎么用?C# AI.FindSequenceFaceValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AI
的用法示例。
在下文中一共展示了AI.FindSequenceFaceValues方法的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);
}