adding doxygen comments for the Boards and Tiles packages + changing the AddTileInBag test
continuous-integration/drone/push Build is passing Details

test_old_branch
rportet 11 months ago
parent e49de30ac8
commit bd7d748c7d

@ -9,14 +9,23 @@ using QwirkleClassLibrary.Tiles;
namespace QwirkleClassLibrary.Boards
{
/// <summary>
/// This class is used to create the board for our Qwirkle Game. It uses others classes, such as Cell and Tile, to take care of the tiles placements during the game.
/// </summary>
public class Board
{
public ReadOnlyCollection<Cell> ReadCells => cells.AsReadOnly();
private readonly List<Cell> cells = new();
public int Rows { get; }
public int Columns { get; }
/// <summary>
/// This is the constructor for the board. The parameters 'rows' and 'cols' are used to calculate the size of the board.
/// </summary>
/// <param name="rows">The numbers of rows in the board.</param>
/// <param name="cols">The number of columns in the board.</param>
public Board(int rows, int cols)
{
Rows = rows;
@ -32,6 +41,10 @@ namespace QwirkleClassLibrary.Boards
}
}
/// <summary>
/// This method is used to check if a cell in the board whether it already contains a tile or not.
/// </summary>
/// <returns>Returns a boolean : true if the cell doesn't contain any tile, false if it already contains a tile.</returns>
public bool HasOccupiedCase()
{
foreach (var cell in cells)
@ -44,6 +57,13 @@ namespace QwirkleClassLibrary.Boards
return false;
}
/// <summary>
/// This method is used to add a tile specified by the player, to the coordinates x, y of the board, also provided by the player.
/// </summary>
/// <param name="x">The position of the tile in the x-axis of the board.</param>
/// <param name="y">The position of the tile in the y-axis of the board.</param>
/// <param name="tile">The tile the player want to place in the board.</param>
/// <returns></returns>
public bool AddTileInCell(int x, int y, Tile tile)
{
foreach (var t in cells)
@ -58,16 +78,30 @@ namespace QwirkleClassLibrary.Boards
return false;
}
/// <summary>
/// A getter for the cells attribute of the Board Class.
/// </summary>
/// <returns>The cells of the board in a List format.</returns>
public List<Cell> GetCells()
{
return cells;
}
/// <summary>
/// A getter for the ReadCells attribute of the Board Class.
/// </summary>
/// <returns>The cells of the board, but in a IReadOnlyCollection format.</returns>
public IReadOnlyCollection<Cell> GetReadCells()
{
return ReadCells;
}
/// <summary>
/// A getter for the cell in the coordinates x, y of the board.
/// </summary>
/// <param name="x">The position of the cell in the x-axis of the board.</param>
/// <param name="y">The position of the cell in the y-axis of the board.</param>
/// <returns></returns>
public Cell? GetCell(int x, int y)
{
foreach (var t in cells)

@ -10,6 +10,12 @@ public class Cell
private readonly int y;
private Tile? tile = null;
/// <summary>
/// This is the constructor for a Cell.
/// </summary>
/// <param name="x">The x attribute of the cell.</param>
/// <param name="y">The y attribute of the cell.</param>
/// <exception cref="ArgumentException">Throw an exception if the x or y attribute is negative.</exception>
public Cell(int x, int y)
{
if (x < 0 || y < 0)
@ -21,26 +27,47 @@ public class Cell
this.y = y;
}
/// <summary>
/// A getter for the position of the cell on the x-axis.
/// </summary>
/// <returns>The position of the cell on the x-axis.</returns>
public int GetX
{
get { return x; }
}
/// <summary>
/// A getter for the position of the cell on the y-axis.
/// </summary>
/// <returns>The position of the cell on the y-axis.</returns>
public int GetY
{
get { return y; }
}
/// <summary>
/// Check if the Cell whether is empty or contains a tile.
/// </summary>
/// <returns>True if the cell is empty, false if the cell contains a tile.</returns>
public bool IsFree
{
get { return tile == null; }
}
/// <summary>
/// A getter for the tile in the cell.
/// </summary>
/// <returns>The tile if the cell isn't empty, null otherwise.</returns>
public Tile? GetTile
{
get { return tile; }
}
/// <summary>
/// A setter for the tile in the cell.
/// </summary>
/// <param name="addedTile">The tile the player want to add in the cell.</param>
/// <returns>True if added succefully (if the cell didn't already contain a tile), false if there already was a tile in this cell.</returns>
public bool SetTile(Tile addedTile)
{
if (tile == null)

@ -6,6 +6,9 @@ using System.Threading.Tasks;
namespace QwirkleClassLibrary.Tiles
{
/// <summary>
/// This is the constructor for the Color Enum : it is used to set the colors avaible for the tiles.
/// </summary>
public enum Color
{
Red,

@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace QwirkleClassLibrary.Tiles
{
/// <summary>
/// Enum is used to have a finished number of shapes for the tiles.
/// This is the constructor for the Shape Enum : it is used to set the shapes avaible for the tiles.
/// </summary>
public enum Shape
{

@ -12,27 +12,48 @@ namespace QwirkleClassLibrary.Tiles
private readonly Shape shape;
private readonly Color color;
/// <summary>
/// This is the constructor for a Tile.
/// </summary>
/// <param name="sh">The shape of the tile.</param>
/// <param name="co">The color of the tile.</param>
public Tile(Shape sh, Color co)
{
shape = sh;
color = co;
}
/// <summary>
/// This method is used to return the color and the shape into a string.
/// </summary>
/// <returns>A string with the color and the shape of the tile.</returns>
public string NameColorTile()
{
return color.ToString() + shape.ToString();
}
/// <summary>
/// A getter for the shape of the Tile.
/// </summary>
/// <returns>The shape attribute of the Tile.</returns>
public Shape GetShape
{
get { return shape; }
}
/// <summary>
/// A getter for the color of the Tile.
/// </summary>
/// <returns>The color attribute of the Tile.</returns>
public Color GetColor
{
get { return color; }
}
/// <summary>
/// This method is used to override the ToString() method. It is simply a tool to facilitate the development.
/// </summary>
/// <returns>The color and the shape of the tile, spaced, in a string format.</returns>
public override string ToString()
{
return color.ToString() + " " + shape.ToString();

@ -12,6 +12,11 @@ namespace QwirkleClassLibrary.Tiles
public ReadOnlyCollection<Tile> TilesBag { get; private set; }
private readonly List<Tile> tiles = new List<Tile>();
/// <summary>
/// This is the constructor for the TileBag. It will create a tile of each of the possibilities among the Color and Shape Enums.
/// </summary>
/// <param name="nbSet">This parameter is used to indicate the number of copies we want to create.</param>
/// <exception cref="ArgumentException">Throw an exception if the number of copies is negative (impossible) or superior to 3 (contradiction with the rules).</exception>
public TileBag(int nbSet)
{
if (nbSet < 0 || nbSet > 3)
@ -34,12 +39,20 @@ namespace QwirkleClassLibrary.Tiles
TilesBag = tiles.AsReadOnly();
}
public bool AddTileInBag(Tile tile)
/// <summary>
/// This method is used to add a tile in the tile bag.
/// </summary>
/// <param name="tile">The tile we want to add in the bag.</param>
public void AddTileInBag(Tile tile)
{
tiles.Add(tile);
return true;
}
/// <summary>
/// Remove a tile in the tile bag.
/// </summary>
/// <param name="tile">The tile you want to remove from the bag.</param>
/// <returns>True if the remove was successfull, false if it failed.</returns>
public bool RemoveTileInBag(Tile tile)
{
for (int i = 0; i < tiles.Count; i++)

@ -19,13 +19,6 @@ public class TestTileBag
Assert.Equal(bag.TilesBag.Count, nbset * 36);
}
[Fact]
public void Test_AddTileInBag()
{
Tile tok = new(Shape.Club, Color.Green);
TileBag bag = new TileBag(2);
Assert.True(bag.AddTileInBag(tok));
}
[Theory]
[InlineData(true)]

Loading…
Cancel
Save