Hangman game - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Hangman game

MobixMobix Posts: 17Member
Can u tell me what does this line do DisplayCurrentStatus(Length(NewPhrase), GuessStatusArray)
And tell me if my comments are correct thanks

I know that this will display the current status which means running the function but what do the words inside brackets means ?





[code]
Program Hangman;

{ Skeleton Program code for the AQA COMP1 Summer 2009 examination
this code should be used in conjunction with the Preliminary materials
written by the AQA COMP1 Programmer Team
developed in the Delphi 7 (Console Mode) programming environment (PASCAL)
the DisplayMenu procedure has deliberately omitted a menu choice 3 and 4 }

{$APPTYPE CONSOLE}

uses
SysUtils,
StrUtils;

Type
TGuessStatusArray = Array[1..20] Of Char; //declares a new type of variable that counts letter from 1 to 20 of word
TLettersGuessedArray = Array[1..26] Of Char; //declares a new type of variabel that counts letter 1 to 26 of word
Var
NewPhrase : String; //new variable string
PhraseHasBeenSet : Boolean; //new variable boolean
PhraseGuessed : Boolean; //new variable boolean
Choice : Integer; //new variable integer
GuessStatusArray : TGuessStatusArray; //new variable new variable type 1
LettersGuessedArray : TLettersGuessedArray; // new variable
NextGuessedLetter : Char; //new variable char
Index : Integer; //new variable number

Procedure DisplayMenu; // new procedure that will display the menu
Begin
Writeln('__________________________________'); //WTF looks pretty
Writeln;
Writeln('1. SETTER - Makes new word/phrase'); // tells the option
Writeln;
Writeln('2. USER - Next letter guess'); //tells the options
Writeln;
Writeln('5. End'); //tells the options
Writeln;
End;




Function GetNewPhrase : String; //function for getting new phrase
Var //local variables
PhraseOK : Boolean; // creates a new boolean to check if the phrase is ok
ThisNewPhrase : String; // Variable that stores new phrase

Begin
Repeat //repeat loop
Write('Key in new phrase ...(letters and any Spaces) '); //asks the user to write new phrase
Readln(ThisNewPhrase); //reads the line and puts it into the new phrase vaariable
If Length(ThisNewPhrase) < 10 //If length of the variable is less than 10 then it
Then
Begin
PhraseOK := False; // sets the boolean to false so it asks for another one
Writeln('Not enough letters ... '); // Writes that there is not enough letters

{ possible further validation check(s) }
End
Else // if phrase is long enough
Begin
PhraseOK := True; //changes boolean to true
GetNewPhrase := ThisNewPhrase; //assign the new phrase to get newphrase variable
End;
Until PhraseOK = True; //repeats until the phrase is long enough
End;


Procedure SetUpGuessStatusArray(NewPhrase : String; //Sets up quess phrase.
Var GuessStatusArray : TGuessStatusArray); //display the variable
var
Position : Integer; //new variable that will show position of a letter
Begin
// FOR LOOP
For Position := 1 To Length(NewPhrase) // from first letter to the last letter of the phrase
Do
Begin
If NewPhrase[Position] = ' ' //if the new phrase position is a space
Then GuessStatusArray[Position] := ' ' // then make it a space
Else GuessStatusArray[Position] := '*'; // if it isnt space make it a star
End;
End;

Procedure DisplayCurrentStatus(PhraseLength : Byte;
GuessStatusArray : TGuessStatusArray);
Var
Position : Integer; // variable that will show position of a letter
Begin
// FOR LOOP
For Position := 1 To PhraseLength // from first letter to length of phrase
Do Write(GuessStatusArray[Position]); //writes quessstatus array
Writeln; //leave a blank line
End;

Function GetNextLetterGuess : Char; // gets next letter quess
Var
Position : Integer;
GuessedLetter : Char; //stores quessed letter as a character

Begin
Writeln; // leaves a blank line
Write('Next guess ? '); // asks for a next letter
Readln(GuessedLetter); //reades the letter
GetNextLetterGuess := GuessedLetter; // makes getnextletterquess the letter inputted
End;


Function AllLettersGuessedCorrectly(GuessStatusArray: TGuessStatusArray;
NewPhrase : String) : Boolean;
Var
Position : Integer; // counts position of a letter
MissingLetter : Boolean; // looks if its a missing letter

Begin
MissingLetter := False; // sets the missing letter to false
Position := 1; //starts from 1
Repeat
If GuessStatusArray[Position] <> NewPhrase[Position] //if the letter in quesstatus array equal to new phrase same position
Then MissingLetter := True // It changes boolean to true
Else Position := Position+1; //else it increments position
Until (MissingLetter = True) or (Position = Length(NewPhrase)+1); // Does the loop until it reaches the end of phrase or it found letter

If MissingLetter = False // if missing letter is still false
Then AllLettersGuessedCorrectly := True //then all letters quessed correctly
Else AllLettersGuessedCorrectly := False; //if it isnt false then all letters werent quessed
End;

{ Main program block starts here }
Begin
PhraseHasBeenSet := False; //starts by indicating that there is no phrase
Repeat
DisplayMenu; //shows menu
Write('Choice? '); //writes choice
Readln(Choice); //reads into variable choice

If Choice = 1 // if choice is 1 then it starts the get new phrase
Then
Begin
NewPhrase := GetNewPhrase; // new phrase will be the outcome of function get newphrase
SetUpGuessStatusArray(NewPhrase, GuessStatusArray); // start procedure
PhraseHasBeenSet := True; //the phrase has been set
End;

If Choice = 2 // begins quess code
Then
Begin
If PhraseHasBeenSet = True // if there is a new phrase then it continues to work
Then
Begin
DisplayCurrentStatus(Length(NewPhrase), GuessStatusArray);//
NextGuessedLetter := GetNextLetterGuess;
For Index := 1 To Length(NewPhrase)
Do
If NextGuessedLetter = NewPhrase[Index]
Then GuessStatusArray[Index] := NextGuessedLetter;
DisplayCurrentStatus(Length(NewPhrase), GuessStatusArray);
PhraseGuessed := AllLettersGuessedCorrectly(GuessStatusArray,NewPhrase);
If PhraseGuessed = True
Then Writeln('You have guessed correctly');
End
Else Writeln('The setter has not specified the word/phrase ..'); // if there is no phrase it asks for one
End;

If (Choice = 5) And (PhraseGuessed = False)
Then
Begin
Writeln('You have not completed this word/phrase...Press return to exit');
Readln;
End;
Until Choice = 5;

End.
[/code]
«134

Comments

  • ShadoWsaZShadoWsaZ Posts: 27Member
    Hello,

    DisplayCurrentStatus calls procedure which show hidden phrase - GuessStatusArray. Length(NewPhrase) calls function which result is length of new phrase, so procedure knows how much GuessStatusArray positions to show. However, an array of char is almost the same as a string. With string you could write a simpler version of the program.
    Second very annoying thing is that user have to choose from menu after each guess. I think it is better to make 'give up' option. And, in my opinion, if you use long variable names - frequent comments 'hide' program text from reader. Here is the other version of your program:

    [code]
    program Hangman;

    {$APPTYPE CONSOLE}

    uses
    Crt,
    SysUtils,
    StrUtils;

    const
    MaxLength = 20; // Max length of phrase
    MinLength = 10; // Min length of phrase

    type
    Phrase = string[MaxLength];

    var
    NewPhrase, // Set phrase
    HiddenPhrase: Phrase; // Partly hidden phrase
    PhraseLength: integer;
    PhraseHasBeenSet, PhraseGuessed: boolean;
    Choice, NextGuessedLetter: char;

    function GetMenuOption: char;
    begin
    Writeln('_________________________________________');
    Writeln;
    Writeln('1. SETTER - Makes new word/phrase');
    Writeln;
    Writeln('2. USER - word/phrase guess (give up - ?)');
    Writeln;
    Writeln('3. End');
    Writeln;
    GetMenuOption := ReadKey
    end;

    function GetNewPhrase: Phrase;
    { Get phrase from setter }
    var PhraseOK: boolean;
    ThisNewPhrase: Phrase;
    begin
    repeat
    write('Key in new phrase ... (letters and any spaces) ');
    Readln(ThisNewPhrase);
    PhraseOK := Length(ThisNewPhrase) >= MinLength;
    if not PhraseOK then Writeln('Not enough letters')
    until PhraseOK;
    GetNewPhrase := ThisNewPhrase
    end;

    procedure SetUpGuessStatus(NewPhrase: Phrase; PhraseLength: integer;
    var HiddenPhrase: Phrase);
    { To create hidden phrase }
    var i: integer;
    begin
    HiddenPhrase := '';
    for i := 1 to PhraseLength do
    if NewPhrase[i] = ' '
    then HiddenPhrase := HiddenPhrase + ' '
    else HiddenPhrase := HiddenPhrase + '*'
    end;

    procedure RevealLetter(NextGuessedLetter: char; var HiddenPhrase: Phrase;
    NewPhrase: Phrase; PhraseLength: integer);
    var i: integer;
    begin
    for i := 1 to PhraseLength do
    if UpCase(NewPhrase[i]) = Upcase(NextGuessedLetter) then // C = c
    HiddenPhrase[i] := NewPhrase[i]
    end;

    function GetNextLetterGuess: char;
    begin
    Writeln;
    write('Next guess? '); Readln(GetNextLetterGuess)
    end;

    begin
    PhraseHasBeenSet := false;
    repeat
    Choice := GetMenuOption; // Takes choice from menu
    case Choice of
    '1': begin
    NewPhrase := GetNewPhrase; // Takes phrase from function
    PhraseLength := Length(NewPhrase);
    SetUpGuessStatus(NewPhrase, PhraseLength, HiddenPhrase);
    PhraseHasBeenSet := true;
    ClrScr // Clears screen
    end;
    '2': if PhraseHasBeenSet then
    begin
    Writeln(HiddenPhrase);
    NextGuessedLetter := GetNextLetterGuess; // Takes from function
    PhraseGuessed := false;
    While (NextGuessedLetter <> '?') and not PhraseGuessed do
    begin
    RevealLetter(NextGuessedLetter, HiddenPhrase,
    NewPhrase, PhraseLength);
    Writeln(HiddenPhrase);
    PhraseGuessed := HiddenPhrase = NewPhrase;
    if not PhraseGuessed then
    NextGuessedLetter := GetNextLetterGuess
    end;
    If PhraseGuessed
    then Writeln('Congratulations! You have guessed')
    else Writeln('Maybe you will be luckier other time :)');
    { to hide for next user }
    SetUpGuessStatus(NewPhrase, PhraseLength, HiddenPhrase)
    end
    else Writeln('The phrase has not been set')
    end
    until Choice = '3'
    end.
    [/code]
  • lcgyylcgyy Posts: 5Member
    This post has been deleted.
  • MobixMobix Posts: 17Member
    When i load your program into turbo delphi i get these errors Cannot resolve unit name CRT
    Undeclared identifier Readkey
    Undeclared identifier ClrScr

    I was looking for the way to clear screen but since ClrScr doesnt work i am stuck again;/
  • eatgrubeatgrub Posts: 1Member
    : When i load your program into turbo delphi i get these errors Cannot
    : resolve unit name CRT
    : Undeclared identifier Readkey
    : Undeclared identifier ClrScr
    :
    : I was looking for the way to clear screen but since ClrScr doesnt
    : work i am stuck again;/
    :
    i am assuming that turbo delphi is the same as Turbo pascal. the Crt needs to be changed to wincrt... below is a copy of the code for turbo pascal...


    Program Hangman;

    { Skeleton Program code for the AQA COMP1 Summer 2009 examination
    this code should be used in conjunction with the Preliminary materials
    written by the AQA COMP1 Programmer Team
    developed in the Delphi 7 (Console Mode) programming environment (PASCAL)
    the DisplayMenu procedure has deliberately omitted a menu choice 3 and 4 }

    Uses
    Wincrt;

    Type
    TGuessStatusArray = Array[1..20] Of Char;
    TLettersGuessedArray = Array[1..26] Of Char;
    Var
    NewPhrase : String;
    PhraseHasBeenSet : Boolean;
    PhraseGuessed : Boolean;
    Choice : Integer;
    GuessStatusArray : TGuessStatusArray;
    LettersGuessedArray : TLettersGuessedArray;
    NextGuessedLetter : Char;
    Index : Integer;

    Procedure DisplayMenu;
    Begin
    Writeln('__________________________________');
    Writeln;
    Writeln('1. SETTER - Makes new word/phrase');
    Writeln;
    Writeln('2. USER - Next letter guess');
    Writeln;
    Writeln('5. End');
    Writeln;
    End;




    Function GetNewPhrase : String;
    Var
    PhraseOK : Boolean;
    ThisNewPhrase : String;

    Begin
    Repeat
    Write('Key in new phrase ...(letters and any Spaces) ');
    Readln(ThisNewPhrase);
    If Length(ThisNewPhrase) < 10
    Then
    Begin
    PhraseOK := False;
    Writeln('Not enough letters ... ');
    { possible further validation check(s) }
    End
    Else
    Begin
    PhraseOK := True;
    GetNewPhrase := ThisNewPhrase;
    End;
    Until PhraseOK = True;
    End;


    Procedure SetUpGuessStatusArray(NewPhrase : String;
    Var GuessStatusArray : TGuessStatusArray);
    Var
    Position : Integer;
    Begin
    For Position := 1 To Length(NewPhrase)
    Do
    Begin
    If NewPhrase[Position] = ' '
    Then GuessStatusArray[Position] := ' '
    Else GuessStatusArray[Position] := '*';
    End;
    End;

    Procedure DisplayCurrentStatus(PhraseLength : Byte;
    GuessStatusArray : TGuessStatusArray);
    Var
    Position : Integer;
    Begin
    For Position := 1 To PhraseLength
    Do Write(GuessStatusArray[Position]);
    Writeln;
    End;

    Function GetNextLetterGuess : Char;
    Var
    Position : Integer;
    GuessedLetter : Char;

    Begin
    Writeln;
    Write('Next guess ? ');
    Readln(GuessedLetter);
    GetNextLetterGuess := GuessedLetter;
    End;


    Function AllLettersGuessedCorrectly(GuessStatusArray: TGuessStatusArray;
    NewPhrase : String) : Boolean;
    Var
    Position : Integer;
    MissingLetter : Boolean;

    Begin
    MissingLetter := False;
    Position := 1;
    Repeat
    If GuessStatusArray[Position] <> NewPhrase[Position]
    Then MissingLetter := True
    Else Position := Position+1;
    Until (MissingLetter = True) or (Position = Length(NewPhrase)+1);

    If MissingLetter = False
    Then AllLettersGuessedCorrectly := True
    Else AllLettersGuessedCorrectly := False;
    End;

    { Main program block starts here }
    Begin
    PhraseHasBeenSet := False;
    Repeat
    DisplayMenu;
    Write('Choice? ');
    Readln(Choice);

    If Choice = 1
    Then
    Begin
    NewPhrase := GetNewPhrase;
    SetUpGuessStatusArray(NewPhrase, GuessStatusArray);
    PhraseHasBeenSet := True;
    End;

    If Choice = 2
    Then
    Begin
    If PhraseHasBeenSet = True
    Then
    Begin
    DisplayCurrentStatus(Length(NewPhrase), GuessStatusArray);
    NextGuessedLetter := GetNextLetterGuess;
    For Index := 1 To Length(NewPhrase)
    Do
    If NextGuessedLetter = NewPhrase[Index]
    Then GuessStatusArray[Index] := NextGuessedLetter;
    DisplayCurrentStatus(Length(NewPhrase), GuessStatusArray);
    PhraseGuessed := AllLettersGuessedCorrectly(GuessStatusArray,NewPhrase);
    If PhraseGuessed = True
    Then Writeln('You have guessed correctly');
    End
    Else Writeln('The setter has not specified the word/phrase ..');
    End;

    If (Choice = 5) And (PhraseGuessed = False)
    Then
    Begin
    Writeln('You have not completed this word/phrase...Press return to exit');
    Readln;
    End;
    Until Choice = 5;

    End.




    anyone got ideas of what they may ask us?

    cheers matt
  • Phat NatPhat Nat Posts: 757Member
    : anyone got ideas of what they may ask us?

    Check the thread below this one (http://www.programmersheaven.com/mb/pasprog/389822/389822/need-help-urgently-plz/?S=B20000#389822)

    A couple of others have been asking the same things.
    I would suggest you work together and post a list of everthing that still needs to be added to the program to make it complete, then work through the list and finish each missing section.

    I noticed that a file MYPHRASES.TXT will be made available to you as well. Do you think they will require you to have an option to load a random line from this file and use it instead of having a second person enter the phrase? I would put that on the list unless you are sure they won't!
  • franklinferdifranklinferdi Posts: 14Member
    NO No No.. they would certainly as us to load a random line from the file.. But any one know how to do it!?
  • mayonayzmayonayz Posts: 2Member
    We may also need to show the letters that were guessed incorrectly.
    i have been trying for ages now with my classmates but we are all having no luck.
    im starting to get worried now 'cos my exam is on monday!!!
  • franklinferdifranklinferdi Posts: 14Member
    Hi Mate.. Same here.. I am really getting nervous.. I am working on it.. I think surely I will get a solution by tomoz evening..!! Be Confident!! We can do it!!!
  • MobixMobix Posts: 17Member
    This took me an hour to do :P
    it still lacks few things but oh well...
    the only thing i cant do is clear the screen since turbo delphi doesnt have clrscr command ...

    [code]program secondattempt;

    { Skeleton Program code for the AQA COMP1 Summer 2009 examination
    this code should be used in conjunction with the Preliminary materials
    written by the AQA COMP1 Programmer Team developed in the Delphi 7
    (Console Mode) programming environment (PASCAL) the DisplayMenu procedure
    has deliberately omitted a menu choice 3 and 4 }

    {$APPTYPE CONSOLE}

    uses
    SysUtils;

    Const
    myphrases = 'phrases.txt';

    type
    TGuessStatusArray = array[1..20] of char;
    TLettersGuessedArray = array[1..26] of char;

    var
    NewPhrase : string;
    PhraseHasBeenSet : Boolean;
    PhraseGuessed : Boolean;
    Choice : integer;
    GuessStatusArray : TGuessStatusArray;
    LettersGuessedArray : TLettersGuessedArray;
    NextGuessedLetter : char;
    Index : integer;
    Phraseguesse : string;
    phrases : Textfile;
    a_phrases : array[0..99] of string;
    Letters : String;
    GuessesLeft : Integer;


    procedure DisplayMenu;
    begin
    Writeln('__________________________________');
    Writeln;
    Writeln('1. SETTER - Makes new word/phrase');
    Writeln;
    Writeln('2. USER - Next letter guess');
    Writeln;
    Writeln('3. User - Whole phrase guess');
    Writeln;
    Writeln('4. User - Set a random phras');
    Writeln;
    Writeln('5. End');
    Writeln;
    end;

    function GetNewPhrase : string;
    var
    PhraseOK : Boolean;
    ThisNewPhrase : string;
    begin
    repeat
    Write('Key in new phrase ...(letters and any Spaces) ');
    Readln(ThisNewPhrase);

    if Length(ThisNewPhrase) < 10 then
    begin
    PhraseOK := False;
    Writeln('Not enough letters ... ');
    { possible further validation check(s) }
    end else
    if length(thisnewphrase) > 20 then
    begin
    PhraseOK := False;
    Writeln('Too many letters ... ');
    end else

    begin
    PhraseOK := True;
    GetNewPhrase := Uppercase(ThisNewPhrase);
    Letters := 'abcdefghijklmnopqrstuvwxyz';
    Guessesleft := 10;
    end;
    until PhraseOK = True;
    end;

    function GetRandomPhrase : string;
    var
    PhraseOK : Boolean;
    ThisNewPhrase : string;
    i_phrases : integer;
    begin
    AssignFile(phrases, myphrases);
    Reset(phrases);


    i_phrases := 0;
    While not EOF(phrases)do
    begin
    Readln(phrases, a_phrases[i_phrases]);
    inc(i_phrases);
    end;

    Closefile(phrases);
    Repeat
    Randomize();

    Thisnewphrase := a_phrases[Random(i_phrases-1)];
    if Length(ThisNewPhrase) < 10 then
    begin
    PhraseOK := False;
    Writeln('Random phrase has not enough letters try again ... ');
    { possible further validation check(s) }
    end else
    if length(thisnewphrase) > 20 then
    begin
    PhraseOK := False;
    Writeln('Random phrase has got too many letters ... ');
    end else
    begin
    PhraseOK := True;
    GetrandomPhrase := Uppercase(ThisNewPhrase);
    Letters := 'abcdefghijklmnopqrstuvwxyz';
    Guessesleft := 10;
    end;
    until PhraseOK = True;
    end;

    procedure SetUpGuessStatusArray(NewPhrase : string; var GuessStatusArray : TGuessStatusArray);
    var
    Position : integer;
    begin
    for Position := 1 to Length(NewPhrase) do
    begin
    if NewPhrase[Position] = ' ' then
    GuessStatusArray[Position] := ' '
    else
    GuessStatusArray[Position] := '*';
    end;
    for position := 1 to 26 do
    Lettersguessedarray[Position] := '*';
    end;

    procedure DisplayCurrentStatus(PhraseLength : byte; GuessStatusArray : TGuessStatusArray);
    var
    Position : integer;
    begin
    for Position := 1 to PhraseLength do

    Write(GuessStatusArray[Position]);

    Writeln;
    Writeln;
    Writeln('Letters used so far');

    for Position := 1 to 26 do
    Write(Lettersguessedarray[Position]);
    writeln;
    Writeln('Guesses left ', Guessesleft);
    end;

    function GetNextLetterGuess : char;
    var
    Position : integer;
    GuessedLetter : char;
    b_letter : Boolean;

    begin

    Repeat
    Begin
    B_letter := True;
    Writeln;
    Write('Next guess ? ');
    Readln(GuessedLetter);
    For Position := 0 to Length(Letters) do
    if GuessedLetter = Lettersguessedarray[Position] then
    begin
    Writeln('You have already used this letter ');
    Writeln;
    b_letter := False;
    end;
    end;
    Until B_letter = True ;
    GetNextLetterGuess := GuessedLetter;
    GuessesLeft := Guessesleft-1;
    end;

    function GetWholephrase : string;
    var
    Guessedphrase : string;
    begin
    Writeln;
    Write('Next guess ? ');
    Readln(guessedphrase);
    Getwholephrase := guessedphrase;
    Guessesleft := guessesleft-1;
    end;

    function AllLettersGuessedCorrectly(GuessStatusArray: TGuessStatusArray; NewPhrase : string) : Boolean;
    var
    Position : integer;
    MissingLetter : Boolean;
    begin
    MissingLetter := False;
    Position := 1;

    repeat
    if GuessStatusArray[Position] <> NewPhrase[Position] then
    MissingLetter := True
    else
    Position := Position+1;
    until (MissingLetter = True) or (Position = Length(NewPhrase)+1);

    if MissingLetter = False then
    AllLettersGuessedCorrectly := True
    else
    AllLettersGuessedCorrectly := False;
    end;

    { Main program block starts here }
    begin
    PhraseHasBeenSet := False;

    repeat
    DisplayMenu;
    Write('Choice? ');
    Readln(Choice);

    if Choice = 1 then
    begin
    NewPhrase := GetNewPhrase;
    SetUpGuessStatusArray(NewPhrase, GuessStatusArray);
    PhraseHasBeenSet := True;
    end;

    if Choice = 2 then
    Begin
    if PhraseHasBeenSet = True then
    begin
    DisplayCurrentStatus(Length(NewPhrase), GuessStatusArray);
    NextGuessedLetter := GetNextLetterGuess;

    for Index := 1 to Length(NewPhrase) do
    if Uppercase(NextGuessedLetter) = NewPhrase[Index] then
    GuessStatusArray[Index] := NextGuessedLetter;
    For Index := 1 to 26 do
    if nextguessedletter = Letters[Index] then
    Lettersguessedarray[Index] := Nextguessedletter;


    DisplayCurrentStatus(Length(NewPhrase), GuessStatusArray);
    PhraseGuessed := AllLettersGuessedCorrectly(GuessStatusArray,NewPhrase);

    if PhraseGuessed = True then
    Writeln('You have guessed correctly');
    end else
    Writeln('The setter has not specified the word/phrase ..');
    end;

    if choice = 3 then
    Begin
    if PhraseHasBeenSet = True then
    begin
    DisplayCurrentStatus(Length(NewPhrase), GuessStatusArray);
    Phraseguesse := Getwholephrase;

    if Uppercase(Phraseguesse) = Uppercase(NewPhrase) then
    for index := 1 to Length(newphrase) do

    GuessStatusArray[Index] := Newphrase[Index];

    DisplayCurrentStatus(Length(NewPhrase), GuessStatusArray);
    PhraseGuessed := AllLettersGuessedCorrectly(GuessStatusArray,NewPhrase);

    if PhraseGuessed = True then
    Writeln('You have guessed correctly');
    end else
    Writeln('The setter has not specified the word/phrase ..');
    end;

    if choice = 4 then
    begin
    NewPhrase := GetRandomphrase;
    SetUpGuessStatusArray(NewPhrase, GuessStatusArray);
    PhraseHasBeenSet := True;
    end;


    if (Choice = 5) And (PhraseGuessed = False) then
    begin
    Writeln('You have not completed this word/phrase...Press return to exit');
    Readln;
    end;
    until Choice = 5;
    end.[/code]
  • j_808j_808 Posts: 14Member
    Do any of you've know how to limit the guesses on the hangman game, a bit scared as well because the exam is just monday now
«134
Sign In or Register to comment.