상속: BaseModel
예제 #1
0
        public static Inflation GetInflation(int year)
        {
            Inflation inflation = inflations.Find(i => i.Year == year);

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

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

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

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

                return newInflation;
            }
            return inflation;
        }
예제 #2
0
 public static void AddInflationYear(Inflation inflation)
 {
     inflations.Add(inflation);
 }