public static void Main(string[] args) { // Old style, procedural code: /* * var animal1Name = "Sasha"; * var animal1Breed = "Cheagle"; * var animal1Type = "dog"; * var animal2Name = "Polly"; * var animal2Breed = (string)null; * var animal2Type = "bird"; * // etc * Move(animal1Name, animal1Type); * Move(animal2Name, animal2Type); * */ var sashaTheDog = new Dog("Sasha", "Cheagle", "chicken", Gender.Female); sashaTheDog.Eat("kibble"); sashaTheDog.Eat("chicken"); sashaTheDog.MakeNoise(); sashaTheDog.DoTrick(); sashaTheDog.DoTrick("Play Dead"); sashaTheDog.DoTrick("Run Around"); sashaTheDog.Eat("kibble"); sashaTheDog.Eat("chicken"); var polly = new Parrot("Patrick", "blue", Gender.Male); polly.Eat("Kibble"); polly.Eat("Steak"); polly.Eat("seeds"); polly.Fly(); polly.Eat("seeds"); polly.Speak(); polly.LearnPhrase("want a cracker?"); polly.Speak(); polly.LearnPhrase("ARRR MATEY"); polly.LearnPhrase("Help! I'm trapped in a parrot's body!"); polly.LearnPhrase("ARRR MATEY"); polly.Speak(); polly.Speak(); polly.Speak(); polly.Speak(); #if DEBUG Console.WriteLine("Press enter to close..."); Console.ReadLine(); #endif }
IEnumerator PlayScenario() { playIntro = true; Debug.Log("Intro Play"); parrot.gameObject.SetActive(true); player.Freeze(); player.LayDown(); yield return(new WaitForSeconds(2)); parrot.Eat(); parrot.PlayRandomSound(); yield return(new WaitForSeconds(2)); parrot.Eat(); parrot.PlayRandomSound(); yield return(new WaitForSeconds(1)); player.StandUp(); yield return(new WaitForSeconds(2)); player.Unfreeze(); parrot.FlyTo(parrotTarget1.transform.position); }
static void Main(string[] args) { Parrot parrot1 = new Parrot(34); parrot1.Eat(); parrot1.Fly(); parrot1.Talk("Hello there!"); parrot1.Talk(); Console.WriteLine(); Sparrow sparrow1 = new Sparrow() { Name = "Tom", Weight = 1.5 }; sparrow1.Eat(); sparrow1.Fly(); sparrow1.ClimbThroughSmallHole(); Parrot parrot2 = new Parrot(15) { Name = "Pelle", Weight = 45.6 };; Parrot parrot3 = new Parrot(15) { Name = "Anna", Weight = 235.6 };; Sparrow sparrow2 = new Sparrow() { Name = "Mats", Weight = 23.4 };; Bird[] birds = { parrot1, parrot2, sparrow1, parrot3, sparrow2 }; Console.WriteLine(); Console.WriteLine("Bird array:"); Console.WriteLine(); foreach (Bird bird in birds) { bird.Eat(); if (bird is Parrot) { Parrot temporaryParrot = (Parrot)bird; //(bird as Parrot).Talk(); temporaryParrot.Talk(); temporaryParrot.Fly(); } else { Console.WriteLine($"{bird.Name} can not talk!"); } } Console.WriteLine(); foreach (Bird bird in birds) { bird.Die(); } }
public void CanParrotEat() { Parrot parrot = new Parrot(); Assert.True(parrot.Eat()); }