import javax.microedition.midlet.*; import javax.microedition.lcdui.*; import java.util.*; public class Midlet extends MIDlet implements CommandListener { private Command exitMidlet; private Command playAgain; public void startApp() { exitMidlet = new Command("Exit", Command.EXIT, 1); playAgain = new Command("Again", Command.SCREEN, 2); Random r = new Random(); int a = r.nextInt(10); Form form = new Form(""); form.addCommand(exitMidlet); form.addCommand(playAgain); form.setCommandListener(this); form.append("Загаданное число - "+ a); Display.getDisplay(this).setCurrent(form); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } public void commandAction(Command c, Displayable d) { if(c == exitMidlet) { destroyApp(false); notifyDestroyed(); } if(c == playAgain) { Random r = new Random(); int a = r.nextInt(10); Form form = new Form(""); form.append("Загаданное число - "+ a); Display.getDisplay(this).setCurrent(form); } } }