• Non ci sono risultati.

The CASE-OF-ELSE Statement

N/A
N/A
Protected

Academic year: 2021

Condividi "The CASE-OF-ELSE Statement"

Copied!
3
0
0

Testo completo

(1)

Program Program1b_Lesson5;

Uses Crt;

Label Return; {use of the goto statement is not recommended.. avoid it}

Var

SEL : Integer;

YN : Char;

Begin

Return:Clrscr;

Writeln('[1].PLAY GAME');

WRITELN('[2].LOAD GAME');

WRITELN('[3].MULTIPLAYER');

WRITELN('[4].EXIT GAME');

Writeln('note: Do not press anything except');

Writeln('numbers; otherwise an error occurs!');

Readln(SEL);

Case SEL of 1 : Begin

Writeln('You will soon be able to create');

Writeln('games using Pascal Programming :-)');

Delay(2000);

Goto Return;

End;

2 : Begin

Writeln('Ahhh... no saved games');

Delay(2000);

Goto Return;

End;

3 : Begin

Writeln('networking or 2 players?');

Delay(2000);

Goto Return;

End;

4 : Begin

(2)

Writeln('Exit?');

N := Readkey;

Case YN of {a sort of a nested case statement}

'y' : Begin

Writeln('Good Bye...');

Delay(1000);

Halt;

End;

'n' : Goto Return;

End; {End Case 2}

End; {Close Conditional Expression 4}

End; {End Case 1}

End.

(3)

The CASE-OF-ELSE Statement

Again this is similar to the if..then..else statement. Study the program below to learn how to use the 'else' term following the 'case statement':

Program Program2_Lesson5;

Uses Crt;

Label Return; { avoid it } Var YN : Char;

Begin

Return: ClrScr;

Writeln('Exiting?');

YN := Readkey;

Case YN of

'y' : Halt;

'n' : Begin

Writeln('What are you going to do here, anyway?');

Delay(2000);

Halt;

End;

Else Begin

Writeln('Press either ''y'' for yes');

Writeln('or ''n'' for no.. please try again..');

Delay(3500);

ClrScr;

Goto Return;

End;

End; {CASE}

End. {PROGRAM}

Riferimenti

Documenti correlati

Introduction thus fractional control parameters in the model equation generalizes considered into the third chapter hereditarity nonlinear oscillator based on stick-slip e ffects

The first we consider the problem in the case when the nonstationary transfer of Rn occurs in a homogeneous layer of porous ground with infinite power..

Certainly it can be assumed that all students participating in the IChO have at least modest experience with safety laboratory procedures. However, it is the responsibility of

We consider a class of parabolic equations with critical electromagnetic potentials, for which we obtain a classification of local asymptotics, unique continuation results, and

By combining a parabolic Almgren type monotonicity formula with blow-up methods, we evaluate the exact behavior near the singularity of solutions to linear and subcritical

Specifically, a large part of the international literature has begun to focus the attention towards the relationship between some mechanisms of corporate governance and the

This relation will be analyzed within the agency theory theoretical framework (Jensen and Meckling, 1976; Fama, 1980; Fama and Jensen, 1983a; Eisenhart, 1989; Demsky, 2003) and

In the first part of this paper we generalize Brylinski’s result in order to encompass this variant of the Radon transform, and also to treat arbitrary quasi-coherent D-modules, as