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

Membros Públicos

 TTT ()
 Constructs a TTT (Tic-Tac-Toe) game object.
 
void readMove () override
 Reads a move from the user and validates it.
 
void makeMove () override
 Makes a move in the Tic-Tac-Toe game.
 
char isGameFinished () override
 Checks the current state of the game to determine if it has finished.
 
- 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 ()
 
virtual void printBoard ()
 Prints the current state of the game board to the standard output.
 

Membros privados

void validateMove (int row, int col)
 Validates a move in the Tic-Tac-Toe game.
 
int checkLine (bool isRow)
 Checks if there is a winning line (row or column) in the Tic-Tac-Toe board.
 
int checkRows ()
 Checks the rows in the Tic-Tac-Toe game for a win condition.
 
int checkColumns ()
 Checks the columns in the game.
 
int checkDiagonals ()
 Checks the diagonals of the Tic-Tac-Toe board to determine if there is a winner.
 

Outros membros herdados

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

Documentação das funções

◆ checkColumns()

int checkColumns ( )
private

Checks the columns in the game.

Retorna
int Returns an integer indicating the result of the column check.
Este é o diagrama das funções utilizadas por essa função:
Esse é o diagrama das funções que utilizam essa função:

◆ checkDiagonals()

int checkDiagonals ( )
private

Checks the diagonals of the Tic-Tac-Toe board to determine if there is a winner.

This function checks both the main diagonal (from top-left to bottom-right) and the anti-diagonal (from top-right to bottom-left) of the board. If all three elements in either diagonal are the same, it returns the value of that element (which represents the winner). If neither diagonal has a winner, it returns a space character (' ').

Retorna
The value of the winning element ('X' or 'O') if there is a winner, otherwise returns ' '.
Este é o diagrama das funções utilizadas por essa função:
Esse é o diagrama das funções que utilizam essa função:

◆ checkLine()

int checkLine ( bool isRow)
private

Checks if there is a winning line (row or column) in the Tic-Tac-Toe board.

This function iterates through each row or column of the board (depending on the isRow parameter) and checks if all elements in the row or column are the same and not empty.

Parâmetros
isRowA boolean indicating whether to check rows (true) or columns (false).
Retorna
The character representing the winner ('X' or 'O') if a winning line is found, or a space character (' ') if no winning line is found.
Este é o diagrama das funções utilizadas por essa função:
Esse é o diagrama das funções que utilizam essa função:

◆ checkRows()

int checkRows ( )
private

Checks the rows in the Tic-Tac-Toe game for a win condition.

Retorna
int The result of the checkLine method, indicating the status of the rows.
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 the current state of the game to determine if it has finished.

Retorna
int - The result of the game:
  • Winning player's symbol if there is a winner.
  • 'D' if the game is a draw.
  • 'E' if the game is still ongoing.

Implementa Game.

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

◆ makeMove()

void makeMove ( )
overridevirtual

Makes a move in the Tic-Tac-Toe game.

This function reads the player's move and sets the specified symbol at the corresponding position on the game board.

Implementa Game.

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

◆ readMove()

void readMove ( )
overridevirtual

Reads a move from the user and validates it.

Exceções
InvalidInputExceptionif the move 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 row,
int col )
private

Validates a move in the Tic-Tac-Toe game.

This function checks if the move specified by the row and column is valid. A move is considered valid if the specified position on the board is empty and within the bounds of the board.

Parâmetros
rowThe row index of the move.
colThe column index of the move.
Exceções
InvalidInputExceptionif the position is already occupied or if the position is out of the board's bounds.
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: