/* * Created on Jan 27, 2005 */ package mvc373Hw3; import java.util.List; /** Interface for the model of a Towers of Hanoi game. * In addition to the methods listed here, concrete implementations * should have a public constructor with no arguments, e.g. * public TowerModel(); */ public interface ITowerModel { /** Start or restart the game from an initial configuration: * A number of towers (>=1), with * all of the discs are initially on tower 0. The towers are thought * of as being numbered from 0. The disks are thought of as having * sizes from 1 to discCount, and are considered to be arranged from * smallest (top) to largest (bottom) on the tower. * @param towerCount the number of towers; must be >= 1; normally this * value would be 3. * @param discCount the number of discs to start with; must be >= 1. * The disks are numbered 1 to discCount; the disk number is also its * "size" in the sense of the puzzle: a disk cannot be placed on top * of a smaller disk. * @return true if the game can be started; false otherwise. * @throws IllegalArgumentException if the number of towers is illegal. */ boolean start(int towerCount, int discCount); /** Move a disc from one tower to another. It is understood that the * topmost disk is the one moved, and it is placed in the top-most * position of the new disk. * * @param fromTower the tower from which the disk is to be moved. * Must be a valid tower number. * @param toTower the tower to which the disk is to be moved. Must be * a valid tower number. * @return true iff the move would result in a legal configuration; * in this case, the move has been carried out. A false return indicates * that no move was made. A "legal configuration" is one in which no * disk is on top of a smaller disk. * @throws IllegalArgumentException if either tower number is illegal, * or if the fromTower has no disks on it. */ boolean move(int fromTower, int toTower); /** Move to the previous configuration. * * @return true if the backup was performed; false otherwise. The only * legitimate reason for false is that the initial state had already * been reached. You do not backup past a "start" state (in case more * than one start had been done.) */ boolean backup(); /** Tell how many towers there are. * * @return the number of towers (>= 1). */ int getTowerCount(); /** Get a list of the disks on a tower, from top to bottom. * * @param tower a valid tower (always >= 0) * @return a list representing the sizes of the disks on the tower, * from top (first in the list) to bottom (last in the list). * The list may be empty but not null; * the entries are non-null Integers > 0. */ List getDiskList(int tower); }