Browse Source

Refactored TicTacToeBrett.Gleich und TicTacToeBrett.Voll

feature/tictactoe
Felix Detig 3 years ago
parent
commit
3944a6cfb1
  1. 23
      BlazorSolution/MiniGames/Shared/Models/TicTacToeBrett.cs

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

@ -8,6 +8,11 @@ namespace MiniGames.Shared.Models
int[,] Felder; int[,] Felder;
public int Groesse
{
get { return Felder.GetLength(0) * Felder.GetLength(1); }
}
public TicTacToeBrett() public TicTacToeBrett()
{ {
Felder = new[,] Felder = new[,]
@ -45,14 +50,11 @@ namespace MiniGames.Shared.Models
public bool Gleich(TicTacToeBrett anderes) public bool Gleich(TicTacToeBrett anderes)
{ {
for (int i = 0; i < 3; i++)
for (int i = 0; i < Groesse; i++)
{ {
for (int j = 0; j < 3; j++)
if (Get(i) != anderes.Get(i))
{ {
if (Felder[i, j] != anderes.Felder[i, j])
{
return false;
}
return false;
} }
} }
@ -90,14 +92,11 @@ namespace MiniGames.Shared.Models
public bool Voll() public bool Voll()
{ {
for (int i = 0; i < 3; i++)
for (int i = 0; i < Groesse; i++)
{ {
for (int j = 0; j < 3; j++)
if (Get(i) == LEER)
{ {
if (Felder[i, j] == LEER)
{
return false;
}
return false;
} }
} }

Loading…
Cancel
Save