source: branches/easy compiler/Examples/Animal guessing game.lan

Last change on this file was 150, checked in by chronos, 6 years ago
  • Added: Load/Save example source code from/to file instead of hardcoded text in application source code.
File size: 1.2 KB
Line 
1Begin
2 Var AnimalName StringArray
3 Var AnimalProperty StringArray
4 Var AnimalCount Integer
5 Var Answer String
6 Var I Integer
7 Assign AnimalName[0] 'an elephant'
8 Assign AnimalProperty[0] 'It is big and slow'
9 Assign AnimalName[1] 'a cat'
10 Assign AnimalProperty[1] 'It meows and purrs'
11 Print 'An animal guessing game.'
12 Assign AnimalCount 2
13 Repeat
14 Begin
15 PrintLn 'Think an animal.'
16 Assign I 0
17 Repeat
18 Begin
19 Print AnimalProperty[I]
20 Print '? (y/n)'
21 InputLn Answer
22 IfEqual Answer 'y'
23 Begin
24 Print 'Thats clear. It is '
25 PrintLn AnimalName[I]
26 Break
27 End
28 Increment I 1
29 IfEqual I AnimalCount
30 Break
31 End
32 IfEqual I AnimalCount
33 Begin
34 PrintLn 'I am lost. What is the animal?'
35 InputLn AnimalName[I]
36 PrintLn 'Describe the animal for me. What it is like?'
37 InputLn AnimalProperty[I]
38 PrintLn 'Thank you. I will remember that animal.'
39 Increment AnimalCount 1
40 End
41 Print 'Do you want to play again? (y/n)'
42 InputLn Answer
43 IfNotEqual Answer 'y'
44 Break
45 PrintLn ''
46 End
47 PrintLn 'Bye'
48End
Note: See TracBrowser for help on using the repository browser.