Trabalho Prático - PDS2
Carregando...
Procurando...
Nenhuma entrada encontrado
Referência da Classe Lig4
Diagrama de hierarquia da classe Lig4:
Diagrama de colaboração para Lig4:

Membros Públicos

 Lig4 (int rows, int cols)
 Constructs a new Lig4 object with the specified number of rows and columns.
 
void validateMove (int col)
 Validates a move in the Lig4 game.
 
void makeMove () override
 Executes a move in the Lig4 game.
 
char isGameFinished () override
 Checks if the game is finished.
 
void printBoard () override
 Prints the current state of the game board to the standard output.
 
- Membros Públicos herdados de Game
 Game (int rows, int cols)
 Constructs a new Game object with the specified number of rows and columns.
 
void changePlayer ()
 

Membros privados

bool checkDirection (int row, int col, int rowDir, int colDir)
 Checks if there are four consecutive elements in a specified direction.
 
void readMove () override
 Reads a move from the user and validates it.
 

Outros membros herdados

- Atributos Protegidos herdados de Game
Board board
 
std::pair< int, int > move
 
char current_player
 

Construtores e Destrutores

◆ Lig4()

Lig4 ( int rows,
int cols )

Constructs a new Lig4 object with the specified number of rows and columns.

Parâmetros
rowsThe number of rows for the Lig4 game board.
colsThe number of columns for the Lig4 game board.

Documentação das funções

◆ checkDirection()

bool checkDirection ( int row,
int col,
int rowDir,
int colDir )
private

Checks if there are four consecutive elements in a specified direction.

This function checks if there are four consecutive elements starting from the given position (row, col) in the direction specified by (rowDir, colDir).

Parâmetros
rowThe starting row position.
colThe starting column position.
rowDirThe row direction to check (e.g., 1 for down, -1 for up, 0 for no vertical movement).
colDirThe column direction to check (e.g., 1 for right, -1 for left, 0 for no horizontal movement).
Este é o diagrama das funções utilizadas por essa função:
Esse é o diagrama das funções que utilizam essa função:

◆ isGameFinished()

char isGameFinished ( )
overridevirtual

Checks if the game is finished.

This function iterates through the entire game board and checks for a winning condition in four possible directions: horizontal, vertical and diagonals. If a winning condition is found, it returns the element (player) that has won. If the board is full and no winning condition is found, it returns 'D' indicating a draw. If the game is still ongoing, it returns 'E'.

Retorna
int The element (player) that has won, 'D' for draw, or 'E' for ongoing game.

Implementa Game.

Este é o diagrama das funções utilizadas por essa função:

◆ makeMove()

void makeMove ( )
overridevirtual

Executes a move in the Lig4 game.

This function reads the player's move and updates the game board. It places the current player's piece in the lowest available position in the specified column.

Observação
Assumes that the move is valid and within the bounds of the board.

Implementa Game.

Este é o diagrama das funções utilizadas por essa função:

◆ printBoard()

void printBoard ( )
overridevirtual

Prints the current state of the game board to the standard output.

Reimplementa Game.

Este é o diagrama das funções utilizadas por essa função:

◆ readMove()

void readMove ( )
overrideprivatevirtual

Reads a move from the user and validates it.

Exceções
InvalidInputExceptionif the input column is invalid.

Implementa Game.

Este é o diagrama das funções utilizadas por essa função:
Esse é o diagrama das funções que utilizam essa função:

◆ validateMove()

void validateMove ( int col)

Validates a move in the Lig4 game.

This function checks if the specified column is within the valid range and if the top position of the column is not already occupied.

Parâmetros
colThe column number to validate.
Exceções
InvalidInputExceptionif the column is out of bounds or the position is occupied.
Este é o diagrama das funções utilizadas por essa função:
Esse é o diagrama das funções que utilizam essa função:

A documentação para essa classe foi gerada a partir dos seguintes arquivos: