2
* Copyright (C) 2007 Jordi Mas i Hernàndez <jmas@softcatala.org>
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License as
6
* published by the Free Software Foundation; either version 2 of the
7
* License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* General Public License for more details.
14
* You should have received a copy of the GNU General Public
15
* License along with this program; if not, write to the
16
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
* Boston, MA 02111-1307, USA.
23
public class PuzzleSquares : Game
25
private double rows, columns;
28
public override string Name {
29
get {return Catalog.GetString ("Squares");}
32
public override string Question {
33
get {return Catalog.GetString ("How many squares of any size do you count in the figure below?");}
36
public override string Tip {
37
get { return Catalog.GetString ("A square is a rectangle with sides of equal length. A square can also be built from other squares.");}
40
public override string Answer {
42
string answer = base.Answer + " ";
46
answer += Catalog.GetString ("There are 16 single squares, 9 squares made by 4 single squares, 4 squares made by 9 single squares and 1 square made by 16 single squares.");
49
answer += Catalog.GetString ("There are 9 single squares, 4 squares made by 4 single squares and 1 square made by 9 single squares.");
56
public override void Initialize ()
58
if (CurrentDifficulty==Difficulty.Easy)
61
type = random.Next (2);
75
public override void Draw (CairoContextEx gr, int area_width, int area_height)
77
double rect_w = DrawAreaWidth / rows;
78
double rect_h = DrawAreaHeight / columns;
80
base.Draw (gr, area_width, area_height);
82
for (int column = 0; column < columns; column++) {
83
for (int row = 0; row < rows; row++) {
84
gr.Rectangle (DrawAreaX + row * rect_w, DrawAreaY + column * rect_h, rect_w, rect_h);