1 Setup
2 Adding Characters

Lab 2 Advanced: Exploring Extensible Programming in Java

Java (and OOP in general) is highly touted for its use in writing extensible software. Class hierarchies let us add features to existing classes without editing the source code of the original classes: simply put the new features into a new class that extends the original. This lab explores how well this approach supports extensible-software construction.

For this lab to be effective, we have to simulate two aspects of real software practice:

  1. We don’t know what extensions will be required in future.

  2. Ideally, extensions can’t edit existing code. Often, you sell early versions of software and then offer upgrades or optional extensions with some sort of patch, rather than a whole new software release. Sometimes, you are creating a family of products and want to mix-and-match features.

To simulate the second, we have broken the problem description into several documents. Please don’t read ahead – it spoils the point.

To simulate the first, your answers to each new document may not edit any of your existing code (with the exception of the Examples class to add new test cases). For simplicity, you may put your new work in the same file, but you may not make any changes to existing code until we tell you otherwise. Separate your code from each stage with a commented line of dashes to visually denote the boundaries between questions.

1 Setup

You are writing a small adventure game that plays on classic fairy-tale themes: there are princes, princesses and frogs. Start with the basic class definitions in this file.

2 Adding Characters

Release software (ie, add a new dashed line). Proceed to part 2.