File: type_a_number.ss

package info (click to toggle)
surgescript 0.5.4.4-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,876 kB
  • sloc: ansic: 13,674; makefile: 16
file content (28 lines) | stat: -rw-r--r-- 771 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//
// type_a_number.ss
// Type a number plaything
// Copyright 2017 Alexandre Martins <alemartf(at)gmail(dot)com>
//

object "Application"
{
    number = 0; // we declare the variable "number" here, so it
                // will be accessible throughout the whole object

    // the Application will be locked in state "main", and will 
    // only leave it if the user types a number between 1 and 9
    state "main"
    {
        Console.write("Type a number between 1 and 9: ");
        number = Number(Console.readline());
        if(number >= 1 && number <= 9)
            state = "done";
    }

    // display the typed number and exit the app
    state "done"
    {
        Console.print("Congratulations! You typed " + number);
        Application.exit();
    }
}