/**  Class Board draws a Board, fx. a chessboard.
 **  Made by Søren Munk, u001614
 **  d. 10/10-2000
 **/
import java.awt.*;
import javax.swing.*;

//  Board's construct method
public class Board extends JFrame{
 public Board() {
     setTitle("Cheesboard");
     setBackground(Color.white);
     setSize(300,300);
     setVisible(true);
 }
    
    /** draw2x2ChessBoard
     * @param x first coordinate of upper left corner of chess board
     * @param y second coordinate of upper left corner of chess board
     * @param f side length of a single field on the board
     */
    public void draw2x2ChessBoard(int x, int y, int f) {
	Graphics g = getGraphics();
	g.setColor(Color.black);
	
	//  Draws the squares on the board
	g.drawRect(x*(f*2),(y*(f*2)),f,f);
	g.drawRect((x*(f*2)),(y*(f*2))+f,f,f);    
	g.drawRect((x*(f*2))+f,(y*(f*2)),f,f);
	g.drawRect((x*(f*2))+f,(y*(f*2))+f,f,f);
	
	//  Fills the diagonal squares on the 2 by 2
	//  board.
	g.fillRect(x*(f*2),(y*(f*2))+f,f,f);
	g.fillRect((x*(f*2))+f,(y*(f*2)),f,f);
    }
    
    /** draw4x4ChessBoard
     * @param x first coordinate of upper left corner of chess board
     * @param y second coordinate of upper left corner of chess board
     * @param f side length of a single field on the board
     */ 
    public void draw4x4ChessBoard(int x, int y, int f) {
	draw2x2ChessBoard(x,y,f);
	draw2x2ChessBoard(x,(y+1),f);
	draw2x2ChessBoard((x+1),y,f);    
	draw2x2ChessBoard((x+1),(y+1),f);
    }
    
    /** draw8x8ChessBoard
     * @param x first coordinate of upper left corner of chess board
     * @param y second coordinate of upper left corner of chess board
     * @param f side length of a single field on the board
     */
    public void draw8x8ChessBoard(int x, int y, int f) {
	draw4x4ChessBoard(x,y,f);
	draw4x4ChessBoard(3*x,y,f);
	draw4x4ChessBoard(x,3*y,f);
	draw4x4ChessBoard(3*x,3*y,f);
    }
    
    //  Paint method
    public void paint(Graphics g) {
	// draw2x2ChessBoard(1,1,25);
	// draw4x4ChessBoard(1,1,25);
	draw8x8ChessBoard(1,1,25);   
    }
}
