//import MagicSquare;

public class DoublyEvenOrderMagicSquare extends MagicSquare {

public DoublyEvenOrderMagicSquare(int startValue, int n) {

        super(startValue, n);
        for (int row=0; row<n; row++)
        {
            int modedRow = row%4;
            for (int col=0; col<n; col++)
            {
                int modedCol = col%4;
                int value;
                if ((modedRow == 0 && (modedCol == 1 || modedCol == 2)) ||
                    (modedRow == 1 && (modedCol == 0 || modedCol == 3)) ||
                    (modedRow == 2 && (modedCol == 0 || modedCol == 3)) ||
                    (modedRow == 3 && (modedCol == 1 || modedCol == 2)))
                {
                    value = startValue+row*n+col;
                }
                else
                {
                    value = startValue+(n-row)*n-col-1;
                }
                setCell(row, col, value);
            }
        }

}

public static void main(String[] args) {

        MagicSquare magicSquare;
        for (int i=1; i<3; i++)
        {
            int n = 4*i;
            System.out.println/(n+" by "+n+" magic square:");
            magicSquare = MagicSquareFactory.create(1, n);
            System.out.println/(magicSquare);
        }

}
}