import java.awt.*;
import java.util.Random;
import java.util.Scanner;
import javax.swing.*;
public class Assignment1 extends JFrame {
public int gridSize;
public int pattern;
public float maxRadius;
public float minRadius;
public Assignment1(){
Scanner scanner = new Scanner(System.in);
gridSize = scanner.nextInt();
do{
System.out.print("Enter pattern (1, 2, or 3): ");
pattern= scanner.nextInt();
System.out.println(pattern);
}
while(pattern < 1 || pattern >3);
maxRadius = scanner.nextFloat();
minRadius = scanner.nextFloat();
setSize(640, 480);
}
public void paintTriangle(Graphics g){
for(int i = 0; i < gridSize; i++)
for(int j = 0; j < gridSize; j++){
if((i+j)%2 == 1);
g.fillOval(i*40+100, j*40+100, (int)(maxRadius + (minRadius-maxRadius)), 40); break;
}
}
public void paintTriangle2(Graphics g){
for(int i = 0; i < gridSize; i++)
for(int j = 0; j < gridSize; j++){
if((i+j)%3 == 1);
g.fillOval(i*40+100, j*40+100, 40, 40); break;
}
}
public void paint(Graphics g){
super.paint(g);
switch(pattern){
case 1: paintTriangle(g); break;
case 2: paintTriangle2(g); break;
}
}
public static void main(String []args){
Assignment1 a = new Assignment1();
a.setVisible(true);
}
}