static void Main(string[] args) { Mushroom badMushroom = new Mushroom(MushroomType.Bad); Mushroom goodMushroom = new Mushroom(MushroomType.Good); Character mario = new Character("Mario"); Character lougie = new Character("Lougie"); mario.Run(); mario.Eat(badMushroom); mario.Run(); mario.Eat(goodMushroom); mario.Run(); Console.WriteLine("\n=========================\n"); lougie.Run(); lougie.Eat(new Mushroom(MushroomType.Bad)); lougie.Run(); lougie.Eat(new Mushroom(MushroomType.Good)); lougie.Run(); for (int i = 0; i < 500; i++) { mario.Eat(new Mushroom(MushroomType.Bad)); mario.Run(); } mario.RecieveDamage(int.MaxValue); mario.Run(); Console.WriteLine(Mushroom.TotalShroomsEaten); }
public void Eat(Mushroom mushroom) { if (IsDead) { Console.WriteLine("Character is dead"); return; } bool wasEatenSuccessfully = mushroom.WasEatenSuccessfully(); if (wasEatenSuccessfully) { if (mushroom.MushroomType == MushroomType.Bad) { RecieveDamage(mushroom.DamagePoint); } else if (mushroom.MushroomType == MushroomType.Good) { CharacterMode = CharacterMode.Big; } else { throw new ArgumentException("Unknown MushroomType was provided."); } } }