F. Discussion

Discussion

 

During the creation of this code, there were a few obstacles in the way. Since none of the engineers of this project had any experience with code, the entire thing was figured out along the way. A first major problem was loading words and being able to randomly select one. This was solved after the discovery of the commands ‘importdata’ and ‘randperm’. The next problem was being able to display the blanks for the number of letters in the word. By storing the selected word as an array of letters and using the ‘length’ command to store the number of letters in the word, question marks were able to be printed for each letter in the unknown word. The final major issue discovered after testing, was that the program would add another body part to the hangman for any guess after the first one, even if the guess was correct. The problem was that the program was reading through the word and if the inputted letter didn’t match the first letter of the word, it would think it was incorrect, but still fill the correct blank with the letter. In order to fix this, the condition statement had to be split up instead of all in one. A new if statement was added for when the guess was correct, with a for loop inside to input the correct letter into the word. After this if statement, would be a separate if/elseif statement to print more body parts for each incorrect guess.