RosettaCodeData/Task/Guess-the-number/Rascal/guess-the-number.rascal
Ingy döt Net d066446780 langs a-z
2013-04-10 22:43:41 -07:00

15 lines
497 B
Text

import vis::Render;
import vis::Figure;
import util::Math;
public void Guess(){
random = arbInt(10);
entered = "";
guess = false;
figure = box(vcat([
text("Try to guess the number from 0 to 9."),
textfield("Put your guess here", void(str s){guess = (toInt(s)==random); entered = s; }, fillColor("white")),
text(str(){return guess ? "Correct answer!" : "This is false, the number is not <entered>.";}),
button("Start over", void(){random = arbInt(10);}) ]));
render(figure);
}