Mir wurde die Aufgabe gestellt , diesen Quellcode so zu verändern , dass es aussieht wie ein Schachbrett.
Kann mir bitte jemand dabei helfen , ich finde nicht raus was ich ändern muss.
Kann mir bitte jemand dabei helfen , ich finde nicht raus was ich ändern muss.
Code:
import java.applet.*;
import java.awt.*;
class ZELLe
{
int xZ, yZ;
int dZ;
boolean bLgt;
public Graphics ze;
public void zeichne()
{ ze.setColor(Color.black);
ze.drawRect(xZ*dZ,yZ*dZ,dZ,dZ);
if ( bLgt==true )
{ ze.setColor(Color.red);
ze.fillRect(xZ*dZ+3,yZ*dZ+3,dZ-6,dZ-6);
}
}
ZELLe() { bLgt=false; }
}
class FELD
{
int bZ=40;
int xmaxW=8, ymaxW=8;
boolean zUst[][] = new boolean [ymaxW+2][xmaxW+2];
void loesche()
{ for (int xx=1; xx<=xmaxW; xx++)
{ for (int yy=1; yy<=ymaxW; yy++) { zUst[yy][xx]=false; }
}
}
void starte()
{ for (int xx=1; xx<=xmaxW; xx++)
{ for (int yy=1; yy<=ymaxW; yy++)
{ if (xx%2<=1 && yy%2==1) zUst[yy][xx]=true;
}
}
}
FELD() { loesche(); starte(); }
}
public class sBrett extends Applet
{
public FELD myF = new FELD();
public ZELLe z = new ZELLe();
public void paint (Graphics git)
{ z.ze=git;
for (int xx=1; xx<=myF.ymaxW; xx++)
{ for (int yy=1; yy<=myF.xmaxW; yy++)
{ z.xZ=xx; z.yZ=yy; z.dZ=myF.bZ;
z.bLgt=myF.zUst[yy][xx];
z.zeichne();
}
}
}
}
Zuletzt bearbeitet: