Open kulpot opened 6 months ago
ClassLibrary################## ClassBoardModel ############################
################## Cell.cs ##########################################
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace ClassBoardModel { class Cell { //---------START--------- C# Chess Board 02 board cell classes ------------------------------- public int RowNumber { get; set; } public int ColumnNumber { get; set; } public bool CurrentlyOccupied { get; set; } public bool LegalNextMove { get; set; }
public Cell(int x, int y)
{
RowNumber = x;
ColumnNumber = y;
}
//---------END--------- C# Chess Board 02 board cell classes -------------------------------
}
}
################# Board.cs ########################################
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace ClassBoardModel { class Board { //---------START--------- C# Chess Board 02 board cell classes ------------------------------- // the size of the board usually 8x8 public int Size { get; set; }
// 2d array of type cell.
public Cell[,] theGrid { get; set; }
// constructor
public Board(int s)
{
// initial size of the board is defined by parameter s.
Size = s;
// create a new 2D array of type cell.
theGrid = new Cell[Size, Size];
// fill the 2D array with new Cells, each with unique x and y coordinates.
for (int i = 0; i < Size; i++)
{
for (int j = 0; j < Size; j++)
{
theGrid[i, j] = new Cell(i, j);
}
}
}
//---------END--------- C# Chess Board 02 board cell classes -------------------------------
}
}
################ Program.cs ###############################
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
//-------------------- C# Chess Board 02 board cell classes ------------------------------- //ref link:https://www.youtube.com/watch?v=SFMVyiJ2S6g&list=PLhPyEFL5u-i0YDRW6FLMd1PavZp9RcYdF&index=3
// addNewItemToSolution:class library(name:ClassBoardModel), addNewClassTo:ClassBoardModel(name:Cell.cs/Board.cs),
namespace C__Chess_Board_02 { internal class Program { static void Main(string[] args) { } } }