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.
-
gamelink
- Player uses an object network for the commnication client/Server.
-
generalId
- The identity of the last Player
-
id
-
Player's identity
-
name
- Name of Player
-
nameLabel
- The label which contains the name of Player;
-
o
- Player must be Observable by the others Players.
-
OTHER_DATA
- to know if the data inform about an other Player.
-
PERSO_DATA
- to know if the data inform about the Player.
-
playerPanel
- The panel which represents the Player (with his name and his score);
-
score
- Player's score.
-
scoreLabel
- The label which contains the score of Player;
-
Player()
- Creates a Player without parameters
-
Player(int, Object)
- Creates a new Player with the informations contained in a
object.
-
Player(String)
- Creates a new Player with only his name.
-
Player(String, GameLinkFilter)
- Creates a new Player with his name and his gamelink.
-
Player(String, int)
- Creates a new Player with his name and his identity.
-
addObserver(Observer)
- Adds an observer to the set of observers for this object.
-
countObservers()
- Returns the number of observers of this object.
-
createLinkframe(int, Object, int)
- Creates a new LinkFrame, which concerns only one Player.
-
deleteObserver(Observer)
- Deletes an observer to the set of observers for this object.
-
deleteObservers()
- Clears the observerlist so that this object no longer has any observers.
-
frameReceived(Object, LinkFrame)
- Invoked when a new data frame is received.
-
getComponent()
- Returns a Panel containing the name, and the score of the Player
-
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.
-
getFrameDataPerso()
- Returns an object which contains the informations necessaries for the
constructions by a new client of its own player.
-
getGameLink()
- Returns the GameLinkFilter of Player.
-
getId()
- Return the Player's identity
-
getName()
- Returns the Name of Player.
-
getNewId()
- This method is called when a Player is created.
-
getScore()
- Returns the Player's score.
-
isComputer()
- Tells if Player is a ComputerPlayer or not.
-
main(String[])
-
-
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.
-
setGameLink(GameLinkFilter)
- Set the GameLinkFilter of Player.
-
setName(String)
- Set the name of Player.
-
setScore(int)
- Set a new Player 's score.
-
toString()
- Returns a string representation of the object.
-
update(Observable, Object)
- This method sends the linkframe received from an observed object.
name
protected String name
- Name of Player
score
protected int score
- Player's score.
generalId
static int generalId
- The identity of the last Player
id
int id
- Player's identity
PERSO_DATA
protected int PERSO_DATA
- to know if the data inform about the Player.
OTHER_DATA
protected int OTHER_DATA
- to know if the data inform about an other Player.
gamelink
protected GameLinkFilter gamelink
- Player uses an object network for the commnication client/Server.
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().
nameLabel
protected JLabel nameLabel
- The label which contains the name of Player;
scoreLabel
protected JLabel scoreLabel
- The label which contains the score of Player;
playerPanel
protected JPanel playerPanel
- The panel which represents the Player (with his name and his score);
Player
public Player()
- Creates a Player without parameters
Player
public Player(String name)
- Creates a new Player with only his name.
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.
Player
public Player(String name,
GameLinkFilter gamelink)
- Creates a new Player with his name and his gamelink.
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.
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;
getId
public int getId()
- Return the Player's identity
- Returns:
- the Player's identity
getScore
public int getScore()
- Returns the Player's score.
- Returns:
- the Player's score.
setScore
public void setScore(int newscore)
- Set a new Player 's score.
- Parameters:
- newscore - the new score of Player.
getName
public String getName()
- Returns the Name of Player.
- Returns:
- the Player's Name.
setName
public void setName(String newname)
- Set the name of Player.
- Parameters:
- newName - the new Player's name.
getGameLink
public GameLinkFilter getGameLink()
- Returns the GameLinkFilter of Player.
- Returns:
- the Player's gamelink.
setGameLink
public void setGameLink(GameLinkFilter newgamelink)
- Set the GameLinkFilter of Player.
- Parameters:
- newGameLink - the new Player's gamelink.
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.
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
addObserver
public void addObserver(Observer obs)
- Adds an observer to the set of observers for this object.
- Parameters:
- obs - an observer to be added.
deleteObserver
public void deleteObserver(Observer obs)
- Deletes an observer to the set of observers for this object.
- Parameters:
- obs - the observer to be deleted
deleteObservers
public void deleteObservers()
- Clears the observerlist so that this object no longer has any observers.
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.
countObservers
public int countObservers()
- Returns the number of observers of this object.
- Returns:
- the number of observers of this object.
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.
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.
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.
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.
toString
public String toString()
- Returns a string representation of the object.
- Overrides:
- toString in class Object
getComponent
public Component getComponent()
- Returns a Panel containing the name, and the score of the Player
main
public static void main(String args[])
All Packages Class Hierarchy This Package Previous Next Index