All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class game.Player

java.lang.Object
   |
   +----game.Player

public class Player
extends Object
implements Observer, GameLinkConstants, GameLinkListener
The Player class manages the player in a general way, so it can be used in many games.


Variable Index

 o gamelink
Player uses an object network for the commnication client/Server.
 o generalId
The identity of the last Player
 o id
Player's identity
 o name
Name of Player
 o nameLabel
The label which contains the name of Player;
 o o
Player must be Observable by the others Players.
 o OTHER_DATA
to know if the data inform about an other Player.
 o PERSO_DATA
to know if the data inform about the Player.
 o playerPanel
The panel which represents the Player (with his name and his score);
 o score
Player's score.
 o scoreLabel
The label which contains the score of Player;

Constructor Index

 o Player()
Creates a Player without parameters
 o Player(int, Object)
Creates a new Player with the informations contained in a object.
 o Player(String)
Creates a new Player with only his name.
 o Player(String, GameLinkFilter)
Creates a new Player with his name and his gamelink.
 o Player(String, int)
Creates a new Player with his name and his identity.

Method Index

 o addObserver(Observer)
Adds an observer to the set of observers for this object.
 o countObservers()
Returns the number of observers of this object.
 o createLinkframe(int, Object, int)
Creates a new LinkFrame, which concerns only one Player.
 o deleteObserver(Observer)
Deletes an observer to the set of observers for this object.
 o deleteObservers()
Clears the observerlist so that this object no longer has any observers.
 o frameReceived(Object, LinkFrame)
Invoked when a new data frame is received.
 o getComponent()
Returns a Panel containing the name, and the score of the Player
 o getFrameData()
Returns an object which contains the informations necessaries for the constructions by a new client of a player, which still exists in the server.
 o getFrameDataPerso()
Returns an object which contains the informations necessaries for the constructions by a new client of its own player.
 o getGameLink()
Returns the GameLinkFilter of Player.
 o getId()
Return the Player's identity
 o getName()
Returns the Name of Player.
 o getNewId()
This method is called when a Player is created.
 o getScore()
Returns the Player's score.
 o isComputer()
Tells if Player is a ComputerPlayer or not.
 o main(String[])
 o notifyObservers(LinkFrame)
Notifies all the observers of this Player that he has changed and indicates this changement by a frame that will be send by the method update on a GameLinkFilter.
 o setGameLink(GameLinkFilter)
Set the GameLinkFilter of Player.
 o setName(String)
Set the name of Player.
 o setScore(int)
Set a new Player 's score.
 o toString()
Returns a string representation of the object.
 o update(Observable, Object)
This method sends the linkframe received from an observed object.

Variables

 o name
 protected String name
Name of Player

 o score
 protected int score
Player's score.

 o generalId
 static int generalId
The identity of the last Player

 o id
 int id
Player's identity

 o PERSO_DATA
 protected int PERSO_DATA
to know if the data inform about the Player.

 o OTHER_DATA
 protected int OTHER_DATA
to know if the data inform about an other Player.

 o gamelink
 protected GameLinkFilter gamelink
Player uses an object network for the commnication client/Server.

 o o
 protected Observable o
Player must be Observable by the others Players. So needs the object o to have the methods addObserver(), deleteObserver() and notifyObserver().

 o nameLabel
 protected JLabel nameLabel
The label which contains the name of Player;

 o scoreLabel
 protected JLabel scoreLabel
The label which contains the score of Player;

 o playerPanel
 protected JPanel playerPanel
The panel which represents the Player (with his name and his score);

Constructors

 o Player
 public Player()
Creates a Player without parameters

 o Player
 public Player(String name)
Creates a new Player with only his name.

 o Player
 public Player(int id,
               Object frameData)
Creates a new Player with the informations contained in a object. This Player will exit only in the client so he doesn't need to be observable.

Parameters:
frameData - the object which contains the informations about the Player.
 o Player
 public Player(String name,
               GameLinkFilter gamelink)
Creates a new Player with his name and his gamelink.

 o Player
 public Player(String name,
               int id)
Creates a new Player with his name and his identity.

Parameters:
name - the Player's name.
id - the identity of Player.

Methods

 o getNewId
 public synchronized int getNewId()
This method is called when a Player is created. It gives to this new Player his identity.

Returns:
the Player's new identity;
 o getId
 public int getId()
Return the Player's identity

Returns:
the Player's identity
 o getScore
 public int getScore()
Returns the Player's score.

Returns:
the Player's score.
 o setScore
 public void setScore(int newscore)
Set a new Player 's score.

Parameters:
newscore - the new score of Player.
 o getName
 public String getName()
Returns the Name of Player.

Returns:
the Player's Name.
 o setName
 public void setName(String newname)
Set the name of Player.

Parameters:
newName - the new Player's name.
 o getGameLink
 public GameLinkFilter getGameLink()
Returns the GameLinkFilter of Player.

Returns:
the Player's gamelink.
 o setGameLink
 public void setGameLink(GameLinkFilter newgamelink)
Set the GameLinkFilter of Player.

Parameters:
newGameLink - the new Player's gamelink.
 o update
 public void update(Observable object,
                    Object linkframe)
This method sends the linkframe received from an observed object.

Parameters:
observable - the observed object.
linkframe - the Object received from the observed object.
 o isComputer
 public boolean isComputer()
Tells if Player is a ComputerPlayer or not. This method must be implemented whenever a ComputerPlayer class will be created.

Returns:
true if the Player is a ComputerPlayer, false otherwise
 o addObserver
 public void addObserver(Observer obs)
Adds an observer to the set of observers for this object.

Parameters:
obs - an observer to be added.
 o deleteObserver
 public void deleteObserver(Observer obs)
Deletes an observer to the set of observers for this object.

Parameters:
obs - the observer to be deleted
 o deleteObservers
 public void deleteObservers()
Clears the observerlist so that this object no longer has any observers.

 o notifyObservers
 public void notifyObservers(LinkFrame frame)
Notifies all the observers of this Player that he has changed and indicates this changement by a frame that will be send by the method update on a GameLinkFilter.

Parameters:
frame - the Linkframe that indicates the changement.
 o countObservers
 public int countObservers()
Returns the number of observers of this object.

Returns:
the number of observers of this object.
 o frameReceived
 public void frameReceived(Object link,
                           LinkFrame frame)
Invoked when a new data frame is received.

Parameters:
frame - the frame that has just been received.
 o createLinkframe
 public LinkFrame createLinkframe(int request,
                                  Object data,
                                  int playerid)
Creates a new LinkFrame, which concerns only one Player.

Parameters:
request - the request of the frame.
data - the data of the frame.
playerid - the identity of the Player which is concerned by the request.
 o getFrameData
 public Object getFrameData()
Returns an object which contains the informations necessaries for the constructions by a new client of a player, which still exists in the server.

Returns:
the object which contains the informations about the player.
 o getFrameDataPerso
 public Object getFrameDataPerso()
Returns an object which contains the informations necessaries for the constructions by a new client of its own player.

Returns:
the object which contains the informations about the player.
 o toString
 public String toString()
Returns a string representation of the object.

Overrides:
toString in class Object
 o getComponent
 public Component getComponent()
Returns a Panel containing the name, and the score of the Player

 o main
 public static void main(String args[])

All Packages  Class Hierarchy  This Package  Previous  Next  Index