2
* Copyright (C) 2009 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
using gbrainy.Core.Main;
25
using gbrainy.Core.Libraries;
27
namespace gbrainy.Games.Logic
29
public class PuzzleCounting : Game
39
string question, answer;
42
public override string Name {
43
get {return Catalog.GetString ("Counting");}
46
public override string Question {
47
get {return question; }
50
public override string Answer {
51
get { return base.Answer + " " + answer;}
54
public override void Initialize ()
58
gametype = (GameType) random.Next ((int) GameType.Total);
60
switch ((int) gametype)
62
case (int) GameType.Machine:
63
var = 2 + random.Next (5);
64
total = 50 + random.Next (100);
65
question = String.Format (
66
// Translators: {0} and {1} are always numbers greater than 1
67
Catalog.GetString ("We have a {0} meters piece of fabric. Machine A takes {1} seconds to cut 1 meter of this fabric. How many seconds does Machine A take to cut the entire piece of fabric into 1 meter pieces?"),
69
answer = String.Format (
70
// Translators: {0} is always a number greater than 1
71
Catalog.GetString ("With the {0} cut, Machine A creates two 1 meter pieces."), (total - 1));
73
ans = (total - 1) * var;
76
case (int) GameType.Fence:
77
total = 20 + random.Next (20);
79
question = String.Format (
80
// Translators: {0} is always a number greater than 20
81
Catalog.GetString ("A fence is built to enclose a square shaped region. {0} fence poles are used in each side of the square. How many fence poles are used in total?"),
83
// Translators: {0} is always a number greater than 20
84
answer = String.Format (
85
Catalog.GetString ("There are {0} fence poles since the poles on the corners of the square are shared."), ans);
88
case (int) GameType.Present:
89
int present = 5 + random.Next (20);
92
question = String.Format (
93
// Translators: {0} is always a number greater than 5
94
Catalog.GetString ("Wrapping an anniversary present costs one euro. The anniversary present costs {0} euros more than the cost to wrap it. How much does it cost to both purchase and wrap the present?"),
96
answer = String.Format (
97
Catalog.GetString ("Individually, the present costs one euro more to purchase than to wrap."));
100
throw new Exception ("Unexpected value");
103
right_answer = (ans).ToString ();
106
public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
108
base.Draw (gr, area_width, area_height, rtl);
110
if (gametype == GameType.Present) {
111
gr.DrawImageFromAssembly ("present.svg", 0.2, 0.4, 0.6, 0.2);
113
if (gametype == GameType.Fence)
116
const double x = 0.35, y = 0.2;
117
const double figure_size = 0.4;
119
x105 = figure_size * Math.Cos (105 * Math.PI / 180);
120
y105 = figure_size * Math.Sin (105 * Math.PI / 180);
122
gr.LineTo (x + x105, y + y105);
123
gr.LineTo (x + x105 + figure_size, y + y105);
125
gr.MoveTo (x + figure_size, y);
126
gr.LineTo (x + figure_size + x105, y + y105);
129
gr.LineTo (x + figure_size, y);