[gbrainy] Fixes #613699
- From: Jordi Mas <jmas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gbrainy] Fixes #613699
- Date: Tue, 23 Mar 2010 20:35:46 +0000 (UTC)
commit b3fce507b161a22d1a880b8a19997a255e48220c
Author: Jordi Mas <jmas softcatala org>
Date: Tue Mar 23 21:35:54 2010 +0100
Fixes #613699
src/Games/Logic/PuzzlePercentage.cs | 39 +++++++++++++++++++++-------------
1 files changed, 24 insertions(+), 15 deletions(-)
---
diff --git a/src/Games/Logic/PuzzlePercentage.cs b/src/Games/Logic/PuzzlePercentage.cs
index 9150705..6516199 100644
--- a/src/Games/Logic/PuzzlePercentage.cs
+++ b/src/Games/Logic/PuzzlePercentage.cs
@@ -63,33 +63,42 @@ namespace gbrainy.Games.Logic
gametype = (GameType) random.Next ((int) GameType.Total);
- switch ((int) gametype)
+ switch (gametype)
{
- case (int) GameType.Discount:
- int price, discount, paid;
+ case GameType.Discount:
+ double price, discount, paid;
+
+ do
+ {
+ discount = 10 + random.Next (30);
+ price = 100 + random.Next (100);
+ paid = price - (price * discount / 100);
+
+ } while (paid != Math.Truncate (paid));
- discount = 10 + random.Next (30);
- price = 100 + random.Next (100);
- paid = price - (price * discount / 100);
-
question = String.Format (
Catalog.GetString ("After getting {0}% discount you have paid {1} monetary units for a TV set. What was the original price of the TV set?"),
discount, paid);
- ans = price;
+ ans = (int)price;
break;
- case (int) GameType.Sales:
- int sales, increase, previous;
+ case GameType.Sales:
+ double sales, increase, previous;
+
+ do
+ {
+ previous = 10 + random.Next (90);
+ increase = 10 + random.Next (20);
+ sales = previous + (previous * increase / 100);
+
+ } while (sales != Math.Truncate (sales));
- previous = 10 + random.Next (90);
- increase = 10 + random.Next (20);
- sales = previous + (previous * increase / 100);
question = String.Format (
Catalog.GetString ("John's shop had sales of {0} monetary units. This was an increase of {1}% over last month. What were last month sales?"),
sales, increase);
- ans = previous;
+ ans = (int) previous;
break;
- case (int) GameType.Water:
+ case GameType.Water:
double decrease, percentage;
do
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]