No se la causa de estos errores.
Main.java
Código
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package mypkg;
import java.util.Scanner;
import java.util.InputMismatchException;
/**
*
* @author Hunter
*/
public class Main {
/**
* @param args the command line arguments
*/
// TODO code application logic here
int[] palillos = {7,5,3};
JuegoPalillos juego;
jugador[0] = "Jugador 1";
jugador[1] = "Jugador 2";
int turno = 0;
int fila;
int cuantos;
juego = new JuegoPalillos(palillos);
do{
fila = lector.nextInt();
cuantos = lector.nextInt();
if (juego.quitaPalillos(fila.cuantos)){
turno = (turno + 1) % 2;
}else{
}
}catch (InputMismatchException e){
lector.next();
}
}while (!juego.finDeJuego());
}
JuegoPalillos.java
Código
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package mypkg;
/**
*
* @author Hunter
*/
public class JuegoPalillos {
private FilaPalillos[] filas;
public JuegoPalillos(int[] palillos){
filas = new FilaPalillos[palillos.length];
for (int i = 0; i < filas.length; i++){
filas[i] = new FilaPalillos(palillos[i]);
}
}
public boolean quitaPalillos(int fila, int cuantos){
if (fila < 0 || fila >= filas.length)
return false;
else
return filas[fila].quitaPalillos(cuantos);
}
public boolean finDeJuego(){
for (int i = 0; i < filas.length; ++i){
if(filas[i].cuantosPalillos() != 0) return false;
}
return true;
}
for (int i = 0; i < filas.length; i++){
s += i + " " + filas[i] + "\n";
}
return s;
}
}
FilaPalillos.java
Código
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package mypkg;
/**
*
* @author Hunter
*/
public class FilaPalillos {
private int numPalillos;
public FilaPalillos(int tamaño){
numPalillos = tamaño;
}
public boolean quitaPalillos(int cuantos){
if (cuantos > numPalillos){
return false;
}else{
numPalillos -= cuantos;
return true;
}
}
for (int i=0; i < numPalillos; i++){
s += "|";
}
return s;
}
public void añadePalillos(int cuantos){
numPalillos += cuantos;
}
public int cuantosPalillos(){
return numPalillos;
}
}
Quiero solucionar los errores de este programa.


 
  




 Autor
 Autor
		




 En línea
									En línea
								



