-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathswitch.ss
67 lines (54 loc) · 1.69 KB
/
switch.ss
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//
// switch.ss
// Switch statement example
// Copyright 2024 Alexandre Martins <alemartf(at)gmail(dot)com>
//
object "Application"
{
state "main"
{
Console.print("The Full Name Game");
Console.print("------------------");
Console.print("I can tell you the full name of some characters.");
Console.print("Type the name of a character to know its full name or type 'x' to quit the program.");
Console.print("Known characters: Surge, Neon, Charge, Gimacian, Tux.");
for(;;) {
// read input
Console.write("> ");
input = Console.readline();
// quit the program?
if(input == "x" || input == "X")
break;
// repeat the prompt if the input is empty
if(input == "")
continue;
// print the full name and repeat the prompt
printFullName(input);
}
Console.print("Bye!");
Application.exit();
}
fun printFullName(name)
{
switch(name.toLowerCase()) {
case "surge":
Console.print("Surge the Rabbit");
break;
case "neon":
Console.print("Neon the Squirrel");
break;
case "charge":
Console.print("Charge the Badger");
break;
case "gimacian":
Console.print("Gimacian the Dark");
break;
case "tux":
Console.print("Tux the Penguin");
break;
default:
Console.print("Sorry, I don't recognize this name. Try again!");
break;
}
}
}