CSPP 51090 & CMSC 22001: Software Construction Assignment 5

Due: May 4, 2004

The goal of this assignment is to improve the error checking and cheating detection of your scrabble adminstrator.

These error checks correspond to basic checks on cheating that the administrator and the players in a real game conduct. The terminology of cheating, though, is a notion in the application domain. The purpose of contracts is to catch basic errors in the development of software systems.

Presumambly you have protected your portions of the code (via modules or packages) so that the code itself is reasonably safe. We'll ignore issues like raising exceptions, non-termination for now -- the contracts below ensure that the players cannot cheat when following the protocol and ensure some basic guarantees for the players.

For some of the contracts, blame for failure lies with the player and for some, blame lies with the administrative infrastucture. For those where blame lies with the administrator, abort the program when a failure is detected. For those where the blame lies with the player, inform the player that they have violated the contract and kick them out of the game, but do not stop the game for any other players.


Behavioral Contracts

The following invariants govern the interactions in Scrabble:

  • Initially, a player should be told about exactly 7 tiles.
  • When a player takes a turn, .
  • When a player exchanges tiles,
    • they exchange only as many tiles as they have (or fewer),
    • they do not exchange more tiles than are left in the bag, and
    • they receive as many tiles as they turned in.
  • When a player places a tile or a blank, they place it on an empty space.
  • When a player finishes playing tiles:
    • The player has all of the tiles they played.
    • All of the tiles are in a single row horizontally, or a single column vertically.
    • The tiles are all adjacent to each other, unless existing tiles were in the way.
    • At least one of the tiles is adjacent to an existing tile, or the play covers the middle square (7,7).
    • The player receives as many tiles as they played or all of the remaining tiles in the bag, whichever is smaller.
    • The board should be in a legal state (according to the last assignment).
Determine which invariants should protect which methods, i.e., turn them into method contracts. Implement the contracts manually. [5pts]


Sequence Contracts

Here are the three primary interfaces with sequence contracts:

Implement the sequence contracts in classes that implement these interfaces (one class per interface is sufficient -- you may want to implement the player contracts in the splayer). [5pts]



CSPP 51090 & CMSC 22001: Software Construction