2 — Living up to interfaces

Due Sunday, 24 January, midnight

The assignment consists of two separate tasks though related in theme. While the first one is about implementing someone else’s specification—so-called obligationsthe second one is to implement your own interface specifications—also called promises.

Task 1 Mr. Garnock-Jones will deposit an anonymizd interface specification from some other pair in class. In other words, you are now a citizen of Foomanistan, and your task is to implement a player that satisfies the interface as well as you can.

To simplify the code, the player’s strategy is to place the card with the highest face value when it is its turn, regardless of the stacks on the table. When it must pick up a stack from the table, it naturally picks up the stack with the fewest number of bull points. [In actual games, players occasionally use a different choice.]

If you encounter ambiguities in the specification, document them and resolve them in what you consider the most natural manner. Then implement this decision.

If you encounter under-specifications, document them, make reasonable assumptions, and supplement specifications. Then implement the documented supplementary specifications.

If it is truly impossible to implement the interface, write a memo to your boss (me).

Delivery Deposit the main file player implementation in the appropriate directory and name it player.xyz (for an appropriate xyz). Name auxiliary files appropriately and place them in the same directory.

If you write a memo on the infeasibility of implementing the player interface, deposit it as player.txt.

Task 2 Your second task is to implement the rest of the system that you imagined when you wrote the interface. Do not think of it as a monolithic block, but when you do break it down, make sure to carefully spell out your own interfaces.

When the Foomanistanian subsidiary delivers your desired player implementation, you ought to have a working simulation.

Specification Your system must name the players with natural numbers (0, 1, 2, etc). Abstract (parameterize) your implementation over two aspects:
  • the number of bull points on a card for the initial deck of cards, and

  • the order in which cards are handed out to players.

    Remember that players are handed cards first, the stacks are formed at the end.

When a round is over, the system starts over with a freshly shuffled complete deck of cards.

When a simulation is over, the program prints the index numbers and bull points of the players, sorted in increasing order for the second.

Delivery Create a sub-directory named take5 in your assignment’s folder. Place all files that implement the rest of the system into take5.