Exemplo n.º 1
0
        //returns the inflation for an year
        public static Inflation GetInflation(int year)
        {
            Inflation inflation = inflations.Find(i => i.Year == year);

            if (inflation == null)
            {
                Random rnd = new Random();

                double rndInflation     = (((rnd.NextDouble() * 5) - 1) / 100.0);
                double inflationPercent = 1 + rndInflation;

                Inflation prevInflation = inflations.Find(i => i.Year == year - 1);

                if (prevInflation == null)
                {
                    prevInflation = inflations.Last();
                }

                Inflation newInflation = new Inflation(year, prevInflation.FuelPrice * inflationPercent, rndInflation, prevInflation.Modifier * inflationPercent);
                Inflations.AddInflationYear(newInflation);

                return(newInflation);
            }
            else
            {
                return(inflation);
            }
        }
Exemplo n.º 2
0
        //the converter for a price based on inflation
        public static double GetInflationPrice(double price)
        {
            Inflation baseInflation    = Inflations.GetInflation(Inflations.BaseYear);
            Inflation currentInflation = Inflations.GetInflation(GameObject.GetInstance().GameTime.Year);

            double modifier = currentInflation.Modifier / baseInflation.Modifier;

            double newPrice = price * modifier;

            return(newPrice);
        }