home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / elan / demo / race.eln < prev    next >
Text File  |  1987-08-18  |  1KB  |  58 lines

  1.  
  2. program:
  3.   start horses;
  4.   REP
  5.     choose horse;
  6.     move horse
  7.   UNTIL finished
  8.   ENDREP;
  9.   display winner.
  10.  
  11.   start horses:
  12.     LET no of horses = 6;
  13.     LET start pos = 12;
  14.     LET end pos = 50;
  15.     ROW no of horses INT VAR horse;
  16.     display title;
  17.     INT VAR i;
  18.     FOR i FROM 1 UPTO no of horses
  19.     REP
  20.       put horse at start pos;
  21.       mark start of track;
  22.       mark end of track
  23.     ENDREP.
  24.   
  25.     display title:
  26.       cursor (end pos DIV 2, 1);
  27.       put ("H O R S E   R A C E").
  28.     
  29.     put horse at start pos:
  30.       horse [i] := start pos.
  31.     
  32.     mark start of track:
  33.       cursor (1, 2 * i + 1);
  34.       put (i);
  35.       put ("*").
  36.     
  37.     mark end of track:
  38.       cursor (end pos, 2 * i + 1);
  39.       put ("|").
  40.     
  41.   choose horse:
  42.     INT CONST ix :: random (1, no of horses).
  43.   
  44.   move horse:
  45.     cursor (horse [ix], 2 * ix + 1);
  46.     put (".*");
  47.     horse [ix] INCR 1.
  48.   
  49.   finished:
  50.     horse [ix] >= end pos.
  51.   
  52.   display winner:
  53.     cursor (start pos - 1, 2 * no of horses + 4);
  54.     put ("The winner is horse number:");
  55.     put (ix);
  56.     line (2).
  57.   
  58.