All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class scrobble.ServerBag

java.lang.Object
   |
   +----scrobble.Bag
           |
           +----scrobble.ServerBag

public class ServerBag
extends Bag
implements GameLinkConstants
This class is the Server version of the class Bag. It handles all the Bag operations (giving and receiving letter...)


Variable Index

 o cheat
Boolean cheat enable to play in a cheaty way.
 o debug
if true, enables the printing of debug informations on the console.
 o o
ServerBag must be Observable by the others ClientBag.

Constructor Index

 o ServerBag()
Creates a new ServerBag
 o ServerBag(Distribution)
Creates a new ServerBag

Method Index

 o addLetters(Vector)
Set the modification happened to the bag, notify the observer.
 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)
Creates a new LinkFrame to tranmit to ClientBag.
 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 getLetter()
Get a letter The letters in the Bag are organized following a Vector structure, built with a random process.
 o getLetters(int)
Removes one or more letters from the bag and return them.
 o getRandomLetter()
helper func.
 o getSize()
getSize
 o notifyObservers(LinkFrame)
[Describe me]
 o setLetter(Letter)
Set a letter

Variables

 o debug
 static boolean debug
if true, enables the printing of debug informations on the console.

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

 o cheat
 boolean cheat
Boolean cheat enable to play in a cheaty way.

Constructors

 o ServerBag
 public ServerBag(Distribution distribution)
Creates a new ServerBag

 o ServerBag
 public ServerBag()
Creates a new ServerBag

Methods

 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 countObservers
 public int countObservers()
Returns the number of observers of this object.

Returns:
the number of observers of this object.
 o notifyObservers
 public void notifyObservers(LinkFrame frame)
[Describe me]

 o createLinkframe
 public LinkFrame createLinkframe(int request,
                                  Object data)
Creates a new LinkFrame to tranmit to ClientBag.

Parameters:
request - the request of the frame.
data - the data of the frame.
 o addLetters
 public void addLetters(Vector newLetters)
Set the modification happened to the bag, notify the observer.

Parameters:
newLetters - the new vector of letters remaining in the Bag.
 o getRandomLetter
 Letter getRandomLetter() throws Exception
helper func. Exception has to be created properly (ie EmptyBagException or ..) -vim980406

 o getLetter
 public Letter getLetter() throws Exception
Get a letter The letters in the Bag are organized following a Vector structure, built with a random process. Eventually, the Bag returns a random letter. Faire une exception si le sac est vide

 o getLetters
 public Vector getLetters(int n) throws Exception
Removes one or more letters from the bag and return them.

Parameters:
n - the number of letters to remove from the bag
Returns:
the letters actually removed from the bag
Throws: Exception
@@ [PENDING: Create me, describe me]
 o setLetter
 public void setLetter(Letter letter)
Set a letter

 o getSize
 public int getSize()
getSize


All Packages  Class Hierarchy  This Package  Previous  Next  Index