entrie not yet displayed
Hey,
I'm sorry for the crappy title, but here is what it comes down to:
my 'program' asks the names of the two players. 4 lines later the program ask this:
currentPlayer.getName()+" give move: "
the first time the name of player 1 is to be displayed 'null' appears, whereas the first time the name of player 2 is displayed correctly. Every next time the name of player one is displayed like it should...
publicclass Schaakspelextends Schaakbord{
private String naamWit ="Wit";
private String naamZwart="Zwart";
privatecharkleurAanBeurt='w';
private Schaakbord bord;
/*
* CONSTRUCTOR
*/
public Schaakspel(){
bord =new Schaakbord();
bord.reset();
}
publicvoidsetNaamWit(String n){
this.naamWit = n;
}
publicvoidsetNaamZwart(String n){
this.naamWit = n;
}
publicstaticvoid main(String[] args){
Schaakspel spel =new Schaakspel();
String naam1;
naam1 = JOptionPane.showInputDialog("Naam speler wit");
spel.setNaamWit(naam1);
String naam2;
naam2 = JOptionPane.showInputDialog("Naam speler zwart");
spel.setNaamZwart(naam2);
do{
if ( !spel.getErrorState() ){
String zetBegin;
zetBegin = JOptionPane.showInputDialog("("+spel.kleurAanBeurt+": "+spel.spelerAanBeurt+") geef zet begin:");
String zetEinde;
zetEinde = JOptionPane.showInputDialog("("+spel.kleurAanBeurt+": "+spel.spelerAanBeurt+") geef zet einde:");
spel.verwerkZet(zetBegin, zetEinde);
System.out.println();
spel.printBord();
System.out.println();
}else{
break;
}
}while ( !spel.getErrorState() );//
if ( !spel.getErrorState() )
System.err.println("\n"+spel.getMessageLog());
}
}
Suggestions?
Message was edited by:
smetje

