static void Main(string[] args) { // Every animal has a hunger value, which is a whole number // Every animal has a thirst value, which is a whole number // when creating a new animal object these values are created with the default 50 value // Every animal can eat() which decreases their hunger by one // Every animal can drink() which decreases their thirst by one // Every animal can play() which increases both by one var dog = new Animal("Dog", 50, 50); dog.Drink(); dog.Eat(); dog.Play(); Console.WriteLine(dog.GetThirst()); Console.WriteLine(dog.GetHunger()); var cat = new Animal("Cat", 50, 50); dog.Play(); Console.WriteLine(dog.GetThirst()); Console.WriteLine(dog.GetHunger()); Console.ReadKey(); }
static void Main(string[] args) { Animal giraffe = new Animal(); Animal lion = new Animal(); Console.WriteLine("How many leaves are there for Mr. Giraffe?"); int leaves = int.Parse(Console.ReadLine()); Console.WriteLine("How many sirloin steaks are there for Ms. Lion?"); int steaks = int.Parse(Console.ReadLine()); Console.WriteLine("How many lakes are there?"); int lakes = int.Parse(Console.ReadLine()); Console.WriteLine("For how many rounds should Ms. Lion chase Mr. Giraffe?"); int rounds = int.Parse(Console.ReadLine()); for (int i = 0; i < leaves; i++) { giraffe.Eat(); } for (int i = 0; i < steaks; i++) { lion.Eat(); } for (int i = 0; i < lakes; i++) { giraffe.Drink(); lion.Drink(); } for (int i = 0; i < rounds; i++) { giraffe.Play(); lion.Play(); } Console.WriteLine($"Mr. Giraffe is now {giraffe.GetHunger()}% hungry and {giraffe.GetThirst()}% thirsty"); Console.WriteLine($"Mr. Giraffe is now {lion.GetHunger()}% hungry and {lion.GetThirst()}% thirsty"); Console.ReadLine(); }
static void Main(string[] args) { var tiger = new Animal(50, 50); tiger.Drink(); tiger.Eat(); tiger.Play(); tiger.Play(); tiger.Play(); Console.WriteLine("The tiger's hunger is: " + tiger.GetHunger() + " and the tiger thirth is: " + tiger.GetThirst()); Console.ReadLine(); }