Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

#ifndef CELL_H

#define CELL_H
#include <iomanip>

namespace Tetris
{

/**
* @brief Represents a cell in the Tetris game board.
*/
class Cell
{

friend class Board; // Declare Board as a friend class

public:
/**
* @brief Default constructor.
*/
Cell(const Cell&) = delete;
/**
* @brief Constructs an unoccupied Cell object.
*/
Cell() : CurrentBrickCell(false), OccupiedCell(false) {}
/**
* @brief Checks if the cell is occupied.
* @return True if the cell is occupied, false otherwise.
*/
inline bool isOccupiedCell() const {return OccupiedCell;}
/**
* @brief Checks if the cell is part of the current brick.
* @return True if the cell is part of the current brick, false otherwise.
*/
inline bool isCurrentBrickCell() const {return CurrentBrickCell;}
/**
* @brief Overloaded stream insertion operator to print the cell
representation.
* @param os The output stream.
* @param cell The cell object to be printed.
* @return A reference to the output stream.
*/
friend std::ostream& operator<<(std::ostream& os, const Cell& cell);
/**
* @brief Assignment operator for Cell objects.
* @param cell The Cell object to copy values from.
*/
void operator=(const Cell& cell);
/**
* @brief Deleted to prevent assignment from nullptr.
*/
Cell& operator=(const std::nullptr_t) = delete;

private:
/**
* @brief Sets the occupancy status of the cell.
* @param status The new occupancy status.
*/
inline void setOccupancyStatus(const bool& status) { OccupiedCell =
status;}
/**
* @brief Sets whether the cell is part of the current brick.
* @param status The new current status.
*/
inline void setCurrentStatus(const bool& status) { CurrentBrickCell =
status;}
/**
* @brief Resets the cell to its initial state.
*/
inline void reset() { CurrentBrickCell = false; OccupiedCell = false; }
/**
* @brief Sets the cell as part of the current brick.
*/
inline void setAsCurrentBrick() { CurrentBrickCell = true; OccupiedCell =
true; }

bool CurrentBrickCell ; ///< Indicates whether the cell is part of the


current brick.
bool OccupiedCell ; ///< Indicates whether the cell is occupied.
};

#endif // CELL_H

You might also like