static void Main(string[] args) { Dog dog = new Dog() { Id = 1, Name = "Roki", Color = "yellow" }; Dog dog1 = new Dog() { Id = 0, Name = "Winter", Color = "black" }; Dog dog2 = new Dog() { Id = 2, Name = "Zigi", Color = "white" }; dog.Bark(); if (dog.Validate(dog.Id, dog.Name, dog.Color) == true) { DogShelter.Dogs.Add(dog); } DogShelter.PrintAll(DogShelter.Dogs); Console.ReadLine(); }
static void Main(string[] args) { Console.WriteLine("Hello Polymorphism!"); DogShelter.PrintAll(); DogShelter.DogList.ForEach(dog => dog.Bark()); Console.ReadLine(); }
static void Main(string[] args) { Dog dog1 = new Dog() { Id = 1, Name = "Teodora", Color = "Yellow" }; Dog dog2 = new Dog() { Id = 2, Name = "Filimena", Color = "Green" }; Dog dog3 = new Dog() { Id = 3, Name = "Paraskeva", Color = "Red" }; if (Dog.Validate(dog1) == true) { DogShelter.Dogs.Add(dog1); } else { Console.WriteLine("Smth Went Wrong!"); } if (Dog.Validate(dog2) == true) { DogShelter.Dogs.Add(dog2); } else { Console.WriteLine("Smth Went Wrong!"); } if (Dog.Validate(dog3) == true) { DogShelter.Dogs.Add(dog3); } else { Console.WriteLine("Smth Went Wrong!"); } DogShelter.PrintAll(); Console.ReadLine(); }
static void Main(string[] args) { Dog dog1 = new Dog() { Id = 1, Name = "Rex", Color = "Brown" }; Dog dog2 = new Dog() { Id = 2, Name = "Sparky", Color = "Black" }; Dog dog3 = new Dog() { Id = 3, Name = "Belka", Color = "White" }; DogShelter.Dogs.Add(dog1); DogShelter.Dogs.Add(dog2); DogShelter.Dogs.Add(dog3); DogShelter.PrintAll(); Console.ReadLine(); }
static void Main(string[] args) { Dog sparke = new Dog() { Id = 1, Name = "Sp", Color = "Yellow" }; Dog leo = new Dog() { Id = 2, Name = "Leo", Color = "Red" }; Dog jack = new Dog() { Id = 3, Name = "Jack", Color = "Green" }; // Check if everything is okay if (Dog.Validate(sparke) && Dog.Validate(leo) && Dog.Validate(jack)) { Console.WriteLine("Successful inputs. Dogs added to the Dog Shelter."); DogShelter.Dogs.Add(sparke); DogShelter.Dogs.Add(leo); DogShelter.Dogs.Add(jack); DogShelter.PrintAll(); } else { Console.WriteLine("Invalid input."); } Console.ReadLine(); }
static void Main(string[] args) { #region Exercise //Create a class called Dog that has: // Id, Name, Color, Bark() - Prints “Bark Bark” // A static method Validate() - Checks if dog has all 3 properties, // if Id is not less than 0 and Name is 2 characters or longer //Create a static class called DogShelter that has: // List of Dogs // PrintAll() - prints all dogs from List of Dogs //Create 3 Dog objects, call validate on them to see if they are okay, //add them in the List of Dogs and call PrintAll() #endregion var nero = new Dog(1, "Nero", "Black"); var kim = new Dog(2, "Kim", "Ochkre"); var jeki = new Dog(3, "Jeki", null); var sharko = new Dog(4, "Sharko", ""); var jo = new Dog(5, null, "Mixed"); var sparky = new Dog(0, "Sparky", "Brown"); var bo = new Dog(7, "Bo", "White"); nero.Bark(); Console.WriteLine("-------------------------------------"); Dog.Insert(nero); Dog.Insert(kim); Dog.Insert(jeki); Dog.Insert(sharko); Dog.Insert(jo); Dog.Insert(sparky); Dog.Insert(bo); Console.WriteLine(nero.ToString()); Console.WriteLine("-------------------------------------"); DogShelter.PrintAll(); }
static void Main(string[] args) { Dog woofie = new Dog("Black", 4); Dog afaf = new Dog(5, "T"); Dog milo = new Dog(7, "Milo", "White-Brown"); List <Dog> DogsToBeSheltered = new List <Dog> { woofie, afaf, milo, new Dog(1, "Lucky", "Black"), new Dog(2, "Spike", "Brown"), new Dog(3, "Smiley", "Brown-ish"), new Dog(4, "Toby", "White"), new Dog(5, "Bobby") }; foreach (Dog dog in DogsToBeSheltered) { if (Dog.Validate(dog)) { Console.WriteLine($"{dog.Name} is now sheltered and waiting to be adopted"); DogShelter.Dogs.Add(dog); } else { Console.ForegroundColor = ConsoleColor.DarkYellow; Console.WriteLine("Please fill all information about the dog in order to shelter it"); Console.ForegroundColor = ConsoleColor.White; } } Console.WriteLine("Please enter any key to see the dogs in the shelter"); Console.ReadKey(); DogShelter.PrintAll(); }
static void Main(string[] args) { List <Dog> dogs = new List <Dog> { new Dog(1, "Lessi", "Brown"), new Dog(5, "Bak", "White"), new Dog(-2, "Rex", "Yellow"), new Dog(4, "Badi", "Black"), }; foreach (Dog dog in dogs) { if (Dog.Validate(dog)) { DogShelter.Dogs.Add(dog); } else { Console.WriteLine("No dogs to add!"); } } Console.WriteLine(DogShelter.PrintAll()); }