/********* * HangmanData is a generalised class designed to hold working Hangman data about * one specific flavour. It extracts a working subset of HangmanFlavours via * HangmanFlavours.getTokenizer(int FLAV). * * The code below is meaningless unless instantiated with a particular flavour. * I expect there must be some class modifier to signify this. I'm not aware of * what this is, but it would be the antithesis of 'final' as it definitely needs * to be subclassed in a similar way that that an abstract class needs to be extended, * but I can't find a modifier to fit this situation. So maybe I've done something * unorthodox and awkward? Advice needed please. * * There is a single constructor: HangmanData(int FLAV), where FLAV is one of * the static variables of type HangmanFlavours.FLAV. This constructor would be * invoked from within the main hangman application to make similar data available * for random selection after 'play again' type requests. * * Methods are: * getNumRecords() int * getNumFields() int * getFieldName(int fieldIndex) String * getData(int recordIndex, int fieldIndex) String * getMaxLength() int (returns length of longest data string) * * All data resides within the final class HangmanFlavours. This HangmanData class * just specialises in making details of one particular flavour subset accessible to * the hangman application. Nothing new can be set here (methods are all 'gets' with * no 'sets' at all). * * Andy Murray 08/12/02 */ import java.util.*; import java.lang.*; public class HangmanData { private int intNumRecords, intMaxFields, intNumFields, recordIndex, fieldIndex; private String[][] strData; private String[] strFieldNames; // sole constructor HangmanData(int FLAV) { //find num fields intMaxFields=HangmanFlavours.getMaxFields(); strFieldNames = new String[HangmanFlavours.getMaxFields()]; intNumFields=0; for (fieldIndex=0;fieldIndex= intNumFields) { for (fieldIndex=0; fieldIndexmaxlen) ? strData[i][j].length() : maxlen; } } return maxlen; } }