MiniGame-Madness
Public Member Functions | List of all members
Con4 Class Reference

Class to handle the Connect 4 game logic. More...

#include <con4.h>

Public Member Functions

 Con4 ()
 Constructor for the Connect4 class.
 
void populategrid ()
 Populates the game grid with initial values.
 
void dropcoin (int column, int playercoin)
 Drops a coin into the specified column. More...
 
void checkdraw ()
 Checks if the game is a draw.
 
void setnum (int player, int xval, int yval)
 Manually sets a position as a value given. More...
 
void checkwin ()
 Checks if there is a winning condition on the board.
 
int randomstarter ()
 Randomly selects the starting player. More...
 
int swapturn (int playert)
 Swaps the turn between players. More...
 
void playerturn (int player)
 Handles the player's turn. More...
 
void display ()
 Handles the display of the grid.
 
int connect4 ()
 Main function to run the Connect 4 game.
 

Detailed Description

Class to handle the Connect 4 game logic.

Member Function Documentation

◆ dropcoin()

void Con4::dropcoin ( int  column,
int  playercoin 
)

Drops a coin into the specified column.

Parameters
columnThe column to drop the coin into.
playercoinThe coin of the player.

◆ playerturn()

void Con4::playerturn ( int  player)

Handles the player's turn.

Parameters
playerThe current player.

◆ randomstarter()

int Con4::randomstarter ( )

Randomly selects the starting player.

Returns
int The starting player (1 or 2).

◆ setnum()

void Con4::setnum ( int  player,
int  xval,
int  yval 
)

Manually sets a position as a value given.

Parameters
playerThe player coin dropped
xvalThe x coordinate of the value to be changed
yvalThe y coordinate of the value to be changed

◆ swapturn()

int Con4::swapturn ( int  playert)

Swaps the turn between players.

Parameters
playertThe current player.

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