dunno just need help

wel I ahve a task for my school .
I have to make a game in pascal wich allous the player to chosea level (1 to 10) and number between 1 and 10. If it is level 1 he gats one chanse and so on at the end the score is calculated... plzz help me the levels wont work and the score neather
ViPAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
SimesAConnect With a Mentor Commented:
You missed off the "level" - i.e. limited guesses...


program EX5;
(*guess a number rfom 1 to 10*)

USES crt;
var
  X: integer;
  level: integer;

procedure prepare;                                          (*prepares the screen*)
begin
  //     CLRSCR;
  WRITELN;
  WRITELN('this is a game where you have to guess a number between 1 and 10');
end;

procedure chooselevel;
begin
  level := -1;
  while (level < 1) or (level > 10) do begin
    WRITELN;
    WRITE('choose level (1 to 10): ');
    READLN(level);
  end;
end;

procedure chooseX;
begin
  RANDOMIZE;
  X := random(10) + 1;
end;

procedure play;
var
  guess: integer;
  wrong: boolean;
begin
  wrong := TRUE;
  while wrong and (level > 0) do begin
    level := level - 1;
    WRITELN;
    WRITE('guess a number: ');
    READLN(guess);
    wrong := (guess <> X);
    if wrong then begin
      if level > 0 then
        WRITE('wrong try again')
      else
        WRITE('wrong, you lose!')
    end else
      WRITE('YOU WIN');
  end;
  READLN;
end;

begin
  prepare;
  chooselevel;
  chooseX;
  play;
end.
0
 
VGRCommented:
have I understood properly ?

-your game consists in guessing a 1 to 10 number
-the level is the number of tries available ?
Am I right ?
0
 
mlmccCommented:
What code have you got so far?  If no code then what are your thought on an algorithm and the data?

mlmcc
0
Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

 
ILECommented:
expalin game and i will give u a code
0
 
ViPAuthor Commented:
here I've translated it (I live in belgium).
So this is what I've got so far


PROGRAM EX5;
(*guess a number rfom 1 to 10*)

USES crt;
 VAR X :integer;
     level :integer;
     teller :byte;

PROCEDURE prepare; (*prepares the screen*)
    BEGIN
      CLRSCR;
      WRITELN;
      WRITELN ('this is a game where you have to guess a number between 1 and 10');
    END; (*prepare*)

PROCEDURE chooselevel;
BEGIN
WRITELN;
WRITE ('choose level (1to10): ');    
READLN (level);
END; (*level*)

PROCEDURE chooseX;
   BEGIN
      RANDOMIZE;
      X:=random(10)+1;                        
    END; (*toevalswaarde*)

PROCEDURE play;
    VAR guess :integer;
        wright :boolean;
        wrong  :boolean;
BEGIN
     wrong=TRUE;
    WHILE wrong DO begin
     BEGIN
      WRITELN;
      WRITE ('guess a number: ');
      READLN (guess);
      juist:=(guess=X);
      fout :=(guess<X) OR (gok>X);
      IF wright THEN BEGIN
        WRITE ('YOU WIN');
      END;
      IF wrong THEN BEGIN
        WRITE ('wrong try again');
      END;
    END;
    END;
    READLN;
END;


BEGIN  
     prepare;
     chooselevel;
     chooseX;
     play;
END.
0
 
mlmccCommented:
You aren't setting wright & wrong correctly

PROCEDURE play;
   VAR guess :integer;
       wright :boolean;
       wrong  :boolean;
BEGIN
   wrong=TRUE;
   WHILE wrong DO
    BEGIN
     WRITELN;
     WRITE ('guess a number: ');
     READLN (guess);
     IF (guess = X) THEN
       begin
         WRITE ('YOU WIN');
         wrong = false;
       END
     else
       WRITE ('wrong try again');
   END;
END;


Try that.

mlmcc
0
 
mlmccCommented:
I was just commenting and fixing his code.  Not trying to write what he hadn't tried yet.

mlmcc
0
 
mlmccCommented:
Have gotten what you needed?

mlmcc
0
 
ViPAuthor Commented:
yup I've got al the info I need. Thanks its an A+ :-D
0
 
VGRCommented:
so now please accept someone's answer 8-)
0
All Courses

From novice to tech pro — start learning today.