Continous Integration in der Praxis Gruppenarbeit
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.4 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace MiniGames.Shared.Models
  7. {
  8. public class TicTacToeBrett
  9. {
  10. int[,] Felder;
  11. public TicTacToeBrett()
  12. {
  13. Felder = new[,]
  14. {
  15. { -1, -1, -1 },
  16. { -1, -1, -1 },
  17. { -1, -1, -1 },
  18. };
  19. }
  20. public TicTacToeBrett(int[,] felder)
  21. {
  22. Felder = felder;
  23. }
  24. public bool Gleich(TicTacToeBrett anderes)
  25. {
  26. for (int i = 0; i < 3; i++)
  27. {
  28. for (int j = 0; j < 3; j++)
  29. {
  30. if (Felder[i, j] != anderes.Felder[i, j])
  31. {
  32. return false;
  33. }
  34. }
  35. }
  36. return true;
  37. }
  38. public bool Set(int pos, int wert)
  39. {
  40. int x = pos / 3;
  41. int y = pos % 3;
  42. try
  43. {
  44. if (Felder[x, y] != -1)
  45. return false;
  46. }
  47. catch (IndexOutOfRangeException e)
  48. {
  49. return false;
  50. }
  51. Felder[x, y] = wert;
  52. return true;
  53. }
  54. public bool Voll()
  55. {
  56. return false;
  57. }
  58. }
  59. }