Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. package me.house.UTP;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Random;
  5.  
  6. public class Main {
  7. ArrayList<String> teste = new ArrayList<String>();
  8.  
  9. public static void main(String[] args) {
  10. boolean bit;
  11. while (true) {
  12.  
  13. // CRIANDO O VETOR HI
  14. ArrayList<Boolean> hi = new ArrayList<Boolean>();
  15. hi.add(true);
  16. hi.add(false);
  17.  
  18. // CRIAÇÃO DO VETOR TEMPORÁRIO
  19. ArrayList<Boolean> temp = new ArrayList<Boolean>();
  20.  
  21. // GERAÇÃO DE NÚMEROS ALEATÓRIOS
  22. Random random = new Random();
  23. bit = random.nextBoolean();
  24.  
  25. // PROCESSAMENTO
  26. int cont = 0;
  27.  
  28. if (hi.get(cont)) {
  29. // DEVE SER VERDADEIRO
  30. if (bit) {
  31. // CORRETO
  32. temp.add(bit);
  33. cont++;
  34. } else {
  35. // ERRADO
  36. if (bit == hi.get(0)) {
  37. temp.clear();
  38. temp.add(bit);
  39. cont = 1;
  40. } else {
  41. temp.clear();
  42. cont = 0;
  43. }
  44. }
  45. } else {
  46. // DEVE SER FALSO
  47. if (!(bit)) {
  48. // CORRETO
  49. temp.add(bit);
  50. cont++;
  51. } else {
  52. // ERRADO
  53. if (bit == hi.get(0)) {
  54. temp.clear();
  55. temp.add(bit);
  56. cont = 1;
  57. } else {
  58. temp.clear();
  59. cont = 0;
  60. }
  61. }
  62. }
  63.  
  64. // ESVAZIA O VETOR E PRINTA
  65. if (temp.size() == 2) {
  66. System.out.println("Yeah");
  67. temp.clear();
  68. cont = 0;
  69. }
  70. }
  71. }
  72.  
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement