import javax.microedition.lcdui.*; import java.util.*; class Egg{ public static final int START_STATE=0; public static final int LINE_END_STATE=5; public static final int BROKEN_STATE_SHORT_FALL=8; public static final int BROKEN_STATE_LONG_FALL=10; int state=START_STATE; int oldState=START_STATE; int position; public Egg(int pos) { position=pos; } public void nextState() { oldState=state; state++; } public boolean isBroken() { return stateIsBroken(position, state); } public static boolean stateIsBroken(int tmpPosition, int tmpState) { if (tmpPosition==EggPosition.UP_LEFT || tmpPosition==EggPosition.UP_RIGHT) { return tmpState>=BROKEN_STATE_LONG_FALL; } else { return tmpState>=BROKEN_STATE_SHORT_FALL; } } public boolean isDismissed() { if (position==EggPosition.UP_LEFT || position==EggPosition.UP_RIGHT) { return state>=BROKEN_STATE_LONG_FALL+1; } else { return state>=BROKEN_STATE_SHORT_FALL+1; } } public void setDismissed() { oldState=state; if (position==EggPosition.UP_LEFT || position==EggPosition.UP_RIGHT) { state=BROKEN_STATE_LONG_FALL+1; } else { state=BROKEN_STATE_SHORT_FALL+1; } } public boolean meetsCatcher(Catcher catcher) { return catcher.position==position && state==LINE_END_STATE; } }