static void FIFOAnimalShelter()
        {
            AnimalShelter shelter = new AnimalShelter(new Animal("Cat"));

            shelter.Enqueue(new Animal("cat"));
            shelter.Enqueue(new Animal("cat"));
            shelter.Enqueue(new Animal("Dog"));
            shelter.Enqueue(new Animal("Llama"));
            shelter.Enqueue(new Animal("cat"));
            shelter.Enqueue(new Animal("Dog"));
            shelter.Enqueue(new Animal("dog"));

            Console.WriteLine($"Front:{shelter.Front.Type} Rear:{shelter.Rear.Type}");
            shelter.Print();

            Animal adopted = shelter.Dequeue("cat");

            Console.WriteLine($"Front:{shelter.Front.Type} Rear:{shelter.Rear.Type}");
            shelter.Print();

            shelter.Dequeue("dog");
            Console.WriteLine($"Front:{shelter.Front.Type} Rear:{shelter.Rear.Type}");
            shelter.Print();

            shelter.Dequeue("Dog");
            Console.WriteLine($"Front:{shelter.Front.Type} Rear:{shelter.Rear.Type}");
            shelter.Print();
        }
Exemplo n.º 2
0
        static void FIFOAnimalShelter()
        {
            Cat cat1 = new Cat();
            Cat cat2 = new Cat();
            Dog dog1 = new Dog();
            Dog dog2 = new Dog();

            AnimalShelter animalShelter = new AnimalShelter(cat1);

            animalShelter.Enqueue(dog1);
            animalShelter.Enqueue(dog2);
            animalShelter.Enqueue(cat2);

            Console.WriteLine(animalShelter.Print());

            Console.WriteLine($"The animal taken out is {animalShelter.Dequeue("Dog").Name}");

            Console.WriteLine(animalShelter.Print());
        }
Exemplo n.º 3
0
        /// <summary>
        /// This is a basic test to make sure that everything works
        /// </summary>
        static void FIFOAnimalShelter()
        {
            AnimalShelter animalShelter = new AnimalShelter(new Animal("cat"));

            animalShelter.Enqueue(new Animal("dog"));
            animalShelter.Enqueue(new Animal("cat"));
            animalShelter.Enqueue(new Animal("dog"));
            animalShelter.Enqueue(new Animal("dog"));
            animalShelter.Enqueue(new Animal("cat"));
            animalShelter.Enqueue(new Animal("dog"));
            animalShelter.Enqueue(new Animal("dog"));
            animalShelter.Enqueue(new Animal("dog"));
            animalShelter.Enqueue(new Animal("cat"));
            animalShelter.Enqueue(new Animal("cat"));
            animalShelter.Print();
            string pref           = "dog";
            Animal dequeuedAnimal = animalShelter.Dequeue(pref);

            animalShelter.Print();
            Console.WriteLine(dequeuedAnimal.Value);
        }