Example #1
0
		private string DisplayLoss(Choice choiceOne, Choice choiceTwo)
		{
			string output;
			Rules rule = new Rules(choiceTwo, choiceOne);
			output = rule.DisplayWinner();
			return output + "\nPlayer 2 wins!";
		}
Example #2
0
        public void PaperPlayerTest(Choice choice, Result expected)
        {
            //Arrange
            AlwaysPaperPlayer p1 = new AlwaysPaperPlayer("Paper Player");
            Player p2;

            switch (choice)
            {
                case Choice.Rock:
                    p2 = new AlwaysRockPlayer("Rock Player");
                    break;
                case Choice.Scissors:
                    p2 = new AlwaysScissorPlayer("Scissors Player");
                    break;
                default:
                    p2 = new AlwaysPaperPlayer("Paper Player");
                    break;
             }

            //Act
            Result actual = _game.PlayRound(p1, p2);

            //Assert
            Assert.AreEqual(expected, actual);
        }
Example #3
0
		private string DetermineWinnerHelper(Choice choiceOne, Choice choiceTwo)
		{
			int indexOne = (int) choiceOne.Name;
			int indexTwo = (int) choiceTwo.Name;
			int result = (indexOne - indexTwo + 5) % 5;
		    Console.WriteLine();
			if (result  == 1 || result == 2)
			{
				return DisplayWin(choiceOne, choiceTwo);
			}
			else if (result == 0)
			{
				return DisplayTie(choiceOne, choiceTwo);
			}
			else
			{
				return DisplayLoss(choiceOne, choiceTwo);
			}

		}
        public void TestPaperMethod(Choice choice, Result expected)
        {
            MatchResult result = null;
            Game testGame = new Game();

            switch (choice)
            {
                case Choice.Paper:
                result = testGame.PlayRound(new AlwaysPaper(), new AlwaysPaper());
                    break;
                case Choice.Rock:
                    result = testGame.PlayRound(new AlwaysPaper(), new AlwaysRock());
                    break;
                default:
                    result = testGame.PlayRound(new AlwaysPaper(), new AlwaysScissors());
                    break;
            }

            Assert.AreEqual(expected, result.Match_Result);
        }
Example #5
0
		public Player(string name, Items.Item choice)
		{
			this.name = name;
			switch (choice)
			{
				case Items.Item.Rock:
					this.choice = new Rock();
					break;
				case Items.Item.Paper:
					this.choice = new Paper();
					break;
				case Items.Item.Scissors:
					this.choice = new Scissors();
					break;
				case Items.Item.Lizard:
					this.choice = new Lizard();
					break;
				case Items.Item.Spock:
					this.choice = new Spock();
					break;
			}

		}
Example #6
0
		public Rules(Choice choiceOne, Choice choiceTwo)
		{
			this.choiceOne = choiceOne;
			this.choiceTwo = choiceTwo;
		}
Example #7
0
		private string DisplayTie(Choice choiceOne, Choice choiceTwo)
		{	
			string output = $"{choiceOne.Name} ties {choiceTwo.Name}";
			return output + "\nMeh. Its a tie.";
		}
Example #8
0
		public string DetermineWinningChoice(Choice choice)
		{
			return DetermineWinnerHelper(this, choice);
		}