For my program I am working with simple graphics and need to display a straight row of squares from left to right decreasing in size. I also have to program this recursively so that it makes the squares following the first one by itself. My problem right now is that it does not display any of the squares besides the first one. Here is my recursive method I created, and I am not sure where it is going wrong.
class Windows extends Frame
{
static Random dice = new Random();
public void paint(Graphics g)
{
drawSquare(g,0,100,200);
}
public void drawSquare(Graphics g, int x, int y, int size)
{
if(size>=1)
{
switch(dice.nextInt(8))
{
case 0: g.setColor(Color.green);
break;
case 1: g.setColor(Color.orange);
break;
case 2: g.setColor(Color.red);
break;
case 3: g.setColor(Color.blue);
break;
case 4: g.setColor(Color.yellow);
break;
case 5: g.setColor(Color.cyan);
break;
case 6: g.setColor(Color.pink);
break;
case 7: g.setColor(Color.magenta);
break;
}
g.fillRect(x,y,size,size);
x=x+size+5;
y=size*(1/4)+y;
size=size*(3/4);
drawSquare(g,x,y,size);
}
}
}