Software Construction Assignment 6: Contracts

Due: May 8, 2018 @ 10pm. Please include a README.txt that has both partners' names and email addresses.

For this assignment, you should add contracts to your Tsuro 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, note that the player has violated the contract (via a print out), kick them out of the game, and replace them with a random player. Do not stop the game for the other players.


Behavioral Contracts

The following invariants govern the interactions in Tsuro:

  • The colors passed in the initialize method should be consistent with the colors supplied in the board in place-pawn and play-turn
  • During each turn, a player's set of tiles should make sense (e.g., not already placed on the board, not more than three tiles, no tile should be a rotation of any other tile).
  • 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 is the player interface's sequence contract:

  (initialize . place-pawn . play-turn * . end-game)*
(where get-name can be called at any time). Implement this contracts in the classes that implement these interfaces


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 out some contracts to add to it.



Software Construction