Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/11/2014, 07:07
jegggf
 
Fecha de Ingreso: septiembre-2012
Ubicación: montevideo
Mensajes: 131
Antigüedad: 11 años, 7 meses
Puntos: 0
error en programita

hola ten go el siguiente codigo:

Código Java:
Ver original
  1. import java.util.Random;
  2. import java.util.Scanner;
  3. public class nadita {
  4.  
  5.     static int aciertos[]=new int[6];
  6.     static int numeros[]=new int[6];
  7.     static int persona[]=new int[6];   
  8.     boolean acierto=false;
  9.     static Random azar=new Random();
  10.     static int numazar, opcion, menus, propiedad, xdjota;
  11.    
  12.     public static void cargador(){
  13.         System.out.println("Ingrese su jugada aqui");
  14.         Scanner dato=new Scanner(System.in);
  15.         int [] perro={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48};
  16.         if (propiedad>0 && propiedad<49){
  17.         for (int y=0;y<6;y++){
  18.             persona[y]=dato.nextInt();
  19.         }
  20.         }else{
  21.             System.out.println("Supero el rango permitido");
  22.         }
  23.     }
  24.    
  25.             public static void menu(int menus, int xdjota){
  26.                 Scanner gato=new Scanner(System.in);
  27.                 System.out.println("Buenos dias. Usted esta jugando al 5 de ORO!\n 1-Ingresar jugada\n 2-Ver jugada\n 3-Salir");
  28.                 xdjota=gato.nextInt();
  29.                 do{
  30.                 switch(menus){
  31.                     case 0:
  32.                     cargador();
  33.                     break;
  34.                     case 1:
  35.                     System.out.println(" " + persona[0] + " " + persona[1] + " " + persona[2] + " " + persona[3] + " " + persona[4] + " " + persona[5]);
  36.                     break;
  37.                     }
  38.                 }while (opcion!=3);
  39.             }
  40.  
  41.             public static void  inicializar(){
  42.                 for (int r=0;r<6;r++){
  43.                 numeros[r]=0;
  44.                 }
  45.             }
  46.            
  47.            
  48.            
  49.  
  50.  
  51.             public static void random(){
  52.             for (int h=0;h<6;h++){
  53.                 numazar=azar.nextInt(48-1+1)+1;
  54.                 numeros[h]=numazar;
  55.                 System.out.println(numeros[h]);
  56.                 }
  57.             }
  58.  
  59.  
  60.             public static void comparacion(){
  61.             boolean soniguales=true;
  62.             for (int u=0;u<6 && soniguales; u++){
  63.                 if(persona[u] != numeros[u]){
  64.                     soniguales=false;
  65.                 }
  66.             }
  67.             boolean acertado=false;
  68.             if(soniguales==true){
  69.                 acertado=true;
  70.                 }else{
  71.                 acertado=false;
  72.                 }System.out.println(acertado);
  73.             }
  74.  
  75.  
  76.             public static boolean banderita(){
  77.             boolean esta=false;
  78.             for (int r=0;r<6;r++){
  79.                 if (numeros[r]==numazar){
  80.                     return true;
  81.                     }else return false;
  82.                 }
  83.                 return esta;
  84.             }
  85.  
  86.             public static void opcion(int opcion){
  87.                        
  88.             switch (opcion){
  89.                 case 1:
  90.                 if (numeros[0]==persona[0]){
  91.                     System.out.println("Usted acerto   " + aciertos + "/5"  + "ganó el pozo de oro");
  92.                 }
  93.                 break;
  94.                                
  95.                 case 2:
  96.                 if (numeros[1]==persona[1]){
  97.                     System.out.println("Usted acerto    " + aciertos + "/5" + "ganó el pozo de plata");
  98.                 }
  99.                 break;
  100.                                
  101.                 case 3:
  102.                 if (numeros[2]==persona[2]){
  103.                     System.out.println("Usted acerto   " + aciertos + "/5" + "ganó $5000");
  104.                 }
  105.                 break;
  106.                                
  107.                 case 4:
  108.                 if (numeros[3]==persona[3]){
  109.                     System.out.println("Usted acerto   " + aciertos + "/5" + "ganó $1000");
  110.                     }  
  111.                 break;
  112.                                
  113.                 case 5:
  114.                 if (numeros[4]==persona[4]){
  115.                     System.out.println("Usted acerto   " + aciertos + "/5" + "ganó $250");
  116.                     }
  117.                 break;
  118.                                
  119.                 case 6:
  120.                 if (numeros[5]==persona[5]){
  121.                     System.out.println("Usted acerto   " + aciertos + "/5" + "ganó $100");
  122.                 }
  123.                 break;
  124.                                
  125.                 case 7:
  126.                 if (numeros[6]==persona[6]){
  127.                     System.out.println("Usted acerto   " + aciertos + "/5" + "ganó el pozo revancha");
  128.                 }
  129.                 break;
  130.                                    
  131.                 case 8:
  132.                 if (numeros[7]==persona[7]){
  133.                     System.out.println("Usted no acerto ninguna bolilla");
  134.                 }
  135.                 break;
  136.                 }
  137.             }
  138.        
  139.     public static void main(String[] args){
  140.         menu(menus,xdjota);
  141.         inicializar();
  142.         cargador();
  143.         random();
  144.         banderita();
  145.         comparacion();
  146.         opcion(opcion);
  147.         }
  148. }


el error creo que esta en el cargador, se pueden introducir mas de 6 numeros cuando necesito limitarlos a 6 yque no se puedan introducir ilimitadamente.agradezco ayuda.