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.
24
public class PuzzlePeopleTable : Game
26
private const double figure_size = 0.15;
27
private string ques1, ques2;
34
public Circle (double x, double y)
41
public override string Name {
42
get {return Catalog.GetString ("People at a table");}
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);}
49
public override string Answer {
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.");
57
public override void Initialize ()
59
switch (random.Next (3)) {
61
ques1 = Catalog.GetString ("5th");
62
ques2 = Catalog.GetString ("19th");
66
ques1 = Catalog.GetString ("4th");
67
ques2 = Catalog.GetString ("12th");
71
ques1 = Catalog.GetString ("9th");
72
ques2 = Catalog.GetString ("22nd");
78
public override void Draw (CairoContextEx gr, int area_width, int area_height)
80
double x = DrawAreaX + 0.22, y = DrawAreaY + 0.2;
83
Circle[] circles = null;
85
base.Draw (gr, area_width, area_height);
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),
93
new Circle (0.14, 0.29)
97
gr.Arc (pos_x + figure_size, pos_y + figure_size, figure_size, 0, 2 * Math.PI);
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);
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);