Class Rack

java.lang.Object
  extended byRack

public class Rack
extends java.lang.Object

This class defines a Rack - a list of Letters. Each Player has a Rack. The methods defined in the class operate on Racks, so that a Letter can be extracted from an index, an index from a Letter, and so forth.

Version:
2.0
Author:
3GP01 - Hardev Bhamra, Deepak Chandarana, James Tompkin
See Also:
Game, Player

Constructor Summary
Rack()
           
 
Method Summary
 void addLetters(java.util.List l)
          Adds letters to the Rack.
 int getIndexOfLetter(Letter lett)
          Gets an index from a Letter.
 Letter getLetter(int i)
          Gets a Letter from the Rack at i.
 int getRackSize()
          Returns the size of the Rack.
 int getRackValue()
          Returns the value of the Rack as an int.
 int getReverseIndexOfLetter(Letter lett)
          Similar to getIndexOfLetter, but only from the back of the rack.
 boolean isEmpty()
          Return whether a Rack is empty or not.
 void removeLetters(java.util.List l)
          Removes letters from the Rack.
 void setLetter(int i, Letter lett)
          Sets the Letter at i on the Rack.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Rack

public Rack()
Method Detail

addLetters

public void addLetters(java.util.List l)
Adds letters to the Rack.

Parameters:
l - List containing the letters to be added.

removeLetters

public void removeLetters(java.util.List l)
Removes letters from the Rack. If a letter cannot be found in the Rack, index = -1. There are certain situations whereby this can be beneficial. A blank letter tile is often not found in a Rack, in which case we can assume that the letter that returns index = -1 is a blank letter tile.

Parameters:
l - The List of Letters to be removed from the Rack.

getLetter

public Letter getLetter(int i)
Gets a Letter from the Rack at i.

Parameters:
i - The index of the letter we require.
Returns:
Letter

getIndexOfLetter

public int getIndexOfLetter(Letter lett)
Gets an index from a Letter. Used in the hint move code to rearrange the rackButtons display of the user (in order to guide them towards a successful Move).

Parameters:
lett - The Letter we require an index for.
Returns:
int The index of the Letter lett

getReverseIndexOfLetter

public int getReverseIndexOfLetter(Letter lett)
Similar to getIndexOfLetter, but only from the back of the rack. Useful when we know a rack has more than one letter of the same kind.

Parameters:
lett - The Letter we require an index for.
Returns:
int The index of the Letter lett

getRackSize

public int getRackSize()
Returns the size of the Rack.

Returns:
int

getRackValue

public int getRackValue()
Returns the value of the Rack as an int.

Returns:
int

isEmpty

public boolean isEmpty()
Return whether a Rack is empty or not.

Returns:
boolean

setLetter

public void setLetter(int i,
                      Letter lett)
Sets the Letter at i on the Rack.

Parameters:
i - The index of the Rack we'd like to set.
lett - The letter we'd like to set on the Rack.

toString

public java.lang.String toString()