namespace Models.Game
{
///
/// The Cell class represents a cell in the application.
///
public class Cell : Position, IEquatable
{
///
/// The value of the cell.
///
private int? _value;
public int? Value {
get => _value;
set
{
if (value < 0)
{
throw new Exception("La valeur doit être supérieure à 0");
}
this._value = value;
}
}
///
/// The fact that the cell is dangerous or not.
///
public bool IsDangerous { get; set; }
public bool Valid { get; set; }
///
/// Atribute to know if the cell is a penalty cell.
///
private bool Penalty { get; set; }
///
/// Constructor of the Cell class.
///
/// the x position
/// the y position
/// if the cell is a dangerous cell or not
public Cell(int x, int y,bool isDangerous = false):base(x,y)
{
IsDangerous = isDangerous;
Penalty = false;
Valid = false;
}
///
/// Function in order to return the fact that the cell is dangerous or not.
///
/// If the cell is dangerous or not
public bool GetCellType() => IsDangerous;
///
/// Redefine the equal operation between cells.
///
/// The object to compare with the current cell.
/// true if the specified object is equal to the current cell; otherwise, false.
public bool Equals(Cell? other)
{
if (other == null) return false;
if (this.X == other.X && this.Y == other.Y) return true;
return false;
}
}
} |