PlayerList Class Reference

#include <playerlist.h>

Collaboration diagram for PlayerList:

Collaboration graph
[legend]

List of all members.


Detailed Description

This is the list of all players in a game.

Note:
This class does NOT handle the memory management of any players!
Author:
John Schneiderman

Public Member Functions

void clear ()
PlayercurrentPlayer ()
int currentPlayerIndex () const
Playerdealer ()
void insert (Player &player)
bool isEmpty () const
PlayerleftPlayer ()
PlayerleftPlayerWithCards ()
PlayernextNonEmptyPlayer ()
PlayernextPlayer ()
const Playeroperator[] (int index) const
Playeroperator[] (int index)
 PlayerList ()
bool remove (const Player &player)
PlayerrightPlayer ()
PlayerrightPlayerWithCards ()
void setCurrentPlayer (const Player &player)
int size () const
void swap (int left, int right)

Friends

ostream & operator<< (ostream &out, const PlayerList &playerList)
QTextStream & operator<< (QTextStream &out, const PlayerList &playerList)
QTextStream & operator>> (QTextStream &in, PlayerList &playerList)

Constructor & Destructor Documentation

PlayerList::PlayerList (  ) 

Default constructor.


Member Function Documentation

void PlayerList::clear (  ) 

Clears the list of players.

Player & PlayerList::currentPlayer (  ) 

Accessor to the current player.

Returns:
the current player.

int PlayerList::currentPlayerIndex (  )  const

Accessor to the current player's index.

Returns:
the current player's index.

Player & PlayerList::dealer (  ) 

Accessor to the dealer player.

Returns:
the current dealer.
Exceptions:
KardsGTError if no player is found to be the dealer.

void PlayerList::insert ( Player player  ) 

Inserts a player into the list.

Parameters:
player is the player to place in the list.

bool PlayerList::isEmpty (  )  const

Determines if the player's list is empty.

Returns:
true if there are no players in the list, false if there are.

Player & PlayerList::leftPlayer (  ) 

Accessor to the player that is to the left of the current player.

Returns:
the left player.

Player & PlayerList::leftPlayerWithCards (  ) 

Accessor to the player that is to the left of the current player with cards.

Exceptions:
KardsGTError If there are not any players in the list with cards.
Returns:
the left player with cards.

Player & PlayerList::nextNonEmptyPlayer (  ) 

Increments to the next player who still has cards in his hand.

Note:
The list is circular.
Exceptions:
KardsGTError If there are not any players in the list with cards.
Returns:
the new current player.

Player & PlayerList::nextPlayer (  ) 

Increments to the next player.

Note:
The player list is circular.
Returns:
the new current player.

const Player & PlayerList::operator[] ( int  index  )  const

Random accsesor to the list of players.

Parameters:
index is the player to retrieve.
Exceptions:
KardsGTError if the index is out of range.
Returns:
the player requested as a point to a const.

Player & PlayerList::operator[] ( int  index  ) 

Random accsesor to the list of players.

Parameters:
index is the player to retrieve.
Exceptions:
KardsGTError if the index is out of range.
Returns:
the player requested.

bool PlayerList::remove ( const Player player  ) 

Removes a player from the list.

Parameters:
player is the player to remove from the list.
Returns:
true if successfully removed, false elsewise.

Player & PlayerList::rightPlayer (  ) 

Accessor to the player that is to the right of the current player.

Returns:
the right player.

Player & PlayerList::rightPlayerWithCards (  ) 

Accessor to the player that is to the right of the current player with cards.

Exceptions:
KardsGTError If there are not any players in the list with cards.
Returns:
the right player with cards.

void PlayerList::setCurrentPlayer ( const Player player  ) 

Sets the current player.

Parameters:
player is the player to set as the new current player.
Exceptions:
KardsGTError if player does not exist in the list of players.

int PlayerList::size (  )  const

This is the size of the players list.

Returns:
how many players are in the list.

void PlayerList::swap ( int  left,
int  right 
)

Swaps two player locations in the list.

Parameters:
left is the left player to be swapped into the right position.
right is the right player to be swapped into the left position.


Friends And Related Function Documentation

ostream& operator<< ( ostream &  out,
const PlayerList playerList 
) [friend]

The stream insertion for the player list.

Parameters:
out is the stream to insert the player's list into.
playerList is the list of players to place into the stream.
Returns:
out.

QTextStream& operator<< ( QTextStream &  out,
const PlayerList playerList 
) [friend]

The stream insertion for the player list.

Parameters:
out is the stream to insert the player's list into.
playerList is the list of players to place into the stream.
Returns:
out.

QTextStream& operator>> ( QTextStream &  in,
PlayerList playerList 
) [friend]

The stream extraction for the player list.

Parameters:
in is the stream to extract the player's list from.
playerList is the list of players to fill with the data from the stream.
Returns:
in.


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

Generated on Tue Aug 12 23:24:02 2008 for KardsGT by  doxygen 1.5.5