gbrainy r288 - trunk/src



Author: jmas
Date: Fri Apr  4 20:50:13 2008
New Revision: 288
URL: http://svn.gnome.org/viewvc/gbrainy?rev=288&view=rev

Log:
2008-04-02 Jordi Mas <jmas softcatala org>

	* PuzzleEquation.cs: New logic puzzle
	* GameManager.cs: Add new logic puzzle
	* Makefile.am: Add new puzzle



Added:
   trunk/src/PuzzleEquation.cs
Modified:
   trunk/src/AssemblyInfo.cs.in
   trunk/src/ChangeLog
   trunk/src/GameManager.cs
   trunk/src/Makefile.am

Modified: trunk/src/AssemblyInfo.cs.in
==============================================================================
--- trunk/src/AssemblyInfo.cs.in	(original)
+++ trunk/src/AssemblyInfo.cs.in	Fri Apr  4 20:50:13 2008
@@ -23,7 +23,7 @@
 
 [assembly: AssemblyVersion("@VERSION@")]
 [assembly: AssemblyTitle ("gbrainy")]
-[assembly: AssemblyCopyright ("(c)2007 Jordi Mas")]
+[assembly: AssemblyCopyright ("(c)2007-2008 Jordi Mas")]
 [assembly: AssemblyDescription ("A brain teaser game for fun and keep your brain trained")]
 
 

Modified: trunk/src/GameManager.cs
==============================================================================
--- trunk/src/GameManager.cs	(original)
+++ trunk/src/GameManager.cs	Fri Apr  4 20:50:13 2008
@@ -55,6 +55,7 @@
 		typeof (PuzzleBuildTriangle),
 		typeof (PuzzleClocks),
 		typeof (PuzzleCountCircles),
+		typeof (PuzzleEquation),
 	};
 
 	static Type[] CalculationTrainers = new Type[] 
@@ -174,7 +175,7 @@
 			}
 
 			puzzle =  (Game) Activator.CreateInstance ((Type) games [(int) enumerator.Current], true);
-			//puzzle =  (Game) Activator.CreateInstance (LogicPuzzles [29], true);
+			//puzzle =  (Game) Activator.CreateInstance (LogicPuzzles [31], true);
 			if (first != null && first.GetType () == puzzle.GetType ())
 				break;
 				

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Fri Apr  4 20:50:13 2008
@@ -56,6 +56,7 @@
 	$(srcdir)/CairoContextEx.cs		\
 	$(srcdir)/PuzzleClocks.cs		\
 	$(srcdir)/PuzzleCountCircles.cs		\
+	$(srcdir)/PuzzleEquation.cs		\
 	$(srcdir)/gbrainy.cs			
 
 ASSEMBLIES = \

Added: trunk/src/PuzzleEquation.cs
==============================================================================
--- (empty file)
+++ trunk/src/PuzzleEquation.cs	Fri Apr  4 20:50:13 2008
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2008 Jordi Mas i HernÃndez <jmas softcatala org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+using Cairo;
+using Mono.Unix;
+using System;
+
+public class PuzzleEquation : Game
+{
+	private int num_a, num_b, num_c, num_d, num_e;
+	private string formula;
+
+	public override string Name {
+		get {return Catalog.GetString ("Equation");}
+	}
+
+	public override string Question {
+		get {return Catalog.GetString ("What is the result of the equation below?");} 
+	}
+
+	public override string Answer {
+		get { 
+			string answer = base.Answer + " ";
+			answer += Catalog.GetString ("The order of arithmetical operations is always: exponents and roots, multiplication and division, addition and subtraction");
+			return answer;
+		}
+	}
+
+	public override void Initialize ()
+	{
+		bool found  = false;
+		int order = 0, sequential;
+
+		while (found == false) {
+			num_a = 2 + random.Next (5);
+			num_b = 2 + random.Next (5);
+			num_c = 2 + random.Next (5);
+			num_d = 2 + random.Next (5);
+			num_e = 2 + random.Next (5);
+			order = num_a * num_b + num_c *  num_d - num_e;
+			sequential = ((num_a * num_b + num_c) * num_d) - num_e;
+
+			if (order != sequential)
+				found = true;
+		}
+
+		formula = String.Format ("{0}  * {1} + {2} * {3} - {4}", num_a, num_b, num_c, num_d, num_e);
+		right_answer = (order).ToString ();
+	}
+
+	public override void Draw (CairoContextEx gr, int area_width, int area_height)
+	{
+		gr.Scale (area_width, area_height);
+
+		DrawBackground (gr);
+		PrepareGC (gr);
+		gr.SetLargeFont ();
+		gr.DrawTextCentered (0.5, 0.5, formula);
+	}
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]