Excerpt from Description of Exercise

Objective:To gain experience using loops and active objects.

The Scenario.

The goal of this program is to play a simple game called ``Three-Cow Monty''. The program begins with three seemingly identical cows lined up in a row as shown below. However, one of the cows is different. If you click on the middle cow, it moos and you score a point for picking the correct cow. If you click on either other cow, they do not moo and your incorrect score increases by one. In itself, this is not much of the game, but if you click outside any cow the program shuffles their order in front of you. The goal is to follow the moving cows and click on the one that moos after they have been shuffled.

Your program should be divided into two classes- the ThreeCowMonty window controller class and the Shuffler (or Moover!) active object class. The ThreeCowMonty class creates the three cows and handles the mouse interaction. The Shuffler moves the three cows, as illustrated in our demo. It selects two cows and gradually moves each of them from its original location to the opposite cow's location. Once those two cows are repositioned, it randomly selects two new cows and moves them again, repeating this process perhaps 10 or 20 times before stopping.

Handouts Describing the Exercise

Student Resources for Lab Exercise

Sample solutions