static void Main(string[] args) { var chicken = new Chicken("Liza"); var bob = new Chicken("Bob"); chicken.Peck("corn"); chicken.Peck("corn"); bob.Peck("watermelon"); Console.WriteLine($"{chicken.Name} and {bob.Name} are chickens......."); var llama = new Llama(3, "brown") { Spits = true }; llama.Dye("Blue"); //object initializer var cat = new Cat() { IsFeral = true, Color = CatColor.Tabby, BestFriend = bob }; cat.Color = CatColor.Tabby; cat.BestFriend = bob; cat.HaveASnack(); Console.WriteLine($"The {cat.Color} cat is playing with a toy."); }
static void Main(string[] args) { var chicken = new Chicken("Liza"); var bob = new Chicken("bob"); chicken.Peck("corn"); chicken.Peck("corn"); chicken.Peck("corn"); chicken.Peck("corn"); chicken.Peck("corn"); chicken.Peck("corn"); bob.Peck(); Console.WriteLine($"{chicken.Name} and {bob.Name} are chickens"); var llama = new Llama(3, "brown"); llama.Dye("Teal"); var cat = new Cat(); cat.Color = CatColor.Tabby; cat.BestFriend = bob; cat.HaveASnack(); Console.WriteLine($"this cat is {cat.Color}"); }
static void Main(string[] args) { var chicken = new Chicken("Liza"); var bob = new Chicken("Bob"); chicken.Peck("corn"); chicken.Peck("corn"); chicken.Peck("corn"); chicken.Peck("corn"); bob.Peck(); Console.WriteLine($"{chicken.Name} and {bob.Name} are chickens...."); var llama = new Llama(3, "blue"); llama.Dye("teal"); //object initializer var cat = new Cat() { IsFeral = true, Color = CatColor.Tabby, BestFriend = bob }; cat.Color = CatColor.Tabby; cat.Dye(CatColor.White); cat.BestFriend = bob; cat.HaveASnack(); Console.WriteLine($"The cat is {cat.Color}."); }
static void Main(string[] args) { var chicken = new Chicken("Liza"); var bob = new Chicken("Bob"); chicken.Name = "Liza"; bob.Name = "Bob"; chicken.Peck("corn"); bob.Peck("Watermelon"); bob.Peck(); Console.WriteLine($"{chicken.Name} and {bob.Name} are proud chickens."); var llama = new Llama(3, "brown"); llama.Dye("Blue"); // object initializer syntax //var cat = new Cat() //{ // IsFeral = true, // Color = CatColor.Grey, // BestFriend = bob //}; var cat = new Cat(); // cat.Color = CatColor.Grey; cat.Color = CatColor.Black; cat.BestFriend = bob; Console.WriteLine($"The cat is {cat.Color}"); cat.HaveASnack(); Console.Read(); }