diff --git a/Colours.java b/Colours.java index 61a4a98..71e997d 100644 --- a/Colours.java +++ b/Colours.java @@ -17,8 +17,8 @@ public class Colours extends World implements ButtonEvent Button lila = new Button ("Lila", 16, this); Button gelb = new Button ("Gelb", 16, this); Button weiter = new Button ("Weiter", 16, this); - int[] color = new int [6]; - String[] pn = new String [6]; + int[] color = new int [5]; + String[] pn = new String [5]; int x = 0; boolean possw = true; // schwarz boolean posbl = true; // blau @@ -40,7 +40,6 @@ public class Colours extends World implements ButtonEvent Label pl3 = new Label("",16); Label pl4 = new Label("",16); Label pl5 = new Label("",16); - Label pl6 = new Label("",16); /** * Constructor for objects of class Colors. @@ -52,7 +51,7 @@ public class Colours extends World implements ButtonEvent setBackground(Start_Load.backgroundImage); Button[] bList = new Button[] {schwarz,gelb,blau,grün,rot,lila,weiter,remove}; - Label[] lList = new Label[] {header,pl1,pl2,pl3,pl4,pl5,pl6}; + Label[] lList = new Label[] {header,pl1,pl2,pl3,pl4,pl5}; addObject(header,200,15); @@ -70,7 +69,6 @@ public class Colours extends World implements ButtonEvent addObject(pl3,355,200); addObject(pl4,355,220); addObject(pl5,355,240); - addObject(pl6,355,260); schwarz.setForeColor(Color.black); gelb.setForeColor(Color.yellow); @@ -98,58 +96,49 @@ public class Colours extends World implements ButtonEvent //der per Konstruktor die Daten der Colorklasse übertragen werden, dannach wird die Map die aktive Welt public void buttonClicked (Button b) { - if ( b == schwarz && possw == true) - { - color[x] = sw; - pn[x]=getName(x,"Schwarz"); - if(pn[x].length() > 0) { - x+=1; - possw = false; - } - } - if (b == blau && posbl == true) - { - color[x] = bl; - pn[x]=getName(x,"Blau"); - if(pn[x].length() > 0) { - x+=1; - posbl = false; - } - } - if (b == grün && posgr == true ) - { - color[x] = gr; - pn[x]=getName(x,"Grün"); - if(pn[x].length() > 0) { - x+=1; - posgr = false; - } - } - if ( b == rot && posrt == true) - { - color[x] = rt; - pn[x]=getName(x,"Rot"); - if(pn[x].length() > 0) { - x+=1; - posrt = false; - } - } - if ( b == gelb && posgb == true) - { - color [x] = gb; - pn[x]=getName(x,"Gelb"); - if(pn[x].length() > 0) { - x+=1; - posgb = false; - } - } - if ( b == lila && posli == true) - { - color [x] = li; - pn[x]=getName(x,"Lila"); - if(pn[x].length() > 0) { - x+=1; - posli = false; + if (x < 5) { + if (b == schwarz && possw == true) { + color[x] = sw; + pn[x]=getName(x,"Schwarz"); + if(pn[x].length() > 0) { + x+=1; + possw = false; + } + } else if (b == blau && posbl == true) { + color[x] = bl; + pn[x]=getName(x,"Blau"); + if(pn[x].length() > 0) { + x+=1; + posbl = false; + } + } else if (b == grün && posgr == true ) { + color[x] = gr; + pn[x]=getName(x,"Grün"); + if(pn[x].length() > 0) { + x+=1; + posgr = false; + } + } else if (b == rot && posrt == true) { + color[x] = rt; + pn[x]=getName(x,"Rot"); + if(pn[x].length() > 0) { + x+=1; + posrt = false; + } + } else if (b == gelb && posgb == true) { + color [x] = gb; + pn[x]=getName(x,"Gelb"); + if(pn[x].length() > 0) { + x+=1; + posgb = false; + } + } else if (b == lila && posli == true) { + color [x] = li; + pn[x]=getName(x,"Lila"); + if(pn[x].length() > 0) { + x+=1; + posli = false; + } } } if(b == remove && x > 0) { @@ -179,6 +168,9 @@ public class Colours extends World implements ButtonEvent } private Color getC(boolean pos) { + if(x >= 5) { + return Color.gray; + } return (pos) ? Color.lightGray : Color.gray; } @@ -193,15 +185,13 @@ public class Colours extends World implements ButtonEvent lila.setBackColor(getC(posli)); gelb.setBackColor(getC(posgb)); remove.setBackColor((x > 0) ? Color.black : Color.gray); + weiter.setBackColor((x > 2) ? Color.black : Color.gray); pl1.setText(""); pl2.setText(""); pl3.setText(""); pl4.setText(""); pl5.setText(""); - pl6.setText(""); switch(x) { - case 6: - pl6.setText(pn[5]); case 5: pl5.setText(pn[4]); case 4: diff --git a/Debug6.java b/Debug6.java deleted file mode 100644 index 8cf7a47..0000000 --- a/Debug6.java +++ /dev/null @@ -1,8 +0,0 @@ -public class Debug6 extends Map_World { - public Debug6() { - super( - new String[] {"Spieler Nr. 1", "Player No. 2", "Spieler Nr. 3", "Player No. 4", "Spieler Nr. 5", "Player No. 6"}, - new int[] {1,2,3,4,5,6} - ); - } -} \ No newline at end of file