Last active
September 4, 2017 18:31
-
-
Save jtulach/992904715978478ed14a210b734a21f5 to your computer and use it in GitHub Desktop.
Compute function matrix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h3>Your Results</h3> | |
<input type="checkbox" data-bind="checked: all"> Show all | |
<span data-bind="foreach: results"> | |
<br data-bind="visible: y() == 1"/> | |
<span data-bind="visible: $root.all() || correct()"> | |
f(<span data-bind="text:x"></span>, | |
<span data-bind="text:y"></span>) = | |
<span data-bind="text:f"></span> | |
</span> | |
</span> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package dew.demo.quiz; | |
import net.java.html.json.*; | |
@Model(className="UI", properties={ | |
@Property(name="all", type=boolean.class), | |
@Property(name="results", type=Task.class, array=true) | |
}) | |
class UICntrl { | |
static { | |
UI ui = new UI(true); | |
for (int i = 1; i <= 10; i++) { | |
for (int j = 1; j <= 10; j++) { | |
ui.getResults().add(new Task(i, j)); | |
} | |
} | |
ui.applyBindings(); | |
} | |
@Model(className="Task", properties={ | |
@Property(name="x", type=int.class), | |
@Property(name="y", type=int.class) | |
}) | |
static class TaskCntrl { | |
@ComputedProperty | |
static int f(int x, int y) { | |
return x * y - 5 ; | |
} | |
@ComputedProperty | |
static boolean correct(int x, int y) { | |
return f(x, y) == 13; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See this gist alive in a Development Environment for Web.