Answered step by step
Verified Expert Solution
Link Copied!

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

1. Make sure Milestone 1 is complete. This Milestone will not work without Milestone 1.
2. Create a class called WordMorph.
3. In this class, create a protected section with the following data members
4.Write a private function void clear_moves(). This function will set all the elements of the moves string array to a blank string
5. Write a private function void upper_case(char word[]). This function will array to its upper case equivalent. Remember the toupper(char) function takes its character parameter and it returns its upper case - this function is already available.
6.In the public section, write a function void init(string start, string end). In this function, start from a string type into a character-array type as below
1.Do the same thing as above with end_word and
end. (The c_str() function that is applied to a string variable converts the string type to a character-array type).
2. Call the upper_case() function to convert start_word and end_word separately.
3. Similar to step 1, copy start_word to last_guess. Note that start_word is already a char-array, and you don't need to call c_str() on it.
4. Call clear_moves()
5. Set round_score and actual_moves to zero
7. In the public section, create a default constructor which will set game_score, round_score and actual_moves to zero.
8. Create an overloaded constructor which will pass in two string parameters start and end. In this function, set game_score to zero. Also, call the init(.) function passing into it the start and end parameter variables.
9. Copy or move your global word_distance 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.
10. Write a function int calc_score(). This function calculates the score as 20- actual moves. (Here's how the gameplay and the scoring of the game works using the actual variables available:
1. The player attirmpts to convert a word from start_word to end_word.
2. The player starts off with a score of 20 for the round.
3. Each word played increases actual_moves.
4. Each word played is added to the moves array
5. Each word played reduces the starting value of 20. 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.
11. Write a function bool submit(string played). In this function:
1. Declare a char array guess[10]
2. Copy played into guess. Remember that guess is a char-array and played is a string. You've done similar type conversions earlier in this challenge.
3. Convert guess into upper case
4. Check the word distance between last_guess and guess. If the distance is 1, then the word submitted is valid. Therefore
1. Copy guess into last_guess. It helps to remember what the player's last guess is so we can compare it with their next guess.
2. Store their last_guess 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 actual_moves property
3. Call calc_score() and store its return value in round_score
5. This function returns true if the user's word played is valid (1 word distance). Otherwise, it returns false.
12. Write a function bool round_over(). This function returns true if the round is over. Otherwise, it returns
Write a function bool round_over(). This function returns true if the round is over. Otherwise, it returns false. The round is over when the player's last_guess is the same as end_word (The conversion/morph is complete). If the round is over, increment game_score by round_score, and reset round_score to zero. This allows multiple rounds played per game, allowing each round's score to be accumulatated into a total game score.
13. Write a getter function for the game_score data member.
14.--THIS BULLET POINT IS A SEPARATOR BETWEEN CLASSES --
15. Write a class WordMorphConsole. This class will inherit from class WordMorph.
16. Write a private function void show_moves(). This function displays the first word (start_word). 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 (end_word). Something like below is a goodway to do it.
17. In public, write a default constructor
18. 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.
19. Write an overload for the operator. In this operator function:
Display text as below (the italicized text below represents the inherited variables)
Morph start_word to end_word
GAME SCORE: game_score
Moves: actu
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning VB 2008 Databases

Authors: Vidya Vrat Agarwal, James Huddleston

1st Edition

1590599470, 978-1590599471

More Books

Students also viewed these Databases questions