Advertisement
Guest User

Forum Invaders - Java

a guest
Oct 4th, 2013
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.58 KB | None | 0 0
  1. package Game;
  2.  
  3. class Jogo {
  4.  
  5.     static boolean vitoria = false;
  6.     static boolean derrota = false;
  7.     private static boolean jogadaIncial = true;
  8.     private static int[] resultados;
  9.     private static int counter = 0;
  10.     private static int ponto;
  11.  
  12.     static void verificarResultado(int soma) {
  13.         if (soma == 7 || soma == 11) {
  14.             vitoria = true;
  15.         } else if (soma == 2 || soma == 3 || soma == 12) {
  16.             derrota = true;
  17.         } else {
  18.             if (jogadaIncial) {
  19.                 ponto = soma;
  20.                 resultados[counter++] = soma;
  21.                 jogadaIncial = false;
  22.             } else {
  23.                 resultados[counter++] = soma;
  24.  
  25.                 // Aqui irei implementar a lógica de verificação
  26.             }
  27.         }
  28.     }
  29.  
  30.     static int getPonto() {
  31.         return ponto;
  32.     }
  33.    
  34.     static boolean executar() {
  35.         return !(vitoria || derrota);
  36.     }
  37. }
  38.  
  39. class Dado {
  40.  
  41.     final int[] lado;
  42.  
  43.     Dado() {
  44.         lado = new int[6];
  45.  
  46.         for (int i = 0; i < lado.length; i++) {
  47.             lado[i] = ++i;
  48.         }
  49.     }
  50. }
  51.  
  52. class Jogador {
  53.  
  54.     final private int ponto = Jogo.getPonto();
  55.  
  56.     int jogarDados(Dado d1, Dado d2) {
  57.         return d1.lado[(int) Math.random() * ((6 - 1) + 1) + 1] + d2.lado[(int) Math.random() * ((6 - 1) + 1) + 1];
  58.     }
  59.  
  60.     void jogar(Dado d1, Dado d2) {
  61.         while (Jogo.executar()) {
  62.             Jogo.verificarResultado(jogarDados(d1, d2));
  63.         }
  64.     }
  65. }
  66.  
  67. public class Main {
  68.  
  69.     public static void main(String[] args) {
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement