Stepwise refinement is a low level design technique in which the programmer writes pseudo-code for what the program is supposed to do in steps, expanding non-obvious steps at each iteration of the process. Eventually, the stepwise refinement will be an almost step by step guideline to the implementation of the program.
The main objective of this assignment is to assess students ability to apply the stepwise refinement process to develop a new algorithm and carry that through to the implementation of the program. Implementation must follow the top-down design approach, where the solution starts by describing the general functionality of a program. Next, more details are provided in successive steps to refine the implementation.
You are to implement a variant of the Hangman game, where a player must find a hidden, knowing only the first letter and number of letters in the word. The player selects a letter. If the letter is part of the word, the hidden word is updated with all occurrences of the letter. All used letters must be displayed to the player.
In this variant, the player has 5 lives. Every time a letter is guess correctly the player gains a life. If a letter is guessed wrong, a life is removed. The game terminates if all lives are lost. If a player guesses a word correctly, another word is displayed, and game continues until the player chooses all words correctly or loses all lives. There is a total of 15 words which are read from a file.
Your task is to apply the technique of stepwise refinement to design an algorithm for the Hangman game.
You are provided with a function to read the words and store in a string array.
A strings individual characters can be accessed as if it was an array of characters.
string x = hello;
char y = x //stores character e in y
How to Write Step-Wise Refinement
Use a text editor (e.g., the Code::Blocks editor or Notepad) to write the first pseudo-code statement of the problem. Next, add more statements that support the implementation of that first pseudo-code statement. Each time you refine a step, copy and paste the current version of the program design to the end of the text file, then make the change within that pasted version. Stick to the instructor’s convention of using a different number of *s to indicate the level of expansion applicable to each statement (see example below). When the design is complete, the text file will contain a complete record of the design process used to reach the final design. The text file you submit may be quite lengthy and should show the entire process. Do not remove anything and do not just submit the final iteration. Below is a partial example of stepwise refinement (Note it is only a partial example and has nothing to do with the program for this assignment.):
.(this process would be continued until every statement is adequately refined using pseudo-code)
Figure 1. Initial Screen
Figure 2. Choosing Correct Letter
Figure 3. Choosing Incorrect Letter
Figure 4. Finding the Word
Figure 5. After Finding First Word
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.Read more
Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.Read more
Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.Read more
Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.Read more
By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.Read more