Spielername Abfrage hinzugefügt

master
Zocker1999NET 10 years ago
parent da6b946f07
commit e596faa7e2

@ -1,5 +1,6 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Color; import java.awt.Color;
import javax.swing.JOptionPane;
/** /**
* Write a description of class Colors here. * Write a description of class Colors here.
@ -100,44 +101,56 @@ public class Colours extends World implements ButtonEvent
if ( b == schwarz && possw == true) if ( b == schwarz && possw == true)
{ {
color[x] = sw; color[x] = sw;
pn[x]="Schwarz"; pn[x]=getName(x,"Schwarz");
x+=1; if(pn[x] != null) {
possw = false; x+=1;
possw = false;
}
} }
if (b == blau && posbl == true) if (b == blau && posbl == true)
{ {
color[x] = bl; color[x] = bl;
pn[x] = "Blau"; pn[x]=getName(x,"Blau");
x+=1; if(pn[x] != null) {
posbl = false; x+=1;
posbl = false;
}
} }
if (b == grün && posgr == true ) if (b == grün && posgr == true )
{ {
color[x] = gr; color[x] = gr;
pn[x]="Grün"; pn[x]=getName(x,"Grün");
x+=1; if(pn[x] != null) {
posgr = false; x+=1;
posgr = false;
}
} }
if ( b == rot && posrt == true) if ( b == rot && posrt == true)
{ {
color[x] = rt; color[x] = rt;
pn[x]="Rot"; pn[x]=getName(x,"Rot");
x+=1; if(pn[x] != null) {
posrt = false; x+=1;
posrt = false;
}
} }
if ( b == gelb && posgb == true) if ( b == gelb && posgb == true)
{ {
color [x] = gb; color [x] = gb;
pn[x]="Gelb"; pn[x]=getName(x,"Gelb");
x+=1; if(pn[x] != null) {
posgb = false; x+=1;
posgb = false;
}
} }
if ( b == lila && posli == true) if ( b == lila && posli == true)
{ {
color [x] = li; color [x] = li;
pn[x]="Lila"; pn[x]=getName(x,"Lila");
x+=1; if(pn[x] != null) {
posli = false; x+=1;
posli = false;
}
} }
if(b == remove && x > 0) { if(b == remove && x > 0) {
x -= 1; x -= 1;
@ -201,6 +214,14 @@ public class Colours extends World implements ButtonEvent
pl1.setText(pn[0]); pl1.setText(pn[0]);
} }
} }
private String getName(int id, String col) {
String name = JOptionPane.showInputDialog(null, "Wie soll Spieler Nr. "+id+" mit der Farbe "+col+" heißen?");
if(name == "") {
name = null;
}
return name;
}
} }

Loading…
Cancel
Save