~ubuntu-branches/ubuntu/lucid/gbrainy/lucid

« back to all changes in this revision

Viewing changes to src/PuzzleGames/PuzzleSquares.cs

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2010-01-12 11:21:24 UTC
  • mfrom: (13.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20100112112124-o4ztomxa0xfh2ulj
Tags: 1.30-1ubuntu1
* debian/control:
  - Revert build-depends to lucid versions

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2007 Jordi Mas i Hernàndez <jmas@softcatala.org>
3
 
 *
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.
8
 
 *
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.
13
 
 *
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.
18
 
 */
19
 
 
20
 
using Cairo;
21
 
using Mono.Unix;
22
 
 
23
 
public class PuzzleSquares : Game
24
 
{
25
 
        private double rows, columns;
26
 
        private int type;
27
 
 
28
 
        public override string Name {
29
 
                get {return Catalog.GetString ("Squares");}
30
 
        }
31
 
 
32
 
        public override string Question {
33
 
                get {return Catalog.GetString ("How many squares of any size do you count in the figure below?");} 
34
 
        }
35
 
 
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.");}
38
 
        }
39
 
 
40
 
        public override string Answer {
41
 
                get { 
42
 
                        string answer = base.Answer + " ";
43
 
 
44
 
                        switch (type) {
45
 
                        case 0:
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.");
47
 
                                break;
48
 
                        case 1:
49
 
                                answer += Catalog.GetString ("There are 9 single squares, 4 squares made by 4 single squares and 1 square made by 9 single squares.");
50
 
                                break;
51
 
                        }
52
 
                        return answer;
53
 
                }
54
 
        }
55
 
 
56
 
        public override void Initialize ()
57
 
        {
58
 
                if (CurrentDifficulty==Difficulty.Easy)
59
 
                        type = 0;
60
 
                else
61
 
                        type = random.Next (2);
62
 
 
63
 
                rows = 3;
64
 
                columns = 3;            
65
 
 
66
 
                if (type == 0) {
67
 
                        rows++;
68
 
                        columns++;
69
 
                        right_answer = "30";
70
 
                } else {
71
 
                        right_answer = "14";
72
 
                }
73
 
        }
74
 
 
75
 
        public override void Draw (CairoContextEx gr, int area_width, int area_height)
76
 
        {
77
 
                double rect_w = DrawAreaWidth / rows;
78
 
                double rect_h = DrawAreaHeight / columns;
79
 
 
80
 
                base.Draw (gr, area_width, area_height);
81
 
 
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);
85
 
                        }
86
 
                }
87
 
 
88
 
                gr.Stroke ();
89
 
        }
90
 
 
91
 
}
92
 
 
93