/// <summary> /// Ask the user for parameters and then run all the tests. /// </summary> static void Main() { Console.WriteLine("How many tests do you want to perform?"); int numberOfTests = int.Parse(Console.ReadLine()); Console.WriteLine("What's the length of the code?"); int lengthOfCode = int.Parse(Console.ReadLine()); BruteForceStrategy bruteForceStrategy = new BruteForceStrategy(numberOfTests, lengthOfCode); RunStrategy(bruteForceStrategy); ColorEliminationStrategy colorEliminationStrategy = new ColorEliminationStrategy(numberOfTests, lengthOfCode); RunStrategy(colorEliminationStrategy); HumanStrategy humanStrategy = new HumanStrategy(numberOfTests, lengthOfCode); RunStrategy(humanStrategy); CheckFourValuesFirstStrategy checkFourValuesFirstStrategy = new CheckFourValuesFirstStrategy(numberOfTests, lengthOfCode); RunStrategy(checkFourValuesFirstStrategy); Console.ReadKey(); }
public HumanStrategyTest() { var input = "1"; _configurationSetter = new Mock <IConfigurationSetter>(); _configurationSetter .Setup(x => x.Message.chooseAttackCard_3_) .Returns(""); _configurationSetter .Setup(x => x.Message.youCannotUseCard_5_) .Returns(""); _consoleRead = new Mock <IConsoleReadWrap>(); _consoleRead .Setup(x => x.ConsoleReadLine()) .Returns(input); _humanStrategy = new HumanStrategy(_configurationSetter.Object, _consoleRead.Object); CardToBeat = new Card(1, "", "", false); CardToBeatTrumpTrue = new Card(1, "", "", true); CardListOnHands = new List <Card> { new Card(1, "", "", true), new Card(2, "", "", false), new Card(8, "", "", true), new Card(9, "", "", true) }; CardListOnTable = new List <Card> { new Card(1, "", "", false), new Card(2, "", "", false), new Card(1, "", "", false), new Card(1, "", "", true) }; }
public void GetGestureFromKeyPress(char key, HandGesture expectedGesture) { var input = new MockInput(key); var strategy = new HumanStrategy(input); var actualGesture = strategy.GetGesture().Result; // Simulate a keypress Assert.AreEqual(expectedGesture, actualGesture, $@"The keypress '{key}' should generate the gesture '{expectedGesture.ToString()}'."); }
public HumanStrategyTest() { var strategyMock = new Mock <IStrategy>(); _p1 = new Player(strategyMock.Object, "p1"); _p2 = new Player(strategyMock.Object, "p2"); _p3 = new Player(strategyMock.Object, "p3"); _p4 = new Player(strategyMock.Object, "p4"); _userInterfaceMock = new Mock <IUserInterface>(); _sut = new HumanStrategy(_userInterfaceMock.Object, "pippo"); }
void Start() { HumanStrategy h1 = new HumanStrategy("Yamada", 170, 60, 20); HumanStrategy h2 = new HumanStrategy("Sato", 175, 55, 20); comparator = new AgeComparator(); resultAge = Compare(h1, h2); comparator = new HeightComparator(); resultHeight = Compare(h1, h2); print("age :" + resultAge); print("height :" + resultHeight); }
public int compare(HumanStrategy h1, HumanStrategy h2) { if (h1.height > h2.height) { return(1); } else if (h1.height == h2.height) { return(0); } else { return(-1); } }
public int compare(HumanStrategy h1, HumanStrategy h2) { if (h1.age > h2.age) { return(1); } else if (h1.age == h2.age) { return(0); } else { return(-1); } }
/// <summary> /// Ask the user to come up with a code. /// </summary> private void AskForCode() { Console.Clear(); Console.WriteLine(DynamicConsoleTexts.GetAskForCodeInformation(4, availableCharacters)); AI = new HumanStrategy(codeLength); string code = Console.ReadLine(); bool doCharactersExist = !Regex.IsMatch(code, $"[^{availableCharacters}]"); if (doCharactersExist || code.Length == codeLength) { List <string> combinations = new List <string>(); AskAI(combinations, code); } else { Console.WriteLine($"{StaticConsoleTexts.WrongCode}\n"); AskForCode(); } }
public int Compare(HumanStrategy h1, HumanStrategy h2) { return(comparator.compare(h1, h2)); }