/************************************** * HangmanFlavours is a final (non-extendable) class embodying a full collection of * 'flavours' (e.g. "composers", "instruments") ready for use with constructor * new HangmanData(FLAVOUR) which extracts a single flavour. * * HangmanFlavours provides methods for getting basic info about the flavours and * the data itself, which is needed to populate a new instantiation of HangmanData. * * 2-D arrays are used for fieldnames and gueassable/clueable flags as these might * be queried before a final choice of flavour is made. But data itself only needs * to be passed as one string tokenizer as random access is only needed once the * flavour has been chosen and a new HangmanData extension is being instantiated. * * Methods: getNumFlavours() int * getFlavourName(int FLAVOUR) String * getMaxFields(int FLAVOUR) int * getFieldName(int FLAVOUR, int fieldIndex) String * getTokenizer(int FLAVOUR) StringTokenizer * isGuessable(int FLAVOUR, int fieldIndex) boolean * isClueable(int FLAVOUR, int fieldIndex) boolean * * There is now a max of 5 fields per flavour. * * Andy Murray 08/12/02 */ import java.util.StringTokenizer; public final class HangmanFlavours { static final int COMPOSERS = 0, INSTRUMENTS = 1, FORMS = 2, DEVICES = 3; private static int intNumFlavours = 4, intMaxFields = 5; private static String[] strFlavours = {"Composers & pieces", "Musical instruments", "Musical forms", "Musical devices"}; private static String[][] strFieldNames = new String[intNumFlavours][intMaxFields]; private static boolean[][] isGuessable = new boolean[intNumFlavours][intMaxFields], isClueable = new boolean[intNumFlavours][intMaxFields]; private StringTokenizer stData; // this final class needs no counstructor. /** * Method getNumFlavours() returns the number of flavours (areas of knowledge) * available in this class as an int. */ public static int getNumFlavours() { return strFlavours.length; } /** * Method getFlavourName(int) returns the name of the referenced flavour as a string. */ public static String getFlavourName(int flavourIndex) { return ((flavourIndex>-1) && (flavourIndex