Thinking In Objects

 

Justin Harrison, Matthieu Daley, Dontae Mair, Jeffrey Desir

 

Scrabble

 

How to Play

 

 1. For each Scrabble game, there must be at least two players and no more than four.

1

5. Words placed diagonally or backwards are not allowed.

 

3. Once the order of turns is established, each person draws six more tiles in that order.

2. The person who draws the earliest letter in the alphabet plays first.

4. Tiles can only be placed from left to right or from top to bottom.

Scrabble

 

6. The game progresses as each player lays down tiles on the board that make up words that connect to already played words, like making one big crossword puzzle.

 

 

5. After each turn, the tile values are added up and placed on the score sheet, and the person draws the number of tiles they used for their last play, always having seven tiles until all tiles run out.

 

7. The person with the most points at the end of the game wins.

Pseduo-Code for Game

<<Abtract>> Board Class

 
public abstract class Board
{
    int getHeight();
    int getWidth();
    boolean isLegal();
    boolean startGame();
    void endGame();
}

Scrabble Board

public class ScrabbleBoard extends Board {
    private List<Player>() players;
    private int[] scoreBoard;
    
    public ScrabbleBoard()
    {
       mkBoard();
    }

    public void addScore(Player p)
    {
        p.score=+amount;
     }

     public boolean isAWord()
    {
}
    
@Override
public String toString()
{
    return "info"
}
        
}

Letter bag Class

public class Letterbag {
  private String[] alphabet = 
{"A","B","C","D","E","F","G","H","I",
"J","K","L","M","N",
"O","P","Q","R","S","T",
"U","V","W","X","Y","Z" } 
  private final int maxLetter = 100;
  private int size;
  private List<Letter> bag;

  public letterBag()
  {
    bag = new ArrayList<Letter>(maxLetter);
  for(Each Letter && Corresponding Point Value)
  {
    bag.add(new Letter(→ forAllLetters))
     }
  }

  public Letter giveLetter(Player p)
  {
    p.letterHolder.add(bag.get(randomLetter))
      bag.remove(randomLetter))
      size--;
  }

   @Override
    public String toString()
    {
        return this.size + this.bag;
    }
}

Tile Class

public class Tile {

  public Tile()
  {
    mkTile()
  }

    public void mkSpecialTile()
{
board.add.randomTile();
}

   @Override
    public String toString()
    {
        return this.size + this.bag;
    }

}
public class Letter {
  private int letterValue;
  private String letter;
  
  public Letter(String let, int v)
   {
    this.letterValue = v;
    this.letter = let;
   }

  public String getLetter()
   {
    return this.letter;
   }

  public int getValue()
   {
    return this.letterValue;
   }   

  @Override
  public String toString()
    {
     return "Letter: " + getLetter() + " Value: " + ParseInt(getValue());
    } 
}

Letter Class

 

Player Class

public class Player 
 {
   private final int maxSize = 7;
   private List<Letter>() letterHolder;
   private int score;
  

   public Player()
   {  
     letterHolder = new ArrayList<Letter>(maxSize);
     for(int x = 0 ; x < maxSize; x++)
     {
       letterHolder.add(Letterbag.giveLetter(this));
     }
   }

    private Letter chooseLetter(String str)
    {
        if(hasLetter())
        {
            for(Letter let : letterHolder)
                {
                    if(let.getLetter().equals(str))
                        {
                           return let;
                        }
                }
        } else { return null;
    }

    private void refillHolder()
    {
        if(letterHolder.size() < maxSize)
            {
                while(true)
                { LetterBag.giveLetter(this)
        }
    }
 
    public int getScore()
    {
       return this.score;
    }

    @Override
    public String toString() { return ParseInt(score); }  
}

Thinking in Objects

By Geoff Desir

Thinking in Objects

  • 400
Loading comments...

More from Geoff Desir