OOP A3 Board Games 35
a Board Game Project Made by Students at Cairo FCAI
Loading...
Searching...
No Matches
UI< T > Class Template Referenceabstract

Base class for handling user interface and input/output. More...

#include <BoardGame_Classes.h>

Public Member Functions

 UI (string message, int cell_display_width)
 Construct the UI and display a welcome message.
virtual ~UI ()
void display_message (string message)
 Display any message to the user.
virtual Move< T > * get_move (Player< T > *)=0
 Ask the user (or AI) to make a move.
virtual Player< T > ** setup_players ()
 Set up players for the game.
virtual Player< T > * create_player (string &name, T symbol, PlayerType type)=0
 Create a player object based on input name, symbol, and type.
void display_board_matrix (const vector< vector< T > > &matrix) const
 Display the current board matrix in formatted form.

Protected Member Functions

string get_player_name (string player_label)
 Ask the user for the player's name.
PlayerType get_player_type_choice (string player_label, const vector< string > &options)
 Ask the user to choose the player type from a list.

Protected Attributes

int cell_width
 Width of each displayed board cell.

Detailed Description

template<typename T>
class UI< T >

Base class for handling user interface and input/output.

Template Parameters
TThe type of symbol used on the board.

Constructor & Destructor Documentation

◆ UI()

template<typename T>
UI< T >::UI ( string message,
int cell_display_width )
inline

Construct the UI and display a welcome message.

◆ ~UI()

template<typename T>
virtual UI< T >::~UI ( )
inlinevirtual

Member Function Documentation

◆ create_player()

template<typename T>
virtual Player< T > * UI< T >::create_player ( string & name,
T symbol,
PlayerType type )
pure virtual

Create a player object based on input name, symbol, and type.

Implemented in FourUI, Numerical_UI, SUSUI, and TicTacToe4x4_UI.

◆ display_board_matrix()

template<typename T>
void UI< T >::display_board_matrix ( const vector< vector< T > > & matrix) const
inline

Display the current board matrix in formatted form.

◆ display_message()

template<typename T>
void UI< T >::display_message ( string message)
inline

Display any message to the user.

◆ get_move()

template<typename T>
virtual Move< T > * UI< T >::get_move ( Player< T > * )
pure virtual

◆ get_player_name()

template<typename T>
string UI< T >::get_player_name ( string player_label)
inlineprotected

Ask the user for the player's name.

◆ get_player_type_choice()

template<typename T>
PlayerType UI< T >::get_player_type_choice ( string player_label,
const vector< string > & options )
inlineprotected

Ask the user to choose the player type from a list.

◆ setup_players()

template<typename T>
Player< T > ** UI< T >::setup_players ( )
virtual

Set up players for the game.

Default implementation of setting up two players.

Member Data Documentation

◆ cell_width

template<typename T>
int UI< T >::cell_width
protected

Width of each displayed board cell.


The documentation for this class was generated from the following file: