import inria.meije.rc.sugarcubes.Machine; import inria.meije.rc.sugarcubes.SC; import inria.meije.rc.sugarcubes.Program; // This program shows the use of stop. class Stops { public static void main(String[] args){ // First one writes a reactive program. Program print = SC.seq( SC.print("Hello World!\n"), SC.stop(), SC.seq( SC.seq(SC.print("This program\n"),SC.stop(), SC.print("displays a message\n"),SC.stop()), SC.seq(SC.print("which differs\n"),SC.stop(), SC.print("at each reactions\n"),SC.stop()), SC.seq(SC.print("It shows how to use the 'stop' and the 'seq' operators.\n"), SC.stop(), SC.print("---------------------\n"),SC.stop()), SC.seq(SC.print("Without stop\n"), SC.print("messages are displayed\n"), SC.print("during the same reaction\n"), SC.stop()) ) ); // Then one makes a reactive execution machine. Machine machine = SC.machine(); // One adds the program into the machine. machine.addProgram(print); // One makes the machine reacts for ten consecutive instants. for(int i = 1; i<=10; i++){ System.out.println("instant "+i+": "); machine.react(); } } }