Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package mobileapplication6;
- import java.util.Random;
- import javax.microedition.midlet.*;
- import javax.microedition.lcdui.*;
- /**
- * @author admin
- */
- public class Midlet extends MIDlet implements CommandListener{
- private Form okno;
- private Command cmdKoniec;
- private Command cmdOblicz;
- private TextField tf1, tf2, tf3;
- private String[] slowka = new String[11];
- private String [] zgaduj= new String[11];
- private String[] wyswietl = new String[11];
- public double proby = 6;
- public String li = "";
- public Midlet() {
- okno = new Form("Wisielec");
- tf1 = new TextField("Szukane slowo: ", null, 50, TextField.ANY);
- tf2 = new TextField("Podaj litere: ", null, 1, TextField.ANY);
- tf3 = new TextField("Próby ", null, 50, TextField.ANY);
- cmdOblicz = new Command("Sprawdź", Command.ITEM, 0);
- cmdKoniec = new Command("Koniec", Command.ITEM, 2);
- okno.append(tf1);
- okno.append(tf2);
- okno.append(tf3);
- slowka[0] = "i";
- slowka[1]="n";
- slowka[2]="f";
- slowka[3]="o";
- slowka[4]="r";
- slowka[5]="m";
- slowka[6]="a";
- slowka[7]="t";
- slowka[8]="y";
- slowka[9]="k";
- slowka[10]="a";
- zgaduj[0]="_";
- zgaduj[1]="_";
- zgaduj[2]="_";
- zgaduj[3]="_";
- zgaduj[4]="_";
- zgaduj[5]="_";
- zgaduj[6]="_";
- zgaduj[7]="_";
- zgaduj[8]="_";
- zgaduj[9]="_";
- zgaduj[10]="_";
- wyswietl[0]="_";
- wyswietl[1]="_";
- wyswietl[2]="_";
- wyswietl[3]="_";
- wyswietl[4]="_";
- wyswietl[5]="_";
- wyswietl[6]="_";
- wyswietl[7]="_";
- wyswietl[8]="_";
- wyswietl[9]="_";
- wyswietl[10]="_";
- tf1.setString(zgaduj[0]+" "+zgaduj[1]+" "+zgaduj[2]+" "+zgaduj[3]+" "+zgaduj[4]+" "+zgaduj[5]+" "+ zgaduj[6]+" "+zgaduj[7]+" "+zgaduj[8]+" "+zgaduj[9]+" "+zgaduj[10]);
- }
- public void startApp() {
- Display ekran = Display.getDisplay(this);
- ekran.setCurrent(okno);
- okno.addCommand(cmdOblicz);
- okno.addCommand(cmdKoniec);
- okno.setCommandListener(this);
- }
- public void pauseApp() {
- }
- public void destroyApp(boolean unconditional) {
- }
- public void commandAction(Command cmd, Displayable s) {
- if (cmd == cmdOblicz) //przeliczanie temperatury
- {
- try
- {
- String b = tf2.getString();
- String a0 = slowka[0];
- String a1 = slowka[1];
- String a2 = slowka[2];
- String a3 = slowka[3];
- String a4 = slowka[4];
- String a5 = slowka[5];
- String a6 = slowka[6];
- String a7 = slowka[7];
- String a8 = slowka[8];
- String a9 = slowka[9];
- String a10 = slowka[10];
- if(a0.equals(b))
- {
- wyswietl[0]=b;
- tf1.setString(wyswietl[0]+" "+wyswietl[1]+" "+wyswietl[2]+" "+wyswietl[3]+" "+wyswietl[4]+" "+wyswietl[5]+" "+wyswietl[6] + " " + wyswietl[7] + " " + wyswietl[8] + " " + wyswietl[9] + " " +wyswietl[10]);
- }else if(a1.equals(b))
- {
- wyswietl[1]=b;
- tf1.setString(wyswietl[0]+" "+wyswietl[1]+" "+wyswietl[2]+" "+wyswietl[3]+" "+wyswietl[4]+" "+wyswietl[5]+" "+wyswietl[6] + " " + wyswietl[7] + " " + wyswietl[8] + " " + wyswietl[9] + " " +wyswietl[10]);
- }else if(a2.equals(b))
- {
- wyswietl[2]=b;
- tf1.setString(wyswietl[0]+" "+wyswietl[1]+" "+wyswietl[2]+" "+wyswietl[3]+" "+wyswietl[4]+" "+wyswietl[5]+" "+wyswietl[6] + " " + wyswietl[7] + " " + wyswietl[8] + " " + wyswietl[9] + " " +wyswietl[10]);
- }else if(a3.equals(b))
- {
- wyswietl[3]=b;
- tf1.setString(wyswietl[0]+" "+wyswietl[1]+" "+wyswietl[2]+" "+wyswietl[3]+" "+wyswietl[4]+" "+wyswietl[5]+" "+wyswietl[6] + " " + wyswietl[7] + " " + wyswietl[8] + " " + wyswietl[9] + " " +wyswietl[10]);
- }else if(a4.equals(b))
- {
- wyswietl[4]=b;
- tf1.setString(wyswietl[0]+" "+wyswietl[1]+" "+wyswietl[2]+" "+wyswietl[3]+" "+wyswietl[4]+" "+wyswietl[5]+" "+wyswietl[6] + " " + wyswietl[7] + " " + wyswietl[8] + " " + wyswietl[9] + " " +wyswietl[10]);
- }else if(a5.equals(b))
- {
- wyswietl[5]=b;
- tf1.setString(wyswietl[0]+" "+wyswietl[1]+" "+wyswietl[2]+" "+wyswietl[3]+" "+wyswietl[4]+" "+wyswietl[5]+" "+wyswietl[6] + " " + wyswietl[7] + " " + wyswietl[8] + " " + wyswietl[9] + " " +wyswietl[10]);
- }
- else if(a6.equals(b))
- {
- wyswietl[6]=b;
- tf1.setString(wyswietl[0]+" "+wyswietl[1]+" "+wyswietl[2]+" "+wyswietl[3]+" "+wyswietl[4]+" "+wyswietl[5]+" "+wyswietl[6] + " " + wyswietl[7] + " " + wyswietl[8] + " " + wyswietl[9] + " " +wyswietl[10]);
- }
- else if(a7.equals(b))
- {
- wyswietl[7]=b;
- tf1.setString(wyswietl[0]+" "+wyswietl[1]+" "+wyswietl[2]+" "+wyswietl[3]+" "+wyswietl[4]+" "+wyswietl[5]+" "+wyswietl[6] + " " + wyswietl[7] + " " + wyswietl[8] + " " + wyswietl[9] + " " +wyswietl[10]);
- }
- else if(a8.equals(b))
- {
- wyswietl[8]=b;
- tf1.setString(wyswietl[0]+" "+wyswietl[1]+" "+wyswietl[2]+" "+wyswietl[3]+" "+wyswietl[4]+" "+wyswietl[5]+" "+wyswietl[6] + " " + wyswietl[7] + " " + wyswietl[8] + " " + wyswietl[9] + " " +wyswietl[10]);
- }
- else if(a9.equals(b))
- {
- wyswietl[9]=b;
- tf1.setString(wyswietl[0]+" "+wyswietl[1]+" "+wyswietl[2]+" "+wyswietl[3]+" "+wyswietl[4]+" "+wyswietl[5]+" "+wyswietl[6] + " " + wyswietl[7] + " " + wyswietl[8] + " " + wyswietl[9] + " " +wyswietl[10]);
- }
- else if(a10.equals(b))
- {
- wyswietl[10]=b;
- tf1.setString(wyswietl[0]+" "+wyswietl[1]+" "+wyswietl[2]+" "+wyswietl[3]+" "+wyswietl[4]+" "+wyswietl[5]+" "+wyswietl[6] + " " + wyswietl[7] + " " + wyswietl[8] + " " + wyswietl[9] + " " +wyswietl[10]);
- }
- else
- {
- proby=proby-1;
- tf3.setString(Double.toString(proby));
- }
- }
- catch (NumberFormatException e)
- {
- e.printStackTrace();
- }
- }
- if (cmd == cmdKoniec)
- {
- notifyDestroyed();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement