public override string ToString() { StringBuilder sb = new StringBuilder(); sb.AppendLine($"Code: {Code}"); sb.AppendLine($"Name: {Name}"); sb.AppendLine($"LocalName: {LocalName}"); sb.AppendLine($"CapitalName: {CapitalName}"); sb.AppendLine($"Continent: {Continent}"); sb.AppendLine($"Region: {Region}"); sb.AppendLine($"Surface Area: {SurfaceArea.ToString("N2")}"); sb.AppendLine($"Independence Year: {IndepYear ?? ""}"); sb.AppendLine($"Population: {Population}"); sb.AppendLine($"LifeExpectancy: {LifeExpectancy?.ToString("N2") ?? ""}"); sb.AppendLine($"GNP: {GNP?.ToString("N2") ?? ""}"); sb.AppendLine($"GNP Old: {GNPOld?.ToString("N2") ?? ""}"); sb.AppendLine($"Government Form: {GovernmentForm}"); sb.AppendLine($"Head Of State: {HeadOfState ?? ""}"); sb.AppendLine(); if (Languages.Count != 0) { string langstring = "Languages: "; foreach (var lang in Languages) { langstring += $"{lang.Language}, "; } sb.AppendLine(langstring.TrimEnd().Trim(',')); } sb.AppendLine(); sb.AppendLine(); if (Cities.Count != 0) { string citystring = "Cities: "; foreach (var city in Cities) { citystring += $"{city.Name}, "; } sb.AppendLine(citystring.TrimEnd().Trim(',')); } sb.AppendLine(); sb.AppendLine(); return(sb.ToString()); }
public Annuities(Person person) { int currentYear = DateTime.Now.Year; yearsToRetirement = person.retirementDate - currentYear; //Calculate life expectancy based on different real world methods irsLife = LifeExpectancy.GetLifeExpectancy(person.age, person.gender); annuityLife = LifeExpectancy.GetLifeExpectancy(person.age + defferedTime, person.gender); retireLife = LifeExpectancy.GetLifeExpectancy(person.age + yearsToRetirement, person.gender); initialAmount = person.lumpSum; accumulationYears = Math.Max(yearsToRetirement, defferedTime); effectiveRate = Tax.GetEffectiveRate(person); yearsAfterRetirement = (person.deathDate - person.retirementDate); this.person = person; CalculateRiders(); }
public void EvaluateTraits(CreatureManager hManager, string speciesName) { List <Gene> genes = new List <Gene>(); if (!GlobalGEPSettings.RANDOMIZED_TRAITS || traitIndices.Count == 0) { traitIndices = GlobalGEPSettings.speciesTraitLayouts[speciesName]; } foreach (KeyValuePair <string, int[][]> thisTrait in traitIndices) { string key = thisTrait.Key; //For every chromosome a trait is linked to... //i = chromosome index (when a trait is on multiple chromosomes) for (int i = 0; i < thisTrait.Value.Length; i++) { //Index [i][0] will ALWAYS be the chromosome index int chromosomeIndex = thisTrait.Value[i][0]; //For every gene this trait is linked to (on this chromosome)... //j = gene index for this chromosome for (int j = 1; j < thisTrait.Value[i].Length; j++) { //Get the gene index int geneIndex = thisTrait.Value[i][j]; //Add the gene at the chromosomeIndex and geneIndex to a list to be evaluated //Accesses the genome rather than making a copy ensuring the genes accessed later on match exactly the current genome genes.Add(genome[chromosomeIndex].genes[geneIndex]); } } List <Trait> thisTraitList = AccessTraits(genes); //For each trait (keyValuePair) evaluate the genes //Could put the results into a dictionary - this way would be more polymorphic as would search for (or add) a row for each trait and search by name // instead of individual variables, or an array which requires the developer to remember which index is which switch (key.ToLower()) { case "eye left colour": eyeColours[0] = new GeneColour(thisTraitList); if (eyeColours[1] == null && eyeStyle != null) { if (eyeStyle.eyeMatching) { eyeColours[1] = eyeColours[0]; UnityEngine.Debug.Log("Eye Matching, Assigned 1 = 0"); } } break; case "eye right colour": eyeColours[1] = new GeneColour(thisTraitList); if (eyeColours[0] == null && eyeStyle != null) { if (eyeStyle.eyeMatching) { eyeColours[0] = eyeColours[1]; UnityEngine.Debug.Log("Eye Matching, Assigned 0 = 1"); } } break; case "eye style": eyeStyle = new EyeStyle(thisTraitList); if (eyeStyle.eyeMatching) { if (eyeColours[0] != null) { eyeColours[1] = eyeColours[0]; } else if (eyeColours[1] != null) { eyeColours[0] = eyeColours[1]; } else { UnityEngine.Debug.Log("Error: Both eye colours are currently NULL"); } } break; case "hair colour": hairColour = new GeneColour(thisTraitList); break; case "skin colour": skinColour = new GeneColour(thisTraitList); break; case "growth rate": growthRate = new GrowthRate(thisTraitList); break; case "life expectancy": lifeExpectancy = new LifeExpectancy(thisTraitList); break; case "reproductive age": reproductiveAge = new ReproductiveAge(thisTraitList); break; case "gestation period": gestationPeriod = new GestationPeriod(thisTraitList); break; case "energy level": energyLevel = new EnergyLevel(thisTraitList); break; case "energy consumption": energyConsumption = new EnergyConsumption(thisTraitList); break; case "food level": foodLevel = new FoodLevel(thisTraitList); break; case "food consumption": foodConsumption = new FoodConsumption(thisTraitList); break; case "water level": waterLevel = new WaterLevel(thisTraitList); break; case "water consumption": waterConsumption = new WaterConsumption(thisTraitList); break; case "strength": case "intellect": case "constitution": case "wisdom": case "charisma": case "vanity": attributesList.Add(new AttributeTrait(thisTraitList)); break; } genes.Clear(); } }