A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
36
Task/Menu/Fantom/menu.fantom
Normal file
36
Task/Menu/Fantom/menu.fantom
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
class Main
|
||||
{
|
||||
static Void displayList (Str[] items)
|
||||
{
|
||||
items.each |Str item, Int index|
|
||||
{
|
||||
echo ("$index: $item")
|
||||
}
|
||||
}
|
||||
|
||||
public static Str getChoice (Str[] items)
|
||||
{
|
||||
selection := -1
|
||||
while (selection == -1)
|
||||
{
|
||||
displayList (items)
|
||||
Env.cur.out.print ("Select: ").flush
|
||||
input := Int.fromStr(Env.cur.in.readLine, 10, false)
|
||||
if (input != null)
|
||||
{
|
||||
if (input >= 0 && input < items.size)
|
||||
{
|
||||
selection = input
|
||||
}
|
||||
}
|
||||
echo ("Try again")
|
||||
}
|
||||
return items[selection]
|
||||
}
|
||||
|
||||
public static Void main ()
|
||||
{
|
||||
choice := getChoice (["fee fie", "huff and puff", "mirror mirror", "tick tock"])
|
||||
echo ("You chose: $choice")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue