public void PoodleDogBarkTest()
        {
            IDog   dog  = new Poodle();
            String bark = dog.Bark();

            Assert.AreEqual("The Poodle says Yip Yip", bark);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Temp t = new Temp();

            Console.WriteLine(t.num);
            Console.ReadLine();

            Animal d = new Dog();

            Console.WriteLine(d.Legs);
            // Outputs 4

            d.Call();
            //d.Bark();
            //Outputs "Woof"

            Poodle fluffy = new Poodle();

            Console.WriteLine(fluffy.speed);

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

            Book b;

            b.title = "Book Title";

            Console.WriteLine(b.title);

            Console.ReadLine();
        }
        public void PoodleColorReturnsBlackTest()
        {
            // Act
            Poodle poodle = new Poodle();

            // Assert
            Assert.Equal("black", poodle.Color);
        }
        public void PoodleSpeakReturnsBarkTest()
        {
            //Act
            Poodle poodle = new Poodle();

            // Assert
            Assert.Equal("bark", poodle.Speak());
        }
        public void PoodleEatsFreshTest()
        {
            // Act
            IEatFresh poodle = new Poodle();

            // Assert
            Assert.Equal("I eat kibble and fresh meat", poodle.EatsFresh());
        }
        public void PoodleISpeakAlotTest()
        {
            // Act
            ISpeakAlot poodle = new Poodle();

            //Assert
            Assert.Equal("bark bark bark bark", poodle.SpeaksAlot());
        }
Esempio n. 7
0
    private void AddDog()
    {
        HandleInput("Enter breed", out string breed);                                                       //låter användaren skriva in en input som går igenom "HandelInput"

        if (breed.ToLower() == "poodle" || breed.ToLower() == "labrador" || breed.ToLower() == "weinerdog") // om användaren skriver in någon av de 3 olika raserna så händer de under
        {
            HandleInput("Enter name", out string name);
            HandleInput("Enter age", out int age);
            HandleInput("Enter length", out int length);
            HandleInput("Enter withers", out int withers);
            HandleInput("Enter weight", out int weight);
            HandleInput("Enter gender", out string gender);

            Dog dog = null;                                                   // nollställer dog

            if (breed.ToLower() == "poodle")                                  //om användaren skrev in pudel
            {
                dog = new Poodle(name, age, length, withers, weight, gender); // då blir dog satt till Pudel och hela strängen
            }

            if (breed.ToLower() == "labrador")  //om användaren skrev in labrador
            {
                dog = new Labrador(name, age, length, withers, weight, gender);
            }

            if (breed.ToLower() == "weinerdog") // om användaren skrev in weinerdog
            {
                dog = new WeinerDog(name, age, length, withers, weight, gender);
            }

            int count = 0;             // sätter variabeln count till 0
            foreach (Dog d in doglist) // för varje hund i listan...
            {
                if (d.Compare(dog))    // jämför den med dog
                {
                    count++;           // lägger på +1 på count
                }
            }
            if (count == 0)       // om count fortfarande är 0 , alltså att det inte fanns någon likadan hund så händer de under, alltså inom {}
            {
                doglist.Add(dog); // lägger till hund
            }
            else // om count inte är 0 så händer...
            {
                Console.WriteLine("The dog you tried to add already exist");
            }
        }
        else // om man skrev något annat än de 3 raserna så...
        {
            Console.WriteLine("Breed does not exist");
            return; // retunerar
        }
    }
Esempio n. 8
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            Animal poodle = new Poodle();

            // PolyMorphism with Interfaces

            var transmissions = new List <ITransmission>();

            transmissions.Add(new Sedan());
            transmissions.Add(new Truck());

            foreach (var transmission in transmissions)
            {
                var currentGear = transmission.ChangeGear(4);

                Console.WriteLine($"My Transmission is set to the {currentGear} gear.");
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Creates a Dog type depending on type selected
        /// </summary>
        /// <param name="other">Dog to copy details from</param>
        /// <returns></returns>
        private Dog CreateTypeOfDogFromDogType()
        {
            if ((DogType)animalTypeWithinSpecies == DogType.GoldenRetriever)
            {
                GoldenRetriever goldenRetriever = new GoldenRetriever(animalName, animalAge, animalGender, mammalNumberOfTeeth, dogInformation.NumberOfLegs, dogInformation.TeilLength, dogInformation.FurType);

                return(goldenRetriever);
            }
            else if ((DogType)animalTypeWithinSpecies == DogType.Poodle)
            {
                Poodle poodle = new Poodle(animalName, animalAge, animalGender, mammalNumberOfTeeth, dogInformation.NumberOfLegs, dogInformation.TeilLength, dogInformation.IsCosy);

                return(poodle);
            }
            else
            {
                Schaefer schaefer = new Schaefer(animalName, animalAge, animalGender, mammalNumberOfTeeth, dogInformation.NumberOfLegs, dogInformation.TeilLength, dogInformation.UseCases);

                return(schaefer);
            }
        }
Esempio n. 10
0
        public static DogBase GedDog(DogBreed dogBreed)
        {
            DogBase dog = null;

            if (dogBreedDict.ContainsKey(dogBreed))
            {
                dog = dogBreedDict.First(db => db.Key == dogBreed).Value;
            }
            else
            {
                switch (dogBreed)
                {
                case DogBreed.Dalmatian:
                    dog = new Dalmatian();
                    break;

                case DogBreed.GoldenRetriever:
                    dog = new GoldenRetriever();
                    break;

                case DogBreed.Labrador:
                    dog = new Labrador();
                    break;

                case DogBreed.Pinscher:
                    dog = new Pinscher();
                    break;

                case DogBreed.Poodle:
                    dog = new Poodle();
                    break;
                }

                Console.WriteLine($"{dogBreed} Created");

                dogBreedDict.Add(dogBreed, dog);
            }

            return(dog);
        }
Esempio n. 11
0
        static void Main(string[] args)
        {
            var motors = new List <IMotor>();

            motors.Add(new Car());
            motors.Add(new LawnMower());

            foreach (var motor in motors)
            {
                Console.WriteLine(motor.Cylinders);
            }


            // back to oop for a second


            // Point Example
            var point = new Point();

            // using the DOT notation, this allows you to access public members outside of your object.
            // so in this case, we are saying point.x, this is like reaching into our point object, and,
            // accessing the X property.
            point.X = 2;
            point.Y = 5;

            Console.WriteLine(point);


            // POLYMORPHSIM

            // Inheritance chain.. Dog <== Animal <== Object
            var dog = new Dog();



            // Inheritance chain.. Cat <== Animal <== Object
            var cat = new Cat();

            cat.Name = "Oreo";

            var poodle = new Poodle();

            poodle.Name = "Poods";

            // We are able to add a our dog, cat, and poodle into this list of Animals because of PolyMorphism.
            // PolyMorphism meaning many shapes, allows us to LOOK at our classes as a DIFFERENT CLASS within
            // it's INHERITENCE chain.  ie. because a Dog INHERITS from ANIMAL, we can look at a DOG as an ANIMAL.
            // because POODLE Inherits from DOG, and DOG INHERITS from ANIMAL, POODLE  is part of the SAME INHERTENCE
            // chain as ANIMAL, and therefore, we can look at a POODLE as an ANIMAL.
            var vetAnimals = new List <Animal>();

            vetAnimals.Add(cat);
            vetAnimals.Add(dog);
            vetAnimals.Add(poodle);

            foreach (var animal in vetAnimals)
            {
                Console.WriteLine(animal.Name);

                // This is Polymorphism Validation. we are asking "is our animal a dog?"
                // and IF IT IS, we then store our animal variable into a dogAnimal variable.
                // then in our if statement, we can then access dog propertys.  this is a
                // safe way to CAST DOWN into your type.
                if (animal is Dog dogAnimal)
                {
                    Console.WriteLine(dogAnimal.IsAGoodDog);
                }

                Console.WriteLine(animal.MakeNoise());
            }

            Console.WriteLine(dog.IsAGoodDog);

            // Inheritance chain.. Dog <== Animal <== Object
            var dogOne = new Dog();

            // Inheritance chain.. Dog <== Animal <== Object
            var dogTwo = new Dog();

            // Inheritance chain.. Dog <== Animal <== Object
            var dogThree = new Dog();

            var animalsTwo = new List <Animal>();

            animalsTwo.Add(dogOne);
            animalsTwo.Add(dogTwo);
            animalsTwo.Add(dogThree);

            foreach (Animal animal in animalsTwo)
            {
                // Because our compile can see that Dog Inherits from Animal, we can
                // explicitly CAST our Animal into a Dog.
                // WARNING!!! AVOID DOING THIS IF YOU ARE NOT 100% SURE!!!
                Dog actuallyADog = (Dog)animal;
                Console.WriteLine(actuallyADog.IsAGoodDog);
            }


            // PolyMorphism Logging example
            var loggers = new List <LoggerBase>();

            loggers.Add(new EmailLogger());
            loggers.Add(new ConsoleLogger());
            loggers.Add(new TextMessageLogger());
            loggers.Add(new DatabaseLogger());

            foreach (var logger in loggers)
            {
                logger.Log("logging my message");
            }
        }
Esempio n. 12
0
    private void Running()
    {
        bool run = true;

        while (run == true)
        {
            Console.WriteLine("Welcome to my dog registry, type !Help to get the commands so you can start your journey");

            string input = Console.ReadLine();

            if (input == "!Help")
            {
                Console.WriteLine("\n List of commands:\n !Help\n !Add dog\n !Remove dog\n !Print\n !Search\n !Exit\n");
            }

            if (input.ToLower() == "!add dog")
            {
                Add();
            }
            if (input.ToLower() == "!print")
            {
                Print();
            }
            if (input.ToLower() == "!exit")
            {
                Environment.Exit(0);
            }
            if (input.ToLower() == "!search")
            {
                Dog dog = Search();
                if (dog != null)
                {
                    Console.WriteLine(dog.GetAsString());
                    bool running = true;
                    while (running == true)
                    {
                        Console.WriteLine("\n You can now choose if you want to !Edit or !Remove the dog from the registry");
                        input = Console.ReadLine();
                        if (input.ToLower() == "!edit")
                        {
                            int index = 0;
                            for (int i = 0; i < list.Count; i++)
                            {
                                if (list[i] == dog)
                                {
                                    index = i;
                                }
                            }
                            Console.WriteLine("What do you want to edit about the dog?");

                            string choice = Console.ReadLine();

                            switch (choice.ToLower())
                            {
                            case "exit":
                                running = false;
                                break;

                            case "name":
                                HandleInput("What do you want to change it to?", out string name);
                                list[index].name = name;
                                break;

                            case "age":
                                int age = HandleInput("What do you want to change it to?");
                                list[index].age = age;
                                break;

                            case "withers":
                                int withers = HandleInput("What do you want to change it to?");
                                list[index].withers = withers;
                                break;

                            case "length":
                                int length = HandleInput("What do you want to change it to?");
                                list[index].length = length;
                                break;

                            case "gender":
                                HandleInput("What do you want to change it to?", out string gender);
                                list[index].gender = gender;
                                break;

                            case "weight":
                                int weight = HandleInput("What do you want to change it to?");
                                list[index].weight = weight;
                                break;

                            case "breed":
                                HandleInput("What do you want to change it to?", out string breed);
                                if (breed.ToLower() == "labrador")
                                {
                                    list[index] = new Labrador(dog.name, dog.age, dog.withers, dog.length, dog.gender, dog.weight, breed);
                                }

                                if (breed.ToLower() == "weiner_dog")
                                {
                                    list[index] = new Weiner_Dog(dog.name, dog.age, dog.withers, dog.length, dog.gender, dog.weight, breed);
                                }

                                if (breed.ToLower() == "poodle")
                                {
                                    list[index] = new Poodle(dog.name, dog.age, dog.withers, dog.length, dog.gender, dog.weight, breed);
                                }
                                break;
                            }
                        }
                        else if (input.ToLower() == "!exit")
                        {
                            running = false;
                        }
                        else if (input.ToLower() == "!remove")
                        {
                            int index = 0;
                            for (int i = 0; i < list.Count; i++)
                            {
                                if (list[i] == dog)
                                {
                                    index = i;
                                }
                            }
                            list.RemoveAt(index);
                        }
                    }
                }
            }
            else if (input == " ")
            {
                Console.WriteLine("You have entered a invalid command");
            }
        }
    }
Esempio n. 13
0
    void Edit(Dog dog) // redigera hunden som har blivit sökt på, körs när användaren matat in kommandot edit efter att ha gått in i sök
    {
        Console.WriteLine(dog.GetAsString());
        bool running = true;

        while (running == true)
        {
            int index = 0;
            for (int i = 0; i < doglist.Count; i++)
            {
                if (doglist[i] == dog)
                {
                    index = i;
                }
            }
            Console.WriteLine("What do you want to edit about the dog? (exit to stop edit");

            string choice = Console.ReadLine();

            switch (choice.ToLower()) // switch sats som låter en välja vad man ska redigera och sätter alla bokstäver till gemener.
            {
            case "exit":
                running = false;
                break;

            case "name":
                HandleInput("What do you want to change it to?", out string name);
                doglist[index].Name = name;                                 //ändrar bara namnet i strängen
                break;

            case "age":
                HandleInput("What do you want to change it to?", out int age);
                doglist[index].Age = age;
                break;

            case "withers":
                HandleInput("What do you want to change it to?", out int withers);
                doglist[index].Withers = withers;
                break;

            case "length":
                HandleInput("What do you want to change it to?", out int length);
                doglist[index].Length = length;
                break;

            case "gender":
                HandleInput("What do you want to change it to?", out string gender);
                doglist[index].Gender = gender;
                break;

            case "weight":
                HandleInput("What do you want to change it to?", out int weight);
                doglist[index].Weight = weight;
                break;

            case "breed":
                HandleInput("What do you want to change it to?", out string breed);
                if (breed.ToLower() == "labrador")     //om rasen (i gemener) är labrador så läggs den ändringen till
                {
                    doglist[index] = new Labrador(dog.Name, dog.Age, dog.Length, dog.Withers, dog.Weight, dog.Gender);
                }

                if (breed.ToLower() == "weinerdog")
                {
                    doglist[index] = new WeinerDog(dog.Name, dog.Age, dog.Length, dog.Withers, dog.Weight, dog.Gender);
                }

                if (breed.ToLower() == "poodle")
                {
                    doglist[index] = new Poodle(dog.Name, dog.Age, dog.Length, dog.Withers, dog.Weight, dog.Gender);
                }
                break;
            }
        }
    }
        public void PoodleDogCreateTest()
        {
            IDog dog = new Poodle();

            Assert.IsInstanceOfType(dog, typeof(Poodle));
        }