CSPP 51090 Software Construction Assignment 5

Due: 5:00pm May 6, 2003

The following invariants govern the interactions in Bazaar:

  • a player should be told about exactly 10 equations
  • when a player takes a turn, there are exactly four (4) cards for sale
  • the administrator plays only a positive number of rounds
  • a player can trade pebbles only if the player owns the trade-in pebbles
  • a player can trade pebbles only if the requested trade is a valid equation
  • a player can buy a card only if the player owns enough pebbles
Determine which invariants should protect which methods, i.e., turn them into method contracts. Implement the contracts manually. [5pts]


Your second task is to implement interface sequence contracts. The goal is to ensure that you can plug "foreign" players into your administrator, that is, player objects that were written by someone you don't fully trust. Presumambly you have protected your portions of the code (via modules or packages) so that the code itself is safe (well, if you used C or C++, good luck). In short, we want to catch error in the players early.

Here are the three primary interfaces with sequence contracts:

It is your task to decide which ones you should implement, given that you are in control of the administrator and turn components and your friends and enemies write the player components. For those you choose not to implement, write a one-sentence explanation that explains your reasoning. [5pts]

Note 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.



CSPP 51090 Software Construction