(* GameWithRanges.pas Copyright (c) Kari Laitinen http://www.naturalprogramming.com/ 2016-02-19 File created. 2016-02-19 Last modification. This Pascal program has been tested in Windows with a compiler downloaded from www.freepascal.org *) program Game ; uses sysutils; // for IntToString() function // It is possible to specify these ranges for numbers, but // the no runtime exceptions took place when I used larger numbers. type InputNumberRange = 0..2000 ; type WinningNumberRange = 1..2001 ; var given_integer: InputNumberRange ; winning_integer: WinningNumberRange ; begin writeln( '' ) ; writeln( ' This program is a computer game.' ) ; write( ' Please, type in an integer in range 0..2000 : ' ) ; read( given_integer ) ; winning_integer := given_integer + 1 ; writeln( '' ) ; write( ' You typed in ' + IntToStr( given_integer ) + '.' ) ; writeln( ' My number is ' + IntToStr( winning_integer ) + '.' ) ; writeln( ' Sorry. You lost. I won. The game is over.' ) ; writeln( '' ) end.