Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 . Make sure Milestone 1 is complete. This Milestone will not work without Milestone 1 . 2 . Create a class called WordMorph. 3
Make sure Milestone is complete. This Milestone will not work without Milestone
Create a class called WordMorph.
In this class, create a protected section with the following data members
Write a private function void clearmoves This function will set all the elements of the moves string array to a blank string
Write a private function void uppercasechar word This function will array to its upper case equivalent. Remember the toupperchar function takes its character parameter and it returns its upper case this function is already available.
In the public section, write a function void initstring start, string end In this function, start from a string type into a characterarray type as below
Do the same thing as above with endword and
end. The cstr function that is applied to a string variable converts the string type to a characterarray type
Call the uppercase function to convert startword and endword separately.
Similar to step copy startword to lastguess. Note that startword is already a chararray, and you don't need to call cstr on it
Call clearmoves
Set roundscore and actualmoves to zero
In the public section, create a default constructor which will set gamescore, roundscore and actualmoves to zero.
Create an overloaded constructor which will pass in two string parameters start and end. In this function, set gamescore to zero. Also, call the init function passing into it the start and end parameter variables.
Copy or move your global worddistance function from the global space into the public section of this class. You will have to convert it to use character arrays instead of strings.
Write a function int calcscore This function calculates the score as actual moves. Heres how the gameplay and the scoring of the game works using the actual variables available:
The player attirmpts to convert a word from startword to endword.
The player starts off with a score of for the round.
Each word played increases actualmoves.
Each word played is added to the moves array
Each word played reduces the starting value of The final score of the round is based on how many moves the player used to convert the word. Obviously, taking more moves will reduce the score more. It's best to solve the conversion in as few moves as possible.
Write a function bool submitstring played In this function:
Declare a char array guess
Copy played into guess. Remember that guess is a chararray and played is a string. You've done similar type conversions earlier in this challenge.
Convert guess into upper case
Check the word distance between lastguess and guess. If the distance is then the word submitted is valid. Therefore
Copy guess into lastguess. It helps to remember what the player's last guess is so we can compare it with their next guess.
Store their lastguess into the moves array Understand that the moves array will contain all the words played by the user in the current round. Also increment the actualmoves property
Call calcscore and store its return value in roundscore
This function returns true if the user's word played is valid word distance Otherwise, it returns false.
Write a function bool roundover This function returns true if the round is over. Otherwise, it returns
Write a function bool roundover This function returns true if the round is over. Otherwise, it returns false. The round is over when the player's lastguess is the same as endword The conversionmorph is complete If the round is over, increment gamescore by roundscore, and reset roundscore to zero. This allows multiple rounds played per game, allowing each round's score to be accumulatated into a total game score.
Write a getter function for the gamescore data member.
THIS BULLET POINT IS A SEPARATOR BETWEEN CLASSES
Write a class WordMorphConsole. This class will inherit from class WordMorph.
Write a private function void showmoves This function displays the first word startword Then it displays all the valid moves the player has used these moves are stored in the moves array. Then it displays the last word endword Something like below is a goodway to do it
In public, write a default constructor
In public, write an overloaded constructor that passes in two strings start and end. Using an initializer list, call the overloaded constructor from its parent WordMorph passing in the appropriate parameters. Remember that WordMorphConsole is a child of WordMorph.
Write an overload for the operator. In this operator function:
Display text as below the italicized text below represents the inherited variables
Morph startword to endword
GAME SCORE: gamescore
Moves: actu
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started