CSE 373 Winter 2005

Homework #3

Towers Game (I)

Files  Turn-in form   Mixmatcher tool

Due Dates

Mock-up: On paper at beginning of class, Monday Feb. 7  (see "Getting Started").
Files: Electronically Thursday Feb. 11 8:00 pm; paperwork at beginning of class Friday.  (Tentative: The electronic turn-in will be done by giving us a single .jar or .zip file.)  When working with a parter, only one person should do electronic turn-in, but both names should be on any papers.

Objectives

Description

The Towers of Hanoi is a famous puzzle.  For generations of data structures students it has served as an example of recursion.  You can find the puzzle explained, in our textbook on p.196, with a hint about a recursive solution.

Your task is not to implement the solution!  Rather, it is to design an interactive version of the puzzle so that a player could try to solve it manually, one move at a time.  The puzzle becomes a kind of one-player game.  The player is allowed to back up in order to try different sets of moves.  In implementing this game, you will have to choose some data structures and apply them in your program.

In order to gain a fresh perspective on testing, this project is organized in a very specific way.  You will have to follow carefully the rules about where files are located, what classes are named and what interfaces they contain, and so forth.  These limitations will eventually allow you to easily combine parts of your version of the project with missing parts written by others (including your classmates). 

Despite the restrictions, there will actually be a lot of freedom in certain respects.  In particular, the way you control the game (user inputs, etc.) and display the state (the towers, etc.) is limited only by your creativity, programming ability, and screen size (and your time, of course!).

The packaging constraints and requirements are complex enough there's a good chance these instructions will be flawed in some way and required you to revise something along the way.  Hopefully that will be minimal.

Overview

When the game runs via the supplied TowerStarter class, the user will see a window (JFrame) with two main panels. 

Structure

In addition to the View and Control, mentioned above, there is to be a third module called the Model.  The model is intended to contain all of the data structures encoding the state of the game (i.e., what disks are on what towers).  The View and the Control should not need to keep any information about the state -- when they need that, they get it from the model.
In addition, the main Model, View, and Controller classes must each contain certain static variables.  These must be present and named exactly as required:
public static final AUTHOR = ...; //Your name or nick-name for public identification purposes (<25 char.)
public static final SHORT_DESCRIPTION =  ...; //a brief (<40 char) description of your module
public static final LONG_DESCRIPTION = ...; //a longer (<300 char) description of your module.

The interfaces specify certain required public methods.  You can have as many additional methods as you wish in the Model, View, and Controller classes, but they may not be public.  You may not define any constructors except certain mandatory ones (documented in the interfaces).   Likewise, you can define additional classes within each of the three packages, but they may not be public.  You may not define anything new within mvc373Hw3. You may not define any additional packages.  You may use any standard Java 1.4 classes.

How does the program start?  There is a class called TowerStarter, which is given to you.  It is in the pacakge towerHw3.tstarter.  Its main method will create the JFrame (window), create instances of the Model, View, and Controller, and position the View and Controller (which are also panels) on the window.  Your program must operate properly when started in this way.  Don't modify TowerStarter, because you won't be allowed to turn it in.  There will probably be revised and improved versions of TowerStarter as time goes by.

A Bigger Picture

Design and program with this goal in mind: if any one of your modules (say, your View) is combined with the other two models written by someone else (say, my Controller and some stranger's Model), -- all three should work perfectly together.  This means you must program for robustness.  Make sure each of your modules works reasonably if it gets bad data or unexpected results from the other modules.

After you have begun to turn-in working versions of your modules electronically, we will make them available on the Web.  There will be a special tool to make it relatively easy to combine modules into a single program and run them together.  It's to enable this combining process that the requirements for packaging and naming are so strict.

The intention is that the modules operate without interfering with one another.  That is, they should be good neighbors.  There are ways you could mess that up -- but you shouldn't!  For example, there might be a way that the Model could hack into the Controller's panel.  This would be very unneighborly -- downright malicious, in fact.  Any modules discovered to be engaging in such activities will be removed and the project not graded.

Looking to the Future

There will be a Part II for this project, with some additional requirements.  In addition, some of the features listed above for Part I won't be checked or required until Part II.  You are free to postpone them if you feel it makes your life easier.  Here they are:

Getting Started

Turn in:

See the deadlines specified at the beginning of this page.  Paperwork (hard copy) includes printouts of the programs (the preferred way to do this is to print the "receipt" you get back from the turn-in form), plus a short report which includes:
Please staple everything together (except the confidential report).  There might not be a stapler in the classroom, so please do this in advance.  Make sure your name is on everything you turn in!  Your student ID is not needed unless we specifically request it.

MixMatcher

MixMatcher is the tool that will facilitate testing your modules by combining them with various people's modules once they are posted on the web.  Information about downloading and using the tool will be available later.

Grading

Most of the grading points will come from

Good luck and have fun!


Notes
If you have questions along the way, either about the assignment or how to do things, feel free to discuss it on the Message Board.  Just don't give away code, or any crucial aspects of the solution.

Where applicable, write your code to be reusable and modifiable.  In a later homework, you might in fact have an opportunity to reuse or modify code from this one...