Software Construction Assignment 5: Contracts

Due: April 25, 2017 @ 5pm. Please include a README.txt that has both partner's names and email addresses.

For this assignment, you should add contracts to your Parcheesi implementation.

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 (if possible) and kick them out of the game, but do not stop the game for the other players.


Behavioral Contracts

The following invariants govern the interactions in Parcheesi:

  • Initially, a player should be told about that its color is one of "red", "green", "blue", or "yellow".
  • During each turn, a player should be told about either two dice or four dice (in the case that a roll is doubles and the player has all of its pieces out).
  • When a player indicates their move, it must be legal.
Determine which invariants should protect which methods, and turn them into method contracts. Implement the contracts manually.


Sequence Contracts

Here are two of the primary interfaces with sequence contracts:

  • Game
    register * . start
  • Player
     (startGame . (doMove | doublesPenalty)*)* 
Implement the sequence contracts in classes that implement these interfaces (one class per interface is sufficient -- you should probably implement the player contracts in the SPlayer).


Your own contracts

As we discussed in class, contracts belong at key interfaces in the program. The above contracts protect the administration of the game from the players (and vice-versa). Find another place in your own organization of your program that would benefit from contracts and work our some contracts to add to it.



Software Construction