Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.applet.*;
- public class Checker extends Applet
- {
- public void paint(Graphics g)
- {
- setBackground(Color.CYAN);
- Check(g, 0, 0, 100, 5, 1);
- Check(g, 20, 150, 40, 3, 10);
- Check(g, 475, 40, 70, 4, 5);
- }
- public static void Check(Graphics g, int x, int y, int size, int b, int c)
- {
- for (int i=0; i<c; i++)
- {
- for (int j=0; j<c; j++)
- {
- drawBoard(g, x+j*size, y+i*size, size, b);
- }
- }
- }
- public static void drawBoard(Graphics g, int x, int y, int size, int b)
- {
- int n = 0;
- g.setColor(Color.DARK_GRAY);
- g.fillRect(x, y, size, size);
- g.setColor(Color.WHITE);
- for (int i=0; i<b/2; i++)
- {
- for (int a=0; a<(b/2)+(b%2); a++)
- {
- g.fillRect(x+((size/b)*a*2), y+(size/b)*i*2+(size/b), size/b, size/b);
- }
- }
- for (int i=0; i<(b/2)+(b%2); i++)
- {
- for (int a=0; a<(b/2); a++)
- {
- g.fillRect(x+((size/b)*a*2)+(size/b), y+(size/b)*i*2, size/b, size/b);
- }
- }
- g.setColor(Color.BLACK);
- g.drawRect(x, y, size, size);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement