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

« back to all changes in this revision

Viewing changes to src/PuzzleGames/PuzzlePeopleTable.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 System;
21
 
using Cairo;
22
 
using Mono.Unix;
23
 
 
24
 
public class PuzzlePeopleTable : Game
25
 
{
26
 
        private const double figure_size = 0.15;
27
 
        private string ques1, ques2;
28
 
        
29
 
        private class Circle
30
 
        {       
31
 
                public double x;
32
 
                public double y;
33
 
 
34
 
                public Circle (double x, double y) 
35
 
                {
36
 
                        this.x = x;
37
 
                        this.y = y;
38
 
                }
39
 
        }
40
 
 
41
 
        public override string Name {
42
 
                get {return Catalog.GetString ("People at a table");}
43
 
        }
44
 
 
45
 
        public override string Question {
46
 
                get {return String.Format (Catalog.GetString ("A group of people are sitting at round table, evenly spaced out. How many people are there if the {0} person is across from the {1}?"), ques1, ques2);} 
47
 
        }
48
 
 
49
 
        public override string Answer {
50
 
                get { 
51
 
                        string answer = base.Answer + " ";
52
 
                        answer += Catalog.GetString ("Subtracting the two positions you find out how many people are seated half way around the table. Doubling this number leaves you with the total amount of people.");
53
 
                        return answer;
54
 
                }
55
 
        }
56
 
 
57
 
        public override void Initialize ()
58
 
        {
59
 
                switch (random.Next (3)) {
60
 
                case 0:
61
 
                        ques1 = Catalog.GetString ("5th");
62
 
                        ques2 = Catalog.GetString ("19th");
63
 
                        right_answer = "28";
64
 
                        break;
65
 
                case 1:
66
 
                        ques1 = Catalog.GetString ("4th");
67
 
                        ques2 = Catalog.GetString ("12th");
68
 
                        right_answer = "16";
69
 
                        break;
70
 
                case 2:
71
 
                        ques1 = Catalog.GetString ("9th");
72
 
                        ques2 = Catalog.GetString ("22nd");
73
 
                        right_answer = "26";
74
 
                        break;
75
 
                }                       
76
 
        }
77
 
 
78
 
        public override void Draw (CairoContextEx gr, int area_width, int area_height)
79
 
        {
80
 
                double x = DrawAreaX + 0.22, y = DrawAreaY + 0.2;
81
 
                double pos_x = x;
82
 
                double pos_y = y;
83
 
                Circle[] circles = null;
84
 
 
85
 
                base.Draw (gr, area_width, area_height);
86
 
 
87
 
                circles =  new Circle [] {
88
 
                        new Circle (0.01, 0.06),
89
 
                        new Circle (0.27, 0.06),
90
 
                        new Circle (0.01, 0.21),
91
 
                        new Circle (0.27, 0.21),
92
 
                        new Circle (0.14, 0),
93
 
                        new Circle (0.14, 0.29)
94
 
                };
95
 
 
96
 
                // Circle
97
 
                gr.Arc (pos_x + figure_size, pos_y + figure_size, figure_size, 0, 2 * Math.PI);
98
 
                gr.Stroke ();           
99
 
 
100
 
                const double point_size = 0.01;
101
 
                for (int i = 0; i < circles.Length; i++) {
102
 
                        gr.Arc (x + point_size + circles[i].x, y + point_size + circles[i].y, point_size, 0, 2 * Math.PI);
103
 
                        gr.Fill ();
104
 
                        gr.Stroke ();
105
 
                }
106
 
 
107
 
                gr.MoveTo (x + circles[2].x + 0.01, y + circles[2].y + 0.01);
108
 
                gr.LineTo (x + circles[1].x + 0.01, y + circles[1].y + 0.01);
109
 
                gr.Stroke ();
110
 
        }
111
 
 
112
 
}
113
 
 
114