Lab 12a Imperative Interactive Games
Game change
5.3.5

Lab 12a

Lab 12a Imperative Interactive Games

The goal of this lab is to think about the design of tests in the presence of mutation and explore how the design and testing of an interactive game changes when converted to the imperative style.

Game change

The library javalib.impworld.jar supports the design of the interactive games using imperative style (mutation). The methods onTick, onKeyEvent, onMouseClisk(Posn p), (and all other mouse handling methods) have the return type void. Each method causes the state of the game to be modified to reflect the desired changes.

The tests for the methods with effects are more difficult. We need to make sure the data we use is set up as desired, invoke the method whose effects we want to test, then run the tests (and possibly, clean up after the test).

The starter files.

Download the file Lab12a.zip and unzip it. It contains the following files:

Start a new project, import the solution in the functional style, as well as all the needed images. Add to the classpath the libraries: javalib-1.0.3.jar and tester.jar.