Skip to content
Snippets Groups Projects
Commit 1c9942b0 authored by Floris's avatar Floris
Browse files

added Draw method

parent c32dc198
No related branches found
No related tags found
No related merge requests found
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);
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment