You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Every application should extend the Task class and implement the application by overriding Task's methods. Fig. 1 shows the default method flow for a task.
Fig. 1. Default method flow and time points for a task.
Blow is an example application RollDice. The application simulates to roll a dice at each step. Each dice has nSide sides, and there are nDice dices. In total it conducts nDice steps in each repeat of a task.
publicclassRollDiceextendsTask {
publicIntegernSide; //Number of dice sidespublicIntegernDice; //Number of dices to rollpublicIntegersum;
publicbooleanprepTask() {
booleanrtn = nSide > 0 && nDice > 0;
returnrtn;
}
publicvoidbeforeRept() {
super.beforeRept();
sum = 0;
}
publicbooleanstep() {
booleanrtn = iStep <= nDice;
if (rtn) {
sum += (int) (rand.nextDouble() * nSide + 1);
}
returnrtn;
}
}