title: Java - Recursively alternate colors in circle
body: <p>How would I go about modifying my current code for a checker board so that the checker pieces recursively alternate in color? Just to be clear, I don't want each piece to be a solid color - I want them to have levels that alternate in color in on itself. So for example, the currently yellow pieces would change to being yellow and blue pieces, having an outer level of yellow, followed by a level of blue, then yellow, etc. I hope that makes sense? I don't believe I can highlight code, but the checker pieces start after the first nested for statement in the checkerBoard method. There are 2 cases, the first being the top 2 rows, and the second being the bottom two.</p>
  
  <pre><code>import java.awt.*;
  import java.applet.*;
  
  public class Checkerboard extends Applet 
  {    
     private final int DIST = 100;
     private final int SIZE = 1000;
  
     public void checkerBoard(int row, int col, int x, int y, boolean b, Graphics g) 
     {    
        for ( row = 0;  row &lt; 8;  row++ ) 
        {         
           for ( col = 0;  col &lt; 8;  col++) 
           {
              x = col * 100;
              y = row * 100;
              if ( (row % 2) == (col % 2) )
                 g.setColor(Color.black);
              else
                 g.setColor(Color.red);
              g.fillRect(x, y, 100, 100);
           }
        }
  
        for ( row = 0;  row &lt; 2;  row++ ) 
        {         
           for ( col = 0;  col &lt; 8;  col++) 
           {
              x = col * 100;
              y = row * 100;
              g.setColor(Color.yellow);
              g.fillOval(x, y, 100, 100);
           }
        }
  
        for ( row = 7;  row &gt; 5;  row-- ) 
        {         
           for ( col = 0;  col &lt; 8;  col++) 
           {
              x = col * 100;
              y = row * 100;
              g.setColor(Color.green);
              g.fillOval(x, y, 100, 100);
           }
        }
     }
  
     public void paint(Graphics g)
     {
      checkerBoard(0, 0, 0, 0, true, g);
     }
  }
  </code></pre>