public static void FIFOAnimalShelter()
        {
            //Create animal shelter
            Console.WriteLine("Preparing the shelter...\n\n");
            AnimalShelter myShelter = new AnimalShelter();

            //Add cat
            Console.WriteLine("A cat has just been placed for adoption.");
            myShelter.Enqueue(new Cat("Billy"));

            //Add dog
            Console.WriteLine("A dog named Pupper has just been placed for adoption.");
            myShelter.Enqueue(new Dog("Pupper"));
            Console.WriteLine("Another dog named Bopper has just been placed for adoption.");
            myShelter.Enqueue(new Dog("Bopper"));

            //Add "Animal"
            Console.WriteLine("Another animal has been put for adoption.");
            myShelter.Enqueue(new Animal());

            //Request dog
            Console.WriteLine("I want to adopt a dog please");
            Dog myDog = (Dog)myShelter.Dequeue("dog");

            Console.WriteLine($"Here's your new dog, his name is: {myDog.Name}");
        }
Exemplo n.º 2
0
        public static void FIFOAnimalShelter()
        {
            //Create animal shelter
            Console.WriteLine("Preparing the shelter...\n\n");
            AnimalShelter myShelter = new AnimalShelter();

            //Add cat
            Console.WriteLine("A cat has just been placed for adoption.");
            myShelter.Enqueue(new Cat("Fluffy"));

            //Add dog
            Console.WriteLine("A dog named Rufus has just been placed for adoption.");
            myShelter.Enqueue(new Dog("Rufus"));
            Console.WriteLine("Another dog named Benji has just been placed for adoption.");
            myShelter.Enqueue(new Dog("Benji"));

            //Add "Animal"
            Console.WriteLine("A strange, other animal has been placed for adoption.");
            myShelter.Enqueue(new Animal());

            //Request dog
            Console.WriteLine("I would like to adopt a dog, please...");
            Dog myDog = (Dog)myShelter.Dequeue("dog");

            Console.WriteLine($"Here's your new dog, his name is: {myDog.Name}");
        }
Exemplo n.º 3
0
        static AnimalShelter MakeAnimalShelter()
        {
            Animal catOne = new Animal("cat");//1st

            catOne.Name = "mike";
            Animal catTwo = new Animal("cat");//2nd

            catTwo.Name = "ron";
            Animal catThree = new Animal("cat");//4th

            catThree.Name = "knight";
            Animal dogOne = new Animal("dog");//3rd

            dogOne.Name = "spot";
            Animal dogTwo = new Animal("dog");//5th

            dogTwo.Name = "demi";
            Animal dogThree = new Animal("dog");//6th

            dogThree.Name = "lassy";

            AnimalShelter myShelter = new AnimalShelter();//make shelter to add too

            //add animals to shelter
            myShelter.Enqueue(catOne);
            myShelter.Enqueue(catTwo);
            myShelter.Enqueue(dogOne);
            myShelter.Enqueue(catThree);
            myShelter.Enqueue(dogTwo);
            myShelter.Enqueue(dogThree);

            return(myShelter);
        }
        static void Main(string[] args)
        {
            Animal cat1 = new Cat("cat1");
            Animal cat2 = new Cat("cat2");
            Animal cat3 = new Cat("cat3");
            Animal dog1 = new Dog("dog1");
            Animal dog2 = new Dog("dog2");
            Animal dog3 = new Dog("dog3");
            Animal fish = new Fish("fish");

            AnimalShelter shelter = new AnimalShelter(cat1);

            shelter.Enqueue(cat2);
            shelter.Enqueue(cat3);
            shelter.Enqueue(dog1);
            shelter.Enqueue(dog2);
            shelter.Enqueue(dog3);
            shelter.Enqueue(fish);

            Console.WriteLine(shelter.Dequeue("dog").Name);

            Console.WriteLine(shelter.Front.Name);
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            Cat cat1 = new Cat("cat 1");
            Cat cat2 = new Cat("cat 2");
            Cat cat3 = new Cat("cat 3");
            Cat cat4 = new Cat("cat 4");
            Dog dog1 = new Dog("dog 1");
            Dog dog2 = new Dog("dog 2");
            Dog dog3 = new Dog("dog 3");


            AnimalShelter shelter = new AnimalShelter(dog1);

            shelter.Enqueue(cat1);
            shelter.Enqueue(dog2);
            shelter.Enqueue(dog3);
            shelter.Enqueue(cat2);
            shelter.Enqueue(cat3);
            shelter.Enqueue(cat4);

            Console.WriteLine($"First animal in queue is: {shelter.Peek().Value}");
            Console.WriteLine($"Check for first cat in queue: {shelter.Dequeue("cat").Value}");
            Console.WriteLine($"Check firt animal in queue even after previous dequeue: {shelter.Peek().Value}");
        }
Exemplo n.º 6
0
        /// <summary>
        ///     Instantiates and runs an AnimalShelter instance for CLI
        /// </summary>
        static void FifoAnimalShelter()
        {
            AnimalShelter shelter = new AnimalShelter();

            List <Animal> animals = new List <Animal>();

            Cat wiskers = new Cat();
            Cat bonkers = new Cat();
            Cat catters = new Cat();
            Dog spot    = new Dog();
            Dog bone    = new Dog();
            Dog wags    = new Dog();

            animals.Add(wiskers);
            animals.Add(spot);
            animals.Add(bonkers);
            animals.Add(catters);
            animals.Add(bone);
            animals.Add(wags);

            foreach (var animal in animals)
            {
                shelter.Enqueue(animal);
            }


            while (true)
            {
                Console.WriteLine("Welcome to Rainin' Cats and Dogs!");
                Console.WriteLine("1] Adopt");
                Console.WriteLine("2] Deopt");
                string selectAction = Console.ReadLine();


                if (selectAction == "1")
                {
                    Console.WriteLine("Adopt: Cat or Dog?");
                    Console.WriteLine("1] Cat");
                    Console.WriteLine("2] Dog");
                    string selectType = Console.ReadLine();

                    if (selectType == "1")
                    {
                        Cat adopteeCat = (Cat)shelter.Dequeue("cat");
                        Console.WriteLine("Cat with tag: " + adopteeCat.ID + " says " + adopteeCat.MakeNoise() + "[Thanks for atopting me!]");
                        Console.ReadLine();
                        Console.Clear();
                    }

                    if (selectType == "2")
                    {
                        Dog adopteeDog = (Dog)shelter.Dequeue("dog");
                        Console.WriteLine("Dog with tag: " + adopteeDog.ID + " says " + adopteeDog.MakeNoise() + "[Thanks for atopting me!]");
                        Console.ReadLine();
                        Console.Clear();
                    }
                    else
                    {
                        Console.WriteLine("I'm sorry, what?");
                        Console.ReadLine();
                        Console.Clear();
                    }
                }
                else if (selectAction == "2")
                {
                    Console.WriteLine("Adopt: Cat or Dog?");
                    Console.WriteLine("1] Cat");
                    Console.WriteLine("2] Dog");
                    string selectType = Console.ReadLine();


                    if (selectType == "1")
                    {
                        Cat deCat = new Cat();
                        Console.WriteLine(deCat.MakeNoise() + " [bye!]");
                        shelter.Enqueue(deCat);
                        Console.ReadLine();
                        Console.Clear();
                    }
                    else if (selectType == "2")
                    {
                        Dog deDog = new Dog();
                        Console.WriteLine(deDog.MakeNoise() + " [bye!]");
                        shelter.Enqueue(deDog);
                        Console.ReadLine();
                        Console.Clear();
                    }
                    else
                    {
                        Console.WriteLine("Um.. cat or dog?");
                        Console.ReadLine();
                        Console.Clear();
                    }
                    Console.ReadLine();
                }
                else
                {
                    Console.WriteLine("Please select 1 or 2");
                }
            }
        }