Follow these steps to implement the example:
- Create a class named MyPhaser and specify that it extends from the Phaser class:
public class MyPhaser extends Phaser {
- Override the onAdvance() method. According to the value of the phase attribute, we call it a different auxiliary method. If the phase attribute is equal to zero, you have to call the studentsArrived() method. If the phase is equal to one, you have to call the finishFirstExercise() method. If the phase is equal to two, you have to call the finishSecondExercise() method. Finally, if the phase is equal to three, you have to call the finishExam() method. Otherwise, return the true value to indicate that phaser has terminated:
@Override protected boolean onAdvance(int ...