Answer to Question #10217 in Prolog for Kostas

Question #10217
% Process guess takes a list of codes representing the answer, a list of codes representing the current % "display phrase" with blanks in it, and the code of the letter that was just guessed. If the guess % was right, call substitute to put the letter in the display phrase and check for a win. Otherwise, just % get another guess from the user. processGuess(AnsList,BlankList,GuessName, CountFailed):- member(GuessName,AnsList), !, write('Correct!'), nl, substitute(AnsList, BlankList, GuessName, NewBlanks), checkWin(AnsList,NewBlanks, CountFailed). processGuess(AnsList, BlankList, _, CountFailed) :- ( CountFailed == 5 -> format('Sorry, game over. You didn\'t guess (~s)~n', [AnsList]) ; write('Wrong Try Again!'), nl, CountFailed1 is CountFailed + 1, getGuess(AnsList, BlankList, CountFailed1) ). The main idea is to make a list where i will put all the wrong letters the user gave and check it everytime he gives another wrong letter
Expert's answer
Unfortunately, your question requires a lot of work and cannot be done for free.
Submit it with all requirements as an assignment to our control panel and we'll assist you.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

New on Blog