/// <summary> /// this method print the name of the dead bunny, what was died this year /// </summary> /// <param name="curDeadBunny"></param> public static void PrintDeadBunny(Bunny curDeadBunny) { while (Times.stopFlow) { ; } logger.Info(curDeadBunny.Name + " died"); Console.WriteLine(curDeadBunny.Name + " died"); }
/// <summary> /// /// </summary> /// <param name="curVampireBunny"></param> public static void PrintVampireBunny(Bunny curVampireBunny) { while (Times.stopFlow) { ; } logger.Info(curVampireBunny.Name + " is radioactive mutant vampire. Age: " + curVampireBunny.Age + " Color: " + curVampireBunny.Color + " Sex: " + curVampireBunny.Sex); Console.WriteLine(curVampireBunny.Name + " is radioactive mutant vampire. Age: " + curVampireBunny.Age + " Color: " + curVampireBunny.Color + " Sex: " + curVampireBunny.Sex); }
public static int countDeadBunnies = 0; //how many bunnies were died /// <summary> /// prints new bunnies /// </summary> /// <param name="newBunny"></param> public static void PrintNewBunny(Bunny newBunny) { while (Times.stopFlow) { ; } logger.Info("Bunny " + newBunny.Name + " was born. Color: " + newBunny.Color + ", Sex: " + newBunny.Sex); Console.WriteLine("Bunny " + newBunny.Name + " was born. Color: " + newBunny.Color + ", Sex: " + newBunny.Sex); countNewBunnies++; }
/// <summary> /// A method for generating new random born bunnies /// </summary> /// <param name="currentBunnies"></param> /// <returns>A List of the generated bunnies</returns> public static List <Bunny> GenerateRandomBunnies(List <Bunny> currentBunnies) { List <Bunny> newBunnies = new List <Bunny>(); int quantMaleBunnies = GetRegularAdultMaleBunnies(currentBunnies).Count; //quantity of regular adult male bunnies List <Bunny> femaleBunnies = GetRegularAdultFemaleBunnies(currentBunnies); //all current regular adult female bunnies Random random = new Random(); foreach (Bunny fBunny in femaleBunnies) { for (int i = 0; i < quantMaleBunnies; i++) { int generatedSex = random.Next(Enum.GetNames(typeof(Sex)).Length); int generatedColor = (int)fBunny.Color; string givenName; //the name is given from the list depending on the gender of the bunny if (i % 2 == 0) // this so that there is an equal number of bunnies at the start { generatedSex = (int)Sex.Female; givenName = ((FemaleNames)random.Next(Enum.GetNames(typeof(FemaleNames)).Length)).ToString(); } else { generatedSex = (int)Sex.Male; givenName = ((MaleNames)random.Next(Enum.GetNames(typeof(MaleNames)).Length)).ToString(); } Bunny generatedBunny = new Bunny(givenName, generatedSex, generatedColor, Bunny.InitialAge); if (generatedBunny.isRadioactiveMutantVampireBunny != true)//cheking whether the bunny was born a vampire or not { Print.PrintNewBunny(generatedBunny); } else { Print.PrintVampireBunny(generatedBunny); Print.countNewBunnies++; } newBunnies.Add(generatedBunny); } } return(newBunnies); }
/// <summary> /// A method for generating random bunnies, but with initial genders. /// </summary> /// <param name="initialNumberOfBunnies"></param> /// <returns>A List of the generated bunnies</returns> public static List <Bunny> GenerateInitialBunnies(int initialNumberOfBunnies) { List <Bunny> initialBunnies = new List <Bunny>(); Random random = new Random(); for (int i = 0; i < initialNumberOfBunnies; i++) { int generatedColor = random.Next(Enum.GetNames(typeof(Color)).Length); int generatedSex; string givenName; //the name is given from the list depending on the gender of the bunny if (i % 2 == 0) // this so that there is an equal number of bunnies at the start { generatedSex = (int)Sex.Female; givenName = ((FemaleNames)random.Next(Enum.GetNames(typeof(FemaleNames)).Length)).ToString(); } else { generatedSex = (int)Sex.Male; givenName = ((MaleNames)random.Next(Enum.GetNames(typeof(MaleNames)).Length)).ToString(); } Bunny generatedBunny = new Bunny(givenName, generatedSex, generatedColor, Bunny.InitialAge); if (generatedBunny.isRadioactiveMutantVampireBunny != true)//cheking whether the bunny was born a vampire or not { Print.PrintNewBunny(generatedBunny); } else { Print.PrintVampireBunny(generatedBunny); Print.countNewBunnies++; } initialBunnies.Add(generatedBunny); } return(initialBunnies); }
/// <summary> /// every year the vampire bunny bites another regular rabbit and infects him with vampirism /// </summary> /// <param name="currentBunnies"></param> public static void DoBite(List <Bunny> currentBunnies) { List <Bunny> vampireBunnies = GetRadioactiveMutantVampireBunnies(currentBunnies); List <Bunny> regularBunnies = GetRegularBunnies(currentBunnies);//auxiliary variable //if vampire bunnies are greater than or equal to the number of ordinary bunnies //then there is no point in further loading the system - we make all ordinary bunnies vampires(also for fix the bug) if (vampireBunnies.Count > regularBunnies.Count) { foreach (Bunny regularBunny in regularBunnies) { regularBunny.isRadioactiveMutantVampireBunny = true; Print.PrintVampireBunny(regularBunny); } return; } //standart method foreach (Bunny vampireBunny in vampireBunnies) { List <Bunny> regularCurrentBunneis = GetRegularBunnies(currentBunnies); IEnumerator <Bunny> regularBunniesEnumerator = regularCurrentBunneis.GetEnumerator(); Random random = new Random(); Bunny randomBunny = regularCurrentBunneis[random.Next(regularCurrentBunneis.Count)]; //choose a random bunny to bite while (regularBunniesEnumerator.Current != randomBunny) //move on the next until we find the one we need to bite { regularBunniesEnumerator.MoveNext(); } regularBunniesEnumerator.Current.isRadioactiveMutantVampireBunny = true; Print.PrintVampireBunny(regularBunniesEnumerator.Current); } }
public AirCraft(Bunny bunny, int damage) { this.Pilot = bunny; this.Damage = damage; this.Coordinates = new Map(); }