Skip to content
Snippets Groups Projects
Commit b288c76a authored by DamianKomdeur's avatar DamianKomdeur
Browse files

Bug fixes

parent 1d50d95e
No related branches found
No related tags found
No related merge requests found
......@@ -26,7 +26,7 @@ namespace PuzzlePlayer_Namespace
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();
//Clear(false);
}
public override void Draw (Graphics gr, Rectangle r) //draws board in rectangle R. warning: will stretch image unless FitBoard() is used for rectangle size
......
......@@ -51,7 +51,7 @@ namespace PuzzlePlayer_Namespace
{
int[,] copy = boardState;
boardState = newState;
if (IsBoardValid(newState) && Solve() == SOLUTIONS.UNIQUE)
if (IsBoardValid(newState) && Solve(false) == SOLUTIONS.UNIQUE)
return true;
else
{
......@@ -115,7 +115,7 @@ namespace PuzzlePlayer_Namespace
public abstract void Generate();
// abstract methode for checking if a imputed boardstate is valid
public abstract bool IsBoardValid(int[,] boardToCheck);
public virtual bool IsBoardValid(int[,] boardToCheck) { return true; }
// changes tile P to value X
public abstract void TileInput(Point p, int x);
......
......@@ -21,6 +21,7 @@ namespace PuzzlePlayer_Namespace
private readonly BufferedGraphics bufferedGraphics;
private Board board;
public Board Board //updating the Board member will immediately call board.Draw method so that the board is updated visually
{
get { return board; }
set
......@@ -31,6 +32,13 @@ namespace PuzzlePlayer_Namespace
}
private readonly Button UPDATEBUTTON;
public string puzzleType { get; }
public PuzzleForm(Board b)
{
board = b;
puzzleType = b.GetType().Name;
}
public PuzzleForm(Board b, Size s = default) //takes Board and Size parameter and sets up the PuzzleForm window.
{
if (s == default) s = new Size(700, 420);
......@@ -104,7 +112,6 @@ namespace PuzzlePlayer_Namespace
hintbutton.Text = "Hint";
hintbutton.MouseClick += (object sender, MouseEventArgs mea) =>
{
board.Draw(graphics, boardP, boardS);
MessageBox.Show("Hint: geef op");
Board = Board;
};
......@@ -112,7 +119,7 @@ namespace PuzzlePlayer_Namespace
solvebutton.Text = "Solve";
solvebutton.MouseClick += (object sender, MouseEventArgs mea) =>
{
Board.Solve();
Board.Solve(false);
Board = Board;
};
......
......@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
using static System.Windows.Forms.DataFormats;
namespace PuzzlePlayer_Namespace
{
......@@ -11,7 +10,7 @@ namespace PuzzlePlayer_Namespace
{
internal static void Main(string[] args)
{
Application.Run(new MainForm());
Application.Run(new PuzzleForm(new Binary()));
}
}
......@@ -29,9 +28,9 @@ namespace PuzzlePlayer_Namespace
{
for (int i = 0; i < 5; i++)
{
puzzleForms.Add(new PuzzleForm(new Binair()));
puzzleForms.Add(new PuzzleForm(new Binary()));
}
puzzleForms.Add(new PuzzleForm(new Binair()));
puzzleForms.Add(new PuzzleForm(new Binary()));
}
private void SetUpUI()
......
File moved
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