public Player(string _name, Die[] _dice, Board _board, int _cash)
 {
     this.name = _name;
     this.dice = _dice;
     this.board = _board;
     this.cash = _cash;
     this.piece = new Piece(board.GetStartSquare(), this.name);
 }
Exemplo n.º 2
0
 public void TestDieRollRange()
 {
     Die die = new Die();
     int roll = die.roll();
     //Test that roll is between 1 & 6
     Assert.LessOrEqual(roll, 6);
     Assert.GreaterOrEqual(roll, 1);
 }
Exemplo n.º 3
0
 public void testRandomness4Fail1in6()
 {
     //Test randomness that should fail on average 1 in 6 times
     Die die = new Die();
     int numberToTest = 4;
     int roll = die.roll();
     Assert.AreNotEqual(roll, numberToTest);
     numberToTest = roll;
 }
Exemplo n.º 4
0
 public void TestDieRollOneThousandRange()
 {
     Die die = new Die();
     for (int i = 0; i < 1000; i++)
     {
         int roll = die.roll();
         Assert.LessOrEqual(roll, 6);
         Assert.GreaterOrEqual(roll, 1);
     }
 }
Exemplo n.º 5
0
        public void DieIsRandomBetweenOneAndSix()
        {
            var die = new Die();
            Boolean[] values = new Boolean[6];

            for (Int32 i = 0; i < 100; i++)
            {
                die.Roll();
                values[die.GetValue() - 1] = true;
            }

            foreach (var value in values)
            {
                Assert.IsTrue(value);
            }
        }
Exemplo n.º 6
0
        static void Main(string [] args)
        {
            int numberOfPlayers = 0;

            Console.WriteLine("                 Welcome to MONOPOLY");
            Console.WriteLine("______________________________________________________");

            Console.WriteLine("               **** Game Started ****");
            Console.WriteLine();

            Console.Write("Please enter the number of players to start the game : ");
            while (!((int.TryParse(Console.ReadLine(), out numberOfPlayers)) &&
                    ((numberOfPlayers >= 2) && (numberOfPlayers <= 8))))
            {
                Console.WriteLine("Player should between 2 and 8 !");
            }

            //creating the array of players,die array and the gameBoard that contains 40 cell
            Player[] arrayOfPlayers = new Player[numberOfPlayers];
            Die[] die = new Die[2];
            GameBoard gameBoard = new GameBoard();

            for (int i = 0; i < numberOfPlayers; i++)
            {
                arrayOfPlayers[i] = new Player(5000, "Player" + (i + 1));
                arrayOfPlayers[i].Position = gameBoard.GetCell(0);
            }

            //creating gameMaster
            GameMaster gameMaster = new GameMaster(die, gameBoard, arrayOfPlayers);

            Console.WriteLine();
            if ((args.Length > 0) && args[0].Equals("test"))
            {
                gameMaster.PlayGame("test");
            }
            else
            {
                gameMaster.PlayGame();
            }
        }
Exemplo n.º 7
0
 public void testToString()
 {
     Die die = new Die();
     //test that toString converts last roll of die same as converting result of roll to string
     int roll = die.roll();
     Assert.AreEqual(roll.ToString(), die.ToString());
 }
Exemplo n.º 8
0
 public void testRandomnessRandomOutputManyDice()
 {
     Console.WriteLine("Random Numbers: ");
     for (int i = 0; i < 1000; i++)
     {
         Die die = new Die();
         Console.WriteLine(die.roll().ToString());//outputs 1000 random numbers
     }
 }