Question: In HW 7, we will implement a program that emits sequence variants and inversions. As part of the program, we will design and test a
In HW 7, we will implement a program that emits sequence variants and inversions. As part of the program, we will design and test a class hierarchy of Sequence objects (or class hierarchy of Sequence types), including the following classes:
- Sequence : a class that encapsulates a word (at least 3 characters long), and responds to inquiries.
- Decide and document what happens if a word is less than 3 characters long.
- Decide and document your definition of state, how it's initially set, if/how it changes, etc. Determine if other states beyond "active" would facilitate the use of Sequence objects.
- Inverter : a class that based on index i and, according to state, supports the inversion of two elements (or characters) of a given sequence at indices i and i+1.
- For example, if the index '3' was encapsulated, the word marital would yield martial; likewise, if the index '1' was encapsulated, the word tarp would yield trap.
- Repeater : a class that emits a variant of the encapsulated word, repeating one or more characters. The object will only emit the variant if 'active'; otherwise, it will emit the word itself.
- For example, if the word rad is encapsulated, raad, radd, radar, etc. could be emitted.
- Extractor : a class that emits a variant (or subsequence) of the encapsulated word, if the provided subsequence is found. The object will only emit the subsequence if 'active'; otherwise, it will emit the word itself.
- For example, if the word believe is encapsulated and the subsequence beli is provided, eve would be emitted; likewise, if the word evening were encapsulated and the subsequence ning is provided, eve would be emitted.
- Decide and document what happens if (1) the provided subsequence is not found, (2) no subsequence is provided, or (3) the provided subsequence is equals to the encapsulated word.
- Variator : a class that emits a variant of the encapsulated word, either concatenating or truncating an internal subsequence. If active, the object will arbitrarily concatenate or truncate an internal subsequence; otherwise, it will emit the word itself.
- For example, if the word seesaw is encapsulated, seesawse, saseesaw, seesaws, etc., could be returned. Alternatively, see, sees, 'eesa', etc. could be returned
Class Requirements
- All of the Sequence objects may invert indices. Emitting sequence variants and inverting indices should be implemented in separate functions.
- Decide (and document) what state the object should be in to invert.
- Decide where the index i should be encapsulated and justify your design decision.
- Decide where inversion functionality should live and justify your design decision.
- The functionality of all parent types should be supported. Be sure that the Liskov Substitution principle is not violated.
- Your design should address any overlapping notions of state. Also, decide (and document) how state can change and how state can be checked by the application programmer.
- All objects must support guessing of the encapsulated word. Decide and document what happens when a word is guessed correctly.
- Several details in this assignment have been left unspecified. Clearly document all design decision you make. A reminder that class documentation should reside in the specification (.h) file. Inline comments can also be provided in the implementation (.cpp) file.
- A list of words to test your program may be found in words.dat
- Question: where should file reading occur?
- Do not throw any exceptions. Document expected use instead.
- Name your files Sequence.h, Sequence.cpp, Extractor.h, Extractor.cpp, Repeater.h, Repeater.cpp, Variator.h, Variator.cpp, Inverter.h, and hw7.cpp. No additional classes
- should be created. No implementation in .h files.
- Include a README called README.md and the words.dat file in the same directory as your C++ files.
Driver Requirements
- Design a driver to demonstrate the program requirements by clearly specifying the intent and structure of your driver. Please make a comment on what exactly you're testing, so it's obvious to the person running your program.
- Create a collection of Sequence objects to test all classes and functionality, including guessing. The collection should contain at least two instances of each object. Sufficiently test all classes and functions.
const int SIZE = 6; Sequence * seqArr[SIZE];
Hint: loop through the collection(s) and call common functionality, so that testing is streamlined.
- Test at least three words in your driver.
- The collection of Sequence objects should contain a variety of Sequence types (i.e. don't just include Extractor objects). All common functionality should be tested.
- User input should not be necessary except for the prompts shown in the sample output. How would this affect the implementation?
- If there is functionality that is not (or cannot be) tested in the collection of Sequence objects, test this functionality separately with the relevant objects.
Partial Sample Output (1)
Welcome to the Sequence tester! ---------- Testing word 1: emit: NNEIGHBORHOOD invert: NEIGHBORHOOD emit: OOD invert: NEIGHBROHOOD emit: ORHOOD invert: NEGIHBORHOOD What is your guess? NEIGHBORHOOD That's correct! ---------- Testing word 2: emit: MMEMORY invert: MEMOYR emit: EMORY invert: EMMORY emit: MEMORYORY invert: MEMOYR What is your guess? MEMORY That's correct! ---------- Testing word 3: emit: ATTEMMPT invert: ATTEPMT emit: PT invert: ATTEMTP emit: TEMPT invert: ATTEPMT What is your guess? ATTEMP That is not correct. Guess again (y/n)? y What is your guess? ATTEMPT That's correct! ---------- Testing word 4 (additional functionality): invert: COKOIES provide a subsequence: IES emit: COOK Provide another subsequence (y/n)? y provide a subsequence: CO emit: OKIES Provide another subsequence (y/n)? n What is your guess? COOKIES That's correct! Would you like to test another word (y/n)? y invert: CLAM provide a subsequence: M emit: CAL Provide another subsequence (y/n)? n What is your guess? CALM That's correct! Would you like to test another word (y/n)? n ---------- Thanks for using the Sequence tester!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
