Ayuda con este programa

bmendezt
08 de Marzo del 2010
es sobre un juego de quinela de futbol me parece al compilar lo hace correctamente, pero a la hora de introducir los valores no me reconoce la cadena de caracteres....
los valores a introducir son 'X', '1' o '2'
a ver si alguien me puede echar una mano

Mando el programa

/**
* Class that represents a footballPoll of 15 teams
*/

public class FootballPolls { /** ERROR SINTÀCTIC: el nom de la Class FootballPollserr és
* FootballPolls
*/


final int COMBINATIONS=15;

/**
* Combination of 15 chars
*/
public char[] combination; // ERROR SINTÀCTIC: chr[] és char amb "a"
// ERROR SEMÀNTIC: ha de ser una variable tipo public



/**
* Constructor method<br>
* This method creates an instance of the footballPolls class
*/
public FootballPolls() /** ERROR SINTÀCTIC: el nom del constructor ha de ser el mateix
* que de la class
*/
{
setCombination();

}

/**
* Method that prints the winner random combination
*/

public void printCombination(){
for(int i=0;i<=COMBINATIONS;i++){
System.out.println(combination[i]); /** ERROR SINTÀCTIC: a "prin" s\'ha d\'afegir "tln"
*/

}
System.out.println(".");
}

/**
* Method that inicializes the winner random combination
*/

public void setCombination(){
int i;
combination = new char[COMBINATIONS];

for (i=0;i<COMBINATIONS;i++)
{
double num = Math.random()*3;
if (num<1) combination[i]=\'X\'; //ERROR SINTÀCTIC: la "X" va així \'X\'
else if ((num>=1) & (num<2)) combination[i]=\'1\';
else if (num>=2) combination[i]=\'2\';
}

}

/**
* Method that validatess the user combination with the combination of the football poll
* @param The user combination
*/
public void checkCombination(char[] userCombination)
{
boolean full=true;
int i;
i=1;

while((i<COMBINATIONS) && (full)) /** ERROR SEMÀNTIC: el comparar dues expressions
cadascuna ha d\'estar dintre d\'un parèntessis
*/

{
if (userCombination[i]!=combination[i]) full=false;

}
if(!full)System.out.println("Congratulations.");
else if(full){
System.out.println("Bad combination.");
}

System.out.print("The combination was: ");//ERROR SINTÀCTIC: print, s\'ha d\'afegir "ln"
printCombination();
}

/**
* Tests the methods related with all the management functions specified for the application.

*/

public static void main(String args[]) // ERROR SINTÀCTIC: argv va amb "s" en comptes de "v"

{
FootballPolls j = new FootballPolls(); /** ERROR SINTÀCTIC: en instanciar l\'objecte el nom ha de coincidir amb
el nom de la class per tant FootballPollserr és FootballPolls
*/


if (args.length==1 && args.length==15) //ERROR SINTÀCTIC: argv va amb "s" en comptes de "v"

/** ERROR SEMÀNTIC: l\'operador && avalua cada expressió
args.length==1 .... expressió1, la longitud mínima de la cadena de
caracters ha de ser =1
args.length==15....expressió2, la longitud màxima de la cadena de
caracters ha de ser =15

si es compleix, farà el mètode checkCombination sinó demanarà que
es posi un valor ja sigui \'1\', \'X\' o \'2\' */

{
j.checkCombination(args[1].toCharArray()); //ERROR SINTÀCTIC: argv va amb "s" en comptes de "v"

}
else System.out.println("usage: footballPolls <15 chars>");
}
}

kalua66
08 de Marzo del 2010
Hola bmendezt estuve mirando el código y lo probé y cambie algunas cosas(espero que no te importe).
te lo dejo para que le eches un vistazo,ami tal como lo puse me funciona.
========================================================


import java.util.Scanner;

public class pru { /** ERROR SINTÀCTIC: el nom de la Class FootballPollserr és
* FootballPolls
*/


final int COMBINATIONS=15;

/**
* Combination of 15 chars
*/
public char[] combination;
public char[] userCombination;// ERROR SINTÀCTIC: chr[] és char amb "a"
// ERROR SEMÀNTIC: ha de ser una variable tipo public



/**
* Constructor method<br>
* This method creates an instance of the footballPolls class
*/
public pru() /** ERROR SINTÀCTIC: el nom del constructor ha de ser el mateix
* que de la class
*/
{

System.out.println("Crea la combinacion ganadora");
setCombinationGanadora();


System.out.println("Crea la combinacion del usuario");
setCombination();



System.out.println("Comprueba las combinaciones");
checkCombination(userCombination);


System.out.println("fin..");
}

/**
* Method that prints the winner random combination
*/

public void printCombination(){
for(int i=0;i<COMBINATIONS;i++){
System.out.println(combination[i]); /** ERROR SINTÀCTIC: a "prin" s\'ha d\'afegir "tln"
*/

}
System.out.println("");
}

public void setCombination(){
int i;

String introducco=null;
char Caracter;
String cadenaCorreccta="12Xx";
Scanner teclado = new Scanner (System.in);
userCombination = new char[COMBINATIONS];


for (i=0;i<COMBINATIONS;i++)
{
System.out.println("Partido numero "+(i+1)+". EsCoja 1,X,2 :");
introducco=teclado.nextLine();
introducco=""+introducco.charAt(0);
introducco=introducco.toUpperCase();
Caracter=introducco.charAt(0);
int pos=cadenaCorreccta.indexOf(introducco);
while(pos==-1){
System.out.println("Has introducido un caracter no valido.Vuelve a intentarlo");
introducco=teclado.nextLine();
introducco=introducco.toUpperCase();
introducco=""+introducco.charAt(0);
Caracter=introducco.charAt(0);
pos=cadenaCorreccta.indexOf(introducco);

}
userCombination[i]=Caracter;
}

}

/**
* Method that inicializes the winner random combination
*/

public void setCombinationGanadora(){
int i;
combination = new char[COMBINATIONS];

for (i=0;i<COMBINATIONS;i++)
{

double num = Math.random()*3;
if (num<1) combination[i]='X'; //ERROR SINTÀCTIC: la "X" va així \'X\'
else if ((num>=1) & (num<2)) combination[i]='1';
else if (num>=2) combination[i]='2';
}

}

/**
* Method that validatess the user combination with the combination of the football poll
* @param The user combination
*/
public void checkCombination(char[] userCombination)
{
boolean full=true;
int i;
i=0;
System.out.println("User Combination || Combination Winner");
System.out.println("==================||=====================");
while((i<15)) /** ERROR SEMÀNTIC: el comparar dues expressions
cadascuna ha d\'estar dintre d\'un parèntessis
*/

{

if (userCombination[i]==combination[i]) {
System.out.println(" "+userCombination[i]+" || "+combination[i]+" ");

}else{
System.out.println(" "+userCombination[i]+" || "+combination[i]+" ");
full=false;
}
i++;
}
System.out.println("==================||=====================");
if(full)System.out.println("Congratulations.");
else {
System.out.println("Bad combination.");
}


}

/**
* Tests the methods related with all the management functions specified for the application.

*/

public static void main(String args[]) // ERROR SINTÀCTIC: argv va amb "s" en comptes de "v"

{
pru j = new pru(); /** ERROR SINTÀCTIC: en instanciar l\'objecte el nom ha de coincidir amb
el nom de la class per tant FootballPollserr és FootballPolls
*/


if (args.length==1 && args.length==15) //ERROR SINTÀCTIC: argv va amb "s" en comptes de "v"

/** ERROR SEMÀNTIC: l\'operador && avalua cada expressió
args.length==1 .... expressió1, la longitud mínima de la cadena de
caracters ha de ser =1
args.length==15....expressió2, la longitud màxima de la cadena de
caracters ha de ser =15

si es compleix, farà el mètode checkCombination sinó demanarà que
es posi un valor ja sigui \'1\', \'X\' o \'2\' */

{
j.checkCombination(args[1].toCharArray()); //ERROR SINTÀCTIC: argv va amb "s" en comptes de "v"

}
else System.out.println("usage: footballPolls <15 chars>");
}
}