// SubStr4.h // #ifndef SUBSTR4 #define SUBSTR4 #include #include "SubStr.h" class SubStr4 : public SubStr { public: // Various constructors. SubStr4(char *val,int num); SubStr4(FILE *fin); // Read from current location. SubStr4(FILE *fin,int num); // Jump to record num and read. SubStr4(FILE *fin,char *val); // Jump to record for val and read. // This method uses the calcIndex static method. // Methods brought in from SubStr. virtual int write(FILE *fout) const; // Write to current location. virtual int writeRandom(FILE *fout) const; // Write at index. virtual void print() const; virtual int compare(const SubStr &s) const; virtual int compare(const string &s) const; virtual int getLength() const; // How many elements in the substring. virtual int getEnglish() const; // Tells if we can use it for charging. virtual void setEnglish(); // Set english member to true. virtual void clearEnglish(); // Set english member to false. virtual char operator[](int n) const; // Get an element. // Used by SubStrHandler static int maxToGen(); // How many of these there are. static void generate(FILE *fout,int num); // Produce the numth one. static int stringLength(); // returns 4. // This calculates the index from a string. static int calcIndex(char *val); private: // Don't allow default construction. SubStr4(); void read(FILE *fin); // Read the data. This is private because // the char array parto f SubStr4 is immutable. char str[4]; // Where the characters are stored. int index; // Number of this substring. Gives location in file. int english; // used as bool to tell if a substr is an english word. }; #endif