From 1c9942b00558a3e5faa78037b1c8fb7362f37ae8 Mon Sep 17 00:00:00 2001
From: Floris <f.k.h.vandezande@students.uu.nl>
Date: Wed, 20 Nov 2024 12:18:50 +0100
Subject: [PATCH] added Draw method

---
 PuzzlePlayer/Binary.cs | 29 ++++++++++++++++++++++++++++-
 PuzzlePlayer/Board.cs  |  2 +-
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/PuzzlePlayer/Binary.cs b/PuzzlePlayer/Binary.cs
index defa72c..b0b50f7 100644
--- a/PuzzlePlayer/Binary.cs
+++ b/PuzzlePlayer/Binary.cs
@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using System.Drawing;
 using System.Runtime.CompilerServices;
 
 namespace PuzzlePlayer_Namespace
@@ -20,12 +21,38 @@ namespace PuzzlePlayer_Namespace
             // create a board with the specifide size
             boardState = new int[boardSize,boardSize];
 
-            Info = "";
+            description = "Binary puzzle is played on any even-numbered square grid, with some cells initially containing black or white circles. The goal of the puzzle is to fill all cells such that:\r\n- More than two circles of the same color cannot be adjacent\r\n- Each row and column must contain an equal number of black and white circles\r\n- Each row and column cannot appear multiple times on the board";
 
             // clear the board (fill it in with -1)
             Clear();
         }
 
+        public void Draw (Graphics gr, Point p, Size s)
+        {
+            for (int i = 0; i<boardState.GetLength(0); i++)
+            {
+                for(int j = 0; j<boardState.GetLength(1); j++)
+                {
+                    gr.DrawRectangle(Pens.Beige, p.X+i*s.Width, p.Y+j*s.Height, s.Width, s.Height);
+                    if (boardState[i,j] == 0)
+                    {
+                        gr.DrawEllipse(Pens.White,
+                            (int)(p.X+((double)i+0.25)*s.Width),
+                            (int)(p.Y+((double)j+0.25)*s.Height),
+                            s.Width/2,s.Height/2);
+                        return;
+                    }
+                    if (boardState[i, j] == 1)
+                    {
+                        gr.DrawEllipse(Pens.Black,
+                            (int)(p.X + ((double)i + 0.25) * s.Width),
+                            (int)(p.Y + ((double)j + 0.25) * s.Height),
+                            s.Width / 2, s.Height / 2);
+                    }
+                }
+            }
+        }
+
         private void Clear()
         {
             int size = boardState.GetLength(0);
diff --git a/PuzzlePlayer/Board.cs b/PuzzlePlayer/Board.cs
index d0658e1..a350641 100644
--- a/PuzzlePlayer/Board.cs
+++ b/PuzzlePlayer/Board.cs
@@ -16,7 +16,7 @@ namespace PuzzlePlayer_Namespace
     public abstract class Board
     {
         protected const int emptySpace = -1; // for every puzzle -1 represents a empty space
-        public string Info;
+        public string description;
 
         // a property for getting and setting the boardsstate. The boardstate should only be setted if the imputed int[,] is valid.
         public int[,] boardState
-- 
GitLab