// Coder.h - contains a single wheel of an Enigma machine // includes reading of keyword, offset and // letter, if any, to remove from wheel #ifndef CODER_CLASS #define CODER_CLASS #include #include "Node.h" class Coder{ Node *plainFront; // points to plaintext dl Node *cipherFront; // points to cipher sll std::string keyword; // keyword int offset; // where to begin aligning plaintext with cipher public: // default constructor // initializes front Coder(); // copy constructor // makes a copy of "other" // calls copy() Coder(const Coder & other); // destructor // calls makeEmpty() ~Coder(); // explicitly defined assignment operator Coder & operator=(const Coder &); // accessor for plain front // returns pointer to plaintext front Node * getPlainFront() const; // accessor for cipher front // returns pointer to cipher front Node * getCipherFront() const; // mutator for plainFront // sets plainFront to ptr void setPlainFront(Node * ptr); // accessor for keyword // returns the keyword std::string getKeyword() const; // mutator for keyword // changes keyword to k void setKeyword(std::string k); // accessor for offset // returns the offset int getOffset() const; // mutator for offset // changes offset to p void setOffset(int p); // reads keyword (until number is detected) // reads offset (1 or 2 digits) void reader(); // strips duplicate letters out of keyword // converts all alphabetics to lowercase void stripKeyword(); // deletes all nodes in the list // THIS FUNCTION MUST BE RECURSIVE void makeEmpty(Node *); // finds the cipher letter x in the dll // returns true if letter is found // else returns false // THIS FUNCTION MUST BE RECURSIVE bool findCipher(const char x); // finds the plaintext letter x in the dll // returns true if found, else returns false // THIS FUNCTION MUST BE RECURSIVE bool findPlaintext(const char x); // locates plaintext letter x in dll // curr is pointing to Node containing x bool findPlaintext(const char x, Node *& curr); // finds plaintext letter that corresponds // to cipher letter x // curr points to Node containing plaintext corresponding to x bool findPlaintextForCipher(char x, Node *&curr); // function inserts plaintext x into dll void insert(const char x); // prints the word "plaintext:" // prints entire plaintext alphabet // alphabets are aligned // each letter is followed by one blank space void printPlain() const; // prints the word " cipher:" // prints entire cipher alphabet // alphabets are aligned void printCipher() const; // returns true if list is empty, else returns false bool isEmpty() const; // deletes the node containing plaintext character x // relinks all pointers void erase(char x); // builds plaintext beginning with letter // at "offset" in 1st Node in dll void buildWheel(); // builds cipher from stripped keyword // followed by remainder of alphabet // this is accomplished AFTER Wheel is built // and all plaintext letters are in it // also hooks up cipherRight pointers to make // cipher linked list circular void addCipherThread(); private: // initializes the data members of this class void init(); // deep copy used in copy constructor and assignment operator void copy(const Coder &); // YOU MAY INCLUDE OTHER PRIVATE FUNCTIONS HERE // YOU MAY USE HELPER FUNCTIONS FOR RECURSION }; #endif // CODER_CLASS