From 6197ce9640f7c969063cb1ee18a3a707834a8e76 Mon Sep 17 00:00:00 2001 From: Felix Detig Date: Mon, 14 Feb 2022 02:55:52 +0100 Subject: [PATCH] =?UTF-8?q?TicTacToeBrett-Konstruktor=20erzeugt=20eigenes?= =?UTF-8?q?=20Array=20mit=20richtiger=20Gr=C3=B6=C3=9Fe=20und=20kopiert=20?= =?UTF-8?q?Werte=20des=20Parameters?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MiniGames/Shared/Models/TicTacToeBrett.cs | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/BlazorSolution/MiniGames/Shared/Models/TicTacToeBrett.cs b/BlazorSolution/MiniGames/Shared/Models/TicTacToeBrett.cs index d924368..8f2ab97 100644 --- a/BlazorSolution/MiniGames/Shared/Models/TicTacToeBrett.cs +++ b/BlazorSolution/MiniGames/Shared/Models/TicTacToeBrett.cs @@ -22,9 +22,29 @@ namespace MiniGames.Shared.Models }; } - public TicTacToeBrett(int[,] felder) + public TicTacToeBrett(int[,] werte) { - Felder = felder; + Felder = new int[3, 3]; + + if (werte == null) + { + werte = new int[0, 0]; + } + + for (int i = 0; i < Felder.GetLength(0); i++) + { + for (int j = 0; j < Felder.GetLength(1); j++) + { + if (i < werte.GetLength(0) && j < werte.GetLength(1)) + { + Felder[i, j] = werte[i, j]; + } + else + { + Felder[i, j] = LEER; + } + } + } } public bool Gleich(TicTacToeBrett anderes)