Class Player

java.lang.Object
  extended by Player

public class Player
extends java.lang.Object

This Player class represents all the client side game functionalites or player side game functionalities of this 304 cards game. This player class is the oparational class int he client side to deal with interface class and client class. Basically all the player side game functionalites are handled by this Player class.


Field Summary
private  int bestBet
           
private  int bestBetBy
           
private  boolean betFinished
           
(package private)  Cards304Client client
           
private  int gameId
           
(package private)  Interface gui
           
private  java.lang.Boolean[] hand
           
private  java.util.ArrayList<Card> handCards
           
private  int myBet
           
private  int playerId
           
private  int[] playerPoints
           
private  boolean selectTrump
           
private  java.lang.Boolean[] table
           
private  Card[] tableCards
           
private  java.lang.String[] team
           
private  Card trump
           
private  boolean trumpOpen
           
private  boolean trumpTrun
           
private  int[] wins
           
 
Constructor Summary
Player(Cards304Client client)
          Constucter method of this class.
 
Method Summary
 void addme2team(java.lang.String myName)
          This method is to a player's name to a team.
private  int enemyOf(int player)
          This method is to find an openent of a player.
 void exitGame()
          This method will be triggerd from the server when someone closes his/her game window.
protected  void finalize()
          This method finalizes the game.
 int getGameId()
          This method is to get the game id from this class.
 int getPlayerId()
          This method is to get the player id.
 void handCardSelected(int no)
          This method is triggerd when any of those hand card are selected.
 void illbet()
          This method is to accept the bet from the player.
private  boolean isNumeric(java.lang.String number)
          This method is to check whether a string value can be converted to numeric or not.
 boolean isTrumpOpen()
          This method checks and return whether the trump is open or not.
 void myTurn()
          This method enables the user interface to the player to select a card when the player's turn comes.
 void newPlay(int player0, int player1, int player2, int player3, int winner)
          This method is called when a play finishes.
 int noOfCards()
          This method is to count the no of cards in the hand and returns by checking the hand boolean array.
private  int partnerOf(int player)
          This method is to find the partner of a player.
 void printCards()
          This method prints the name of cards in the hand.
 void resetTable()
          This method is to reset the tableCards array.
 void scoreBoardCheck()
          This method checks the score and updates teh scoreboard.
 void selectedConfirmed(int playerId, java.lang.String card)
          this method is to confirm player's selection.
 void servetherest()
          This method is to server the final four cards to hand.
 void setBestBet(int player, int bestbet)
          This method is to set the best bet.
 void setGameId(int gameId)
          This method sets the game id to this class object.
 void setHandCards(java.util.ArrayList<Card> cards)
          setHandcards method is to set the cards to handCards arraylist and serves first four cards to players, in order to enable them to choose a trump.
 void setHandCards(java.lang.String cards)
          This method is to set the cards to handCards arralylist from a single String separated my coma.
 void setPlayerId(int playerId)
          This method is to set player id to this player class object.
 void setplayername(int playerId, java.lang.String playerName)
          This method sets a player's name to team string array in the right player position.
 void setTrumpTurn(boolean turn)
          This method is to set the trump turn.
 Card trump()
          This method is to ger the trump card.
 void trumpClicked()
          This methed is triggerd when user clicks the tump button in the table.
 void trumpConfirmed()
          This method is called when server confirms the trump.
 void trumpUsed()
          This method is to check whether the trump is used or not.
 void updatePoints(int playerPoint0, int playerPoint1, int playerPoint2, int playerPoint3)
          This method is to update the points.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

client

Cards304Client client

gui

Interface gui

gameId

private int gameId

playerId

private int playerId

playerPoints

private int[] playerPoints

wins

private int[] wins

handCards

private java.util.ArrayList<Card> handCards

tableCards

private Card[] tableCards

myBet

private int myBet

trump

private Card trump

bestBet

private int bestBet

bestBetBy

private int bestBetBy

betFinished

private boolean betFinished

selectTrump

private boolean selectTrump

trumpOpen

private boolean trumpOpen

trumpTrun

private boolean trumpTrun

team

private java.lang.String[] team

hand

private java.lang.Boolean[] hand

table

private java.lang.Boolean[] table
Constructor Detail

Player

public Player(Cards304Client client)
Constucter method of this class.

Parameters:
client - Cards304Client class object.
Method Detail

addme2team

public void addme2team(java.lang.String myName)
This method is to a player's name to a team. This method send the name to the server to add the name.


setplayername

public void setplayername(int playerId,
                          java.lang.String playerName)
This method sets a player's name to team string array in the right player position. this method is to be called by the client take action method. So the server's team details and client's team details will be synchronized.

Parameters:
playerId - int player's id
playerName - String player's name.

setHandCards

public void setHandCards(java.util.ArrayList<Card> cards)
setHandcards method is to set the cards to handCards arraylist and serves first four cards to players, in order to enable them to choose a trump.

Parameters:
cards - ArrayList

setHandCards

public void setHandCards(java.lang.String cards)
This method is to set the cards to handCards arralylist from a single String separated my coma. serves first four to players, in order to enable them to choose a trump.

Parameters:
cards - String contains name of every card separated by coma.

setBestBet

public void setBestBet(int player,
                       int bestbet)
This method is to set the best bet.

Parameters:
player - int gets which player's bet is best.
bestbet - int the best bet.

noOfCards

public int noOfCards()
This method is to count the no of cards in the hand and returns by checking the hand boolean array.

Returns:
int no of cards in the hand.

trumpUsed

public void trumpUsed()
This method is to check whether the trump is used or not.


trumpClicked

public void trumpClicked()
This methed is triggerd when user clicks the tump button in the table. check whether trump can be open or not and then opens the trump.


handCardSelected

public void handCardSelected(int no)
This method is triggerd when any of those hand card are selected.

Parameters:
no - int the array index no of hand card buttons. it'll be between 0-7.

selectedConfirmed

public void selectedConfirmed(int playerId,
                              java.lang.String card)
this method is to confirm player's selection. This method is called when the server confirms the selection.

Parameters:
playerId - int index number of a player.
card - String name of the card the user selected.

trumpConfirmed

public void trumpConfirmed()
This method is called when server confirms the trump.


myTurn

public void myTurn()
This method enables the user interface to the player to select a card when the player's turn comes.


partnerOf

private int partnerOf(int player)
This method is to find the partner of a player.

Parameters:
player - int player id.
Returns:
int partner player's id.

newPlay

public void newPlay(int player0,
                    int player1,
                    int player2,
                    int player3,
                    int winner)
This method is called when a play finishes. To set the player's winning results to the scoreboard and to reset the player class variables for the next play.

Parameters:
player0 - int first player's index number.
player1 - int second player's index number.
player2 - int third player's index number.
player3 - int fourth player's index number.
winner - int one of the winning team member's player index number.

scoreBoardCheck

public void scoreBoardCheck()
This method checks the score and updates teh scoreboard.


enemyOf

private int enemyOf(int player)
This method is to find an openent of a player. Even though there are two openents, this method will return you the next oponent's player id.

Parameters:
player - int player id.
Returns:
int oponent player's id.

isTrumpOpen

public boolean isTrumpOpen()
This method checks and return whether the trump is open or not.


trump

public Card trump()
This method is to ger the trump card. return Card trump.


resetTable

public void resetTable()
This method is to reset the tableCards array.


printCards

public void printCards()
This method prints the name of cards in the hand.


setPlayerId

public void setPlayerId(int playerId)
This method is to set player id to this player class object.

Parameters:
playerId - int player id.

getPlayerId

public int getPlayerId()
This method is to get the player id.

Returns:
int player id.

setTrumpTurn

public void setTrumpTurn(boolean turn)
This method is to set the trump turn.


setGameId

public void setGameId(int gameId)
This method sets the game id to this class object.

Parameters:
gameId - int game id.

getGameId

public int getGameId()
This method is to get the game id from this class.

Returns:
int game id.

illbet

public void illbet()
This method is to accept the bet from the player.


servetherest

public void servetherest()
This method is to server the final four cards to hand.


updatePoints

public void updatePoints(int playerPoint0,
                         int playerPoint1,
                         int playerPoint2,
                         int playerPoint3)
This method is to update the points.


exitGame

public void exitGame()
This method will be triggerd from the server when someone closes his/her game window. so this method terminates the game with a proper message.


isNumeric

private boolean isNumeric(java.lang.String number)
This method is to check whether a string value can be converted to numeric or not.

Parameters:
number - String value to be checked.

finalize

protected void finalize()
This method finalizes the game.

Overrides:
finalize in class java.lang.Object