Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.63 KB | None | 0 0
  1. package mobileapplication6;
  2.  
  3. import java.util.Random;
  4. import javax.microedition.midlet.*;
  5. import javax.microedition.lcdui.*;
  6. /**
  7. * @author admin
  8. */
  9. public class Midlet extends MIDlet implements CommandListener{
  10.  
  11. private Form okno;
  12. private Command cmdKoniec;
  13. private Command cmdOblicz;
  14. private TextField tf1, tf2, tf3;
  15. private String[] slowka = new String[11];
  16. private String [] zgaduj= new String[11];
  17. private String[] wyswietl = new String[11];
  18. public double proby = 6;
  19. public String li = "";
  20.  
  21. public Midlet() {
  22. okno = new Form("Wisielec");
  23.  
  24. tf1 = new TextField("Szukane slowo: ", null, 50, TextField.ANY);
  25. tf2 = new TextField("Podaj litere: ", null, 1, TextField.ANY);
  26. tf3 = new TextField("Próby ", null, 50, TextField.ANY);
  27. cmdOblicz = new Command("Sprawdź", Command.ITEM, 0);
  28. cmdKoniec = new Command("Koniec", Command.ITEM, 2);
  29. okno.append(tf1);
  30. okno.append(tf2);
  31. okno.append(tf3);
  32.  
  33. slowka[0] = "i";
  34. slowka[1]="n";
  35. slowka[2]="f";
  36. slowka[3]="o";
  37. slowka[4]="r";
  38. slowka[5]="m";
  39. slowka[6]="a";
  40. slowka[7]="t";
  41. slowka[8]="y";
  42. slowka[9]="k";
  43. slowka[10]="a";
  44.  
  45. zgaduj[0]="_";
  46. zgaduj[1]="_";
  47. zgaduj[2]="_";
  48. zgaduj[3]="_";
  49. zgaduj[4]="_";
  50. zgaduj[5]="_";
  51. zgaduj[6]="_";
  52. zgaduj[7]="_";
  53. zgaduj[8]="_";
  54. zgaduj[9]="_";
  55. zgaduj[10]="_";
  56.  
  57. wyswietl[0]="_";
  58. wyswietl[1]="_";
  59. wyswietl[2]="_";
  60. wyswietl[3]="_";
  61. wyswietl[4]="_";
  62. wyswietl[5]="_";
  63. wyswietl[6]="_";
  64. wyswietl[7]="_";
  65. wyswietl[8]="_";
  66. wyswietl[9]="_";
  67. wyswietl[10]="_";
  68. tf1.setString(zgaduj[0]+" "+zgaduj[1]+" "+zgaduj[2]+" "+zgaduj[3]+" "+zgaduj[4]+" "+zgaduj[5]+" "+ zgaduj[6]+" "+zgaduj[7]+" "+zgaduj[8]+" "+zgaduj[9]+" "+zgaduj[10]);
  69. }
  70. public void startApp() {
  71. Display ekran = Display.getDisplay(this);
  72. ekran.setCurrent(okno);
  73. okno.addCommand(cmdOblicz);
  74. okno.addCommand(cmdKoniec);
  75. okno.setCommandListener(this);
  76. }
  77.  
  78. public void pauseApp() {
  79. }
  80.  
  81. public void destroyApp(boolean unconditional) {
  82. }
  83.  
  84. public void commandAction(Command cmd, Displayable s) {
  85. if (cmd == cmdOblicz) //przeliczanie temperatury
  86. {
  87. try
  88. {
  89. String b = tf2.getString();
  90. String a0 = slowka[0];
  91. String a1 = slowka[1];
  92. String a2 = slowka[2];
  93. String a3 = slowka[3];
  94. String a4 = slowka[4];
  95. String a5 = slowka[5];
  96. String a6 = slowka[6];
  97. String a7 = slowka[7];
  98. String a8 = slowka[8];
  99. String a9 = slowka[9];
  100. String a10 = slowka[10];
  101. if(a0.equals(b))
  102. {
  103. wyswietl[0]=b;
  104.  
  105. tf1.setString(wyswietl[0]+" "+wyswietl[1]+" "+wyswietl[2]+" "+wyswietl[3]+" "+wyswietl[4]+" "+wyswietl[5]+" "+wyswietl[6] + " " + wyswietl[7] + " " + wyswietl[8] + " " + wyswietl[9] + " " +wyswietl[10]);
  106.  
  107. }else if(a1.equals(b))
  108. {
  109. wyswietl[1]=b;
  110.  
  111. tf1.setString(wyswietl[0]+" "+wyswietl[1]+" "+wyswietl[2]+" "+wyswietl[3]+" "+wyswietl[4]+" "+wyswietl[5]+" "+wyswietl[6] + " " + wyswietl[7] + " " + wyswietl[8] + " " + wyswietl[9] + " " +wyswietl[10]);
  112.  
  113. }else if(a2.equals(b))
  114. {
  115. wyswietl[2]=b;
  116.  
  117. tf1.setString(wyswietl[0]+" "+wyswietl[1]+" "+wyswietl[2]+" "+wyswietl[3]+" "+wyswietl[4]+" "+wyswietl[5]+" "+wyswietl[6] + " " + wyswietl[7] + " " + wyswietl[8] + " " + wyswietl[9] + " " +wyswietl[10]);
  118.  
  119. }else if(a3.equals(b))
  120. {
  121. wyswietl[3]=b;
  122.  
  123. tf1.setString(wyswietl[0]+" "+wyswietl[1]+" "+wyswietl[2]+" "+wyswietl[3]+" "+wyswietl[4]+" "+wyswietl[5]+" "+wyswietl[6] + " " + wyswietl[7] + " " + wyswietl[8] + " " + wyswietl[9] + " " +wyswietl[10]);
  124.  
  125. }else if(a4.equals(b))
  126. {
  127. wyswietl[4]=b;
  128.  
  129. tf1.setString(wyswietl[0]+" "+wyswietl[1]+" "+wyswietl[2]+" "+wyswietl[3]+" "+wyswietl[4]+" "+wyswietl[5]+" "+wyswietl[6] + " " + wyswietl[7] + " " + wyswietl[8] + " " + wyswietl[9] + " " +wyswietl[10]);
  130.  
  131.  
  132. }else if(a5.equals(b))
  133. {
  134. wyswietl[5]=b;
  135.  
  136. tf1.setString(wyswietl[0]+" "+wyswietl[1]+" "+wyswietl[2]+" "+wyswietl[3]+" "+wyswietl[4]+" "+wyswietl[5]+" "+wyswietl[6] + " " + wyswietl[7] + " " + wyswietl[8] + " " + wyswietl[9] + " " +wyswietl[10]);
  137. }
  138. else if(a6.equals(b))
  139. {
  140. wyswietl[6]=b;
  141. tf1.setString(wyswietl[0]+" "+wyswietl[1]+" "+wyswietl[2]+" "+wyswietl[3]+" "+wyswietl[4]+" "+wyswietl[5]+" "+wyswietl[6] + " " + wyswietl[7] + " " + wyswietl[8] + " " + wyswietl[9] + " " +wyswietl[10]);
  142. }
  143. else if(a7.equals(b))
  144. {
  145. wyswietl[7]=b;
  146. tf1.setString(wyswietl[0]+" "+wyswietl[1]+" "+wyswietl[2]+" "+wyswietl[3]+" "+wyswietl[4]+" "+wyswietl[5]+" "+wyswietl[6] + " " + wyswietl[7] + " " + wyswietl[8] + " " + wyswietl[9] + " " +wyswietl[10]);
  147. }
  148. else if(a8.equals(b))
  149. {
  150. wyswietl[8]=b;
  151. tf1.setString(wyswietl[0]+" "+wyswietl[1]+" "+wyswietl[2]+" "+wyswietl[3]+" "+wyswietl[4]+" "+wyswietl[5]+" "+wyswietl[6] + " " + wyswietl[7] + " " + wyswietl[8] + " " + wyswietl[9] + " " +wyswietl[10]);
  152. }
  153. else if(a9.equals(b))
  154. {
  155. wyswietl[9]=b;
  156. tf1.setString(wyswietl[0]+" "+wyswietl[1]+" "+wyswietl[2]+" "+wyswietl[3]+" "+wyswietl[4]+" "+wyswietl[5]+" "+wyswietl[6] + " " + wyswietl[7] + " " + wyswietl[8] + " " + wyswietl[9] + " " +wyswietl[10]);
  157. }
  158. else if(a10.equals(b))
  159. {
  160. wyswietl[10]=b;
  161. tf1.setString(wyswietl[0]+" "+wyswietl[1]+" "+wyswietl[2]+" "+wyswietl[3]+" "+wyswietl[4]+" "+wyswietl[5]+" "+wyswietl[6] + " " + wyswietl[7] + " " + wyswietl[8] + " " + wyswietl[9] + " " +wyswietl[10]);
  162. }
  163. else
  164. {
  165. proby=proby-1;
  166. tf3.setString(Double.toString(proby));
  167. }
  168. }
  169.  
  170. catch (NumberFormatException e)
  171. {
  172. e.printStackTrace();
  173. }
  174. }
  175. if (cmd == cmdKoniec)
  176. {
  177. notifyDestroyed();
  178. }
  179. }
  180. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement