gbrainy r347 - trunk/src
- From: jmas svn gnome org
- To: svn-commits-list gnome org
- Subject: gbrainy r347 - trunk/src
- Date: Mon, 19 May 2008 18:57:58 +0000 (UTC)
Author: jmas
Date: Mon May 19 18:57:58 2008
New Revision: 347
URL: http://svn.gnome.org/viewvc/gbrainy?rev=347&view=rev
Log:
2008-05-19 Jordi Mas <jmas softcatala org>
* CalculationFractions.cs: Allow a double as an answer
Modified:
trunk/src/CalculationFractions.cs
trunk/src/ChangeLog
Modified: trunk/src/CalculationFractions.cs
==============================================================================
--- trunk/src/CalculationFractions.cs (original)
+++ trunk/src/CalculationFractions.cs Mon May 19 18:57:58 2008
@@ -126,7 +126,7 @@
break;
}
}
-
+
right_answer = String.Format (format_string, rslt);
}
@@ -174,14 +174,14 @@
{
string num_a = string.Empty;
string num_b = string.Empty;
- int a, b;
+ double a, b;
double rslt;
bool first = true;
for (int c = 0; c < answer.Length; c++)
{
if (answer[c] < '0' || answer[c] > '9') {
- if (answer[c] != '-') {
+ if (answer[c] != '-' && answer[c] != '.' && answer[c] != ',') {
first = false;
continue;
}
@@ -196,12 +196,13 @@
try {
if (num_b != string.Empty) {
- a = Int32.Parse (num_a);
- b = Int32.Parse (num_b);
+ a = Double.Parse (num_a);
+ b = Double.Parse (num_b);
rslt = (double) a / (double) b;
} else {
- rslt = Int32.Parse (num_a);
+ rslt = Double.Parse (num_a);
}
+
}
catch (FormatException) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]