これをプログラミングする方法に本当にこだわっています。Java drawArc メソッドを使用して、次の条件で一連の 8 つの同心円を描画する必要があります。
import java.util.Random ライブラリの使用
- 描画をランダムな位置から開始できるようにします (つまり、xy 座標をランダムに計算する必要があります)。
- 各円にランダムな色を提供する
- 各円にランダムな直径を提供する
私の現在のコードは、円ごとにランダムなランダムな色を取得できますが、他のランダムな条件を満たす方法が明確ではありません
// Exercise 12.6 Solution: CirclesJPanel.java
// This program draws concentric circles
import java.awt.Graphics;
import javax.swing.JPanel;
public class ConcentricCircles extends JPanel
{
  // draw eight Circles separated by 10 pixels
   public void paintComponent( Graphics g )
   {
      Random random = new Random();
      super.paintComponent( g );
      // create 8 concentric circles
      for ( int topLeft = 0; topLeft < 80; topLeft += 10 )
      {
         int radius = 160 - ( topLeft * 2 );
         int r = random.nextInt(255);
         int gr = random.nextInt(255);
         int b = random.nextInt(255);
         Color c = new Color(r,gr,b);
         g.setColor(c);
         g.drawArc( topLeft + 10, topLeft + 25, radius, radius, 0, 360 );
      } // end for
   }  
}
// This program draws concentric circles
import javax.swing.JFrame;
public class ConcentricCirclesTest extends JFrame {
    /**
    * @param args
    */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        JFrame frame=new JFrame("Concentric Circles");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        ConcentricCircles cCirclesJPanel = new ConcentricCircles();
        frame.add(cCirclesJPanel);
        frame.setSize(200,250);
        frame.setVisible(true);
    }//end main
}
