Browse Source

Konstante TicTacToeBrett.LEER als Wert für leere Felder angelegt

feature/tictactoe
Felix Detig 3 years ago
parent
commit
f6680a70ee
  1. 12
      BlazorSolution/MiniGames/Shared/Models/TicTacToeBrett.cs
  2. 14
      BlazorSolution/MiniGamesTests/TicTacToeBrettTest.cs

12
BlazorSolution/MiniGames/Shared/Models/TicTacToeBrett.cs

@ -8,15 +8,17 @@ namespace MiniGames.Shared.Models
{
public class TicTacToeBrett
{
public const int LEER = -1;
int[,] Felder;
public TicTacToeBrett()
{
Felder = new[,]
{
{ -1, -1, -1 },
{ -1, -1, -1 },
{ -1, -1, -1 },
{ LEER, LEER, LEER },
{ LEER, LEER, LEER },
{ LEER, LEER, LEER },
};
}
@ -48,7 +50,7 @@ namespace MiniGames.Shared.Models
try
{
if (Felder[x, y] != -1)
if (Felder[x, y] != LEER)
return false;
}
catch (IndexOutOfRangeException e)
@ -67,7 +69,7 @@ namespace MiniGames.Shared.Models
{
for (int j = 0; j < 3; j++)
{
if (Felder[i, j] == -1)
if (Felder[i, j] == LEER)
{
return false;
}

14
BlazorSolution/MiniGamesTests/TicTacToeBrettTest.cs

@ -6,9 +6,9 @@ namespace MiniGamesTests
public class TicTacToeBrettTest
{
public TicTacToeBrett TestBrett(
int a = -1, int b = -1, int c = -1,
int d = -1, int e = -1, int f = -1,
int g = -1, int h = -1, int i = -1
int a = TicTacToeBrett.LEER, int b = TicTacToeBrett.LEER, int c = TicTacToeBrett.LEER,
int d = TicTacToeBrett.LEER, int e = TicTacToeBrett.LEER, int f = TicTacToeBrett.LEER,
int g = TicTacToeBrett.LEER, int h = TicTacToeBrett.LEER, int i = TicTacToeBrett.LEER
)
{
return new(
@ -26,7 +26,13 @@ namespace MiniGamesTests
{
// arrange
TicTacToeBrett brett = new();
TicTacToeBrett erwartetesBrett = TestBrett(-1, -1, -1, -1, 0);
TicTacToeBrett erwartetesBrett = TestBrett(
TicTacToeBrett.LEER,
TicTacToeBrett.LEER,
TicTacToeBrett.LEER,
TicTacToeBrett.LEER,
0
);
int pos = 4;
int wert = 0;
bool erwartetGesetzt = true;

Loading…
Cancel
Save