Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Dog dog1 = new Dog(1, "Bruno", "brown");
            Dog dog2 = new Dog(2, "Kara", "white");
            Dog dog3 = new Dog(3, "Rex", "black");

            Dog.Validate(dog1);
            Console.WriteLine("=====");

            Dog.Validate(dog2);
            Console.WriteLine("=====");

            Dog.Validate(dog3);
            Console.WriteLine("=====");

            DogShelter.AddDogs(dog1);
            DogShelter.AddDogs(dog2);
            DogShelter.AddDogs(dog3);

            Console.WriteLine("=====");

            DogShelter.PrintAll();

            Console.ReadLine();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Dog firstDog  = new Dog(1, "Coki", "white");
            Dog secondDog = new Dog(2, "Moki", "black");
            Dog thirdDog  = new Dog(3, "Loki", "gold");

            Dog.Validate(firstDog);
            Console.WriteLine("==================");

            Dog.Validate(secondDog);
            Console.WriteLine("==================");

            Dog.Validate(thirdDog);
            Console.WriteLine("==================");

            DogShelter.AddDogs(firstDog);
            DogShelter.AddDogs(secondDog);
            DogShelter.AddDogs(thirdDog);

            Console.WriteLine("=================");

            DogShelter.PrintAll();

            Console.ReadLine();
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            Dog dog1 = new Dog()
            {
                Id = 4, Name = "Boo", Color = null
            };
            Dog dog2 = new Dog()
            {
                Id = 4, Name = "Angie", Color = "white"
            };
            Dog dog3 = new Dog()
            {
                Id = -5, Name = "Mickey", Color = "black"
            };
            bool dog1Validation = dog1.Validate(dog1.Id, dog1.Name, dog1.Color);
            bool dog2Validation = dog2.Validate(dog2.Id, dog2.Name, dog2.Color);
            bool dog3Validation = dog3.Validate(dog3.Id, dog3.Name, dog3.Color);

            if (dog1Validation)
            {
                DogShelter.ListOfDogs.Add(dog1);
            }
            if (dog2Validation)
            {
                DogShelter.ListOfDogs.Add(dog2);
            }
            if (dog3Validation)
            {
                DogShelter.ListOfDogs.Add(dog3);
            }
            Console.WriteLine(DogShelter.PrintAll(DogShelter.ListOfDogs));
            Console.ReadLine();
        }
Ejemplo n.º 4
0
        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();
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            Dog dog1 = new Dog(1, "M", "Brown");
            Dog dog2 = new Dog()
            {
                Name = "Leo"
            };
            Dog dog3 = new Dog(3, "Sparky", "Black");

            Validate.Validated(dog1);
            Validate.Validated(dog2);
            Validate.Validated(dog3);

            Console.WriteLine("------------------------------------");

            DogShelter.AddDog(dog1);
            DogShelter.AddDog(dog2);
            DogShelter.AddDog(dog3);

            Console.WriteLine("-----------------------------------");

            DogShelter.PrintAll();

            Console.ReadLine();
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello Polymorphism!");

            DogShelter.PrintAll();

            DogShelter.DogList.ForEach(dog => dog.Bark());



            Console.ReadLine();
        }
Ejemplo n.º 7
0
        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();
        }
Ejemplo n.º 8
0
        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();
        }
Ejemplo n.º 9
0
        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();
        }
Ejemplo n.º 10
0
        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();
        }
Ejemplo n.º 11
0
        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();
        }
Ejemplo n.º 12
0
        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());
        }