gbrainy r349 - trunk/src
- From: jmas svn gnome org
- To: svn-commits-list gnome org
- Subject: gbrainy r349 - trunk/src
- Date: Mon, 19 May 2008 20:22:09 +0000 (UTC)
Author: jmas
Date: Mon May 19 20:22:08 2008
New Revision: 349
URL: http://svn.gnome.org/viewvc/gbrainy?rev=349&view=rev
Log:
2008-05-20 Jordi Mas <jmas softcatala org>
* PuzzleFigureLetter.cs: Allow answer with commas or spaces
* PuzzleFigures.cs: Allow answer with commas or spaces
* PuzzleBuildTriangle.cs: Allow answer with commas or spaces
* Game.cs: New method TrimAnswer
Modified:
trunk/src/ChangeLog
trunk/src/Game.cs
trunk/src/PuzzleBuildTriangle.cs
trunk/src/PuzzleFigureLetter.cs
trunk/src/PuzzleFigures.cs
Modified: trunk/src/Game.cs
==============================================================================
--- trunk/src/Game.cs (original)
+++ trunk/src/Game.cs Mon May 19 20:22:08 2008
@@ -240,8 +240,23 @@
{
return (String.Compare (answer, right_answer, true) == 0);
}
-
+ // When asking for a list of figures people trends to use spaces or commas
+ // to separate the elements
+ static public string TrimAnswer (string answer)
+ {
+ string rslt = string.Empty;
+
+ for (int i = 0; i < answer.Length; i++)
+ {
+ if (answer[i]==' ' || answer[i] == ',')
+ continue;
+
+ rslt += answer[i];
+ }
+ return rslt;
+ }
+
virtual public void PrepareGC (CairoContextEx gr)
{
gr.LineWidth = LineWidth;
Modified: trunk/src/PuzzleBuildTriangle.cs
==============================================================================
--- trunk/src/PuzzleBuildTriangle.cs (original)
+++ trunk/src/PuzzleBuildTriangle.cs Mon May 19 20:22:08 2008
@@ -220,7 +220,10 @@
char [] ans = new char [answer_num];
int c = 0, matches = 0;
char[] opers = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'};
- string answer = a.ToUpper ();
+ string answer;
+
+ a = TrimAnswer (a);
+ answer = a.ToUpper ();
for (int i = 0; i < answer_num; i++)
ans[i] = answers[i];
Modified: trunk/src/PuzzleFigureLetter.cs
==============================================================================
--- trunk/src/PuzzleFigureLetter.cs (original)
+++ trunk/src/PuzzleFigureLetter.cs Mon May 19 20:22:08 2008
@@ -72,7 +72,7 @@
public override bool CheckAnswer (string answer)
{
-
+ answer = TrimAnswer (answer);
switch (question) {
case QuestionType.TwoRectangles:
if ((String.Compare (answer, "ABF", true) == 0)
Modified: trunk/src/PuzzleFigures.cs
==============================================================================
--- trunk/src/PuzzleFigures.cs (original)
+++ trunk/src/PuzzleFigures.cs Mon May 19 20:22:08 2008
@@ -155,6 +155,11 @@
AnswerCoding (gr, DrawAreaX, y);
}
+ public override bool CheckAnswer (string answer)
+ {
+ answer = TrimAnswer (answer);
+ return base.CheckAnswer (answer);
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]