public void NextDayTest1() { uint gameSize = 10; Game gameTest = new Game(gameSize); Cell[] cells = new Cell[gameSize * gameSize]; //Make all cells zombies for (uint column = 0; column < gameSize; column++) { for (uint row = 0; row < gameSize; row++) { uint index = column * gameSize + row; cells[index].Column = column; cells[index].Row = row; cells[index].Status = null; } } gameTest.ModifyCell(cells); gameTest.NextDay(); //All cells are zombies, so the next day will be with just as many zombies... for (uint column = 0; column < gameSize; column++) { for (uint row = 0; row < gameSize; row++) { Assert.AreEqual(gameTest[column,row], null); } } }
public void NextDayTest2() { uint gameSize = 10; Game gameTest = new Game(gameSize); Cell[] cells = new Cell[gameSize * gameSize]; //Set all the cells to be alive and happy for (uint column = 0; column < gameSize; column++) { for (uint row = 0; row < gameSize; row++) { uint index = column * gameSize + row; cells[index].Column = column; cells[index].Row = row; cells[index].Status = 1; } } gameTest.ModifyCell(cells); gameTest.NextDay(); //Now all cells (except those in the 4 corners) will be dead. The last 4 will still be alive for (uint column = 0; column < gameSize; column++) { for (uint row = 0; row < gameSize; row++) { if ((column == 0 && row == 0) || (column == gameSize - 1 && row == 0) || (column == 0 && row == gameSize - 1) || (column == gameSize - 1 && row == gameSize - 1)) { Assert.AreEqual(gameTest[column, row], 1); } else { Assert.AreEqual(gameTest[column, row], 0); } } } }
/// <summary> /// A method to keep track of each individual game the user wants to play /// </summary> private void StartUpGame() { bool playNewGame = true; do { uint size = AskUserForSizeOfGame(MAX_SIZE_OF_GAME); _game = new Game(size); AskUserForModifyCell(size * size); bool continueCurrentGame = true; uint day = 1; do { PrintState(day++); char key = AskUserForNextAction(); //Any keystroke, except for q, will show the next day of the game if (key != 'q') _game.NextDay(); else continueCurrentGame = false; } while (continueCurrentGame); playNewGame = WantsToPlayANewGame(); } while (playNewGame); }