package Program; import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class Identification extends MIDlet implements CommandListener { private Display display; private Form mainScreen; public IntProf intProf; private StringItem sLogin; private StringItem sPassword; private StringItem sInvite; private TextField login; private TextField password; private Command exitButton; private Command loginButton; public Identification() { display = Display.getDisplay(this); exitButton = new Command("Quitter", Command.EXIT, 1); loginButton = new Command("Loggin", Command.SCREEN, 2); } public void startApp() throws MIDletStateChangeException { createForm(this); } public int identification(String login, String password) { int i=0 ; if (login.equals("prof") & password.equals("prof")) { i = 2; } if (login.equals("etud") & password.equals("etud")) { i = 1; } if (login.equals("admin") & password.equals("admin")) { i = 3; } if (login.equals("invite") & password.equals("")) { i = 0; } return i; } public void pauseApp() { } public void destroyApp(boolean unconditional) { notifyDestroyed(); } public void commandAction (Command command, Displayable displayable) { if (command == exitButton) { destroyApp(false); notifyDestroyed(); } if (command == loginButton) { int i = identification(login.getString(), password.getString()); if (i == 2 ) { if (displayable == this.mainScreen) { intProf = new IntProf(); try { intProf.startApp(); } catch (MIDletStateChangeException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } } public void runTest(final Identification ref) { } public void createForm(final Identification ref) { display = Display.getDisplay(this); mainScreen= new Form("Identification"); sLogin = new StringItem(null, "Login"); sPassword = new StringItem(null, "Password"); sInvite = new StringItem(null,"Si vous n'avez pas de login, tapez 'inviter'"); login = new TextField("", "", 20, 0); password = new TextField("", "", 20, 0); mainScreen.append(sLogin); mainScreen.append(login); mainScreen.append(sPassword); mainScreen.append(password); mainScreen.append(sInvite); mainScreen.addCommand(exitButton); mainScreen.addCommand(loginButton); mainScreen.setCommandListener(this); display.setCurrent(mainScreen); } }