コード例 #1
0
        /// <summary>
        /// Finds the cage based on animal type.
        /// </summary>
        /// <param name="animalType">The type of cage to be searched.</param>
        /// <returns>The found cage.</returns>
        public Cage FindCage(Type animalType)
        {
            Cage result = null;

            this.cages.TryGetValue(animalType, out result);
            return(result);
        }
コード例 #2
0
ファイル: Zoo.cs プロジェクト: mtaylorhayden/OOP
        /// <summary>
        /// Removes the animal from the zoo.
        /// </summary>
        /// <param name="animal"> The animal being removed from the zoo.</param>
        public void RemoveAnimal(Animal animal)
        {
            // Loop through the zoo's list of guests.
            foreach (Guest g in this.guests)
            {
                // If any of the guests in the list of guests have adpoted then animal which is being removed...
                if (g.AdoptedAnimal == animal)
                {
                    // Remove the animal from the guest.
                    g.AdoptedAnimal = null;

                    // Remove the guest from the cage.
                    Cage newCage = this.FindCage(animal.GetType());
                    newCage.Remove(g);
                }
            }

            // Remove the animal from the list of animals.
            this.animals.Remove(animal);

            // Find the animals cage and give the cage the type of animal being put into the cage.
            Cage cage = this.FindCage(animal.GetType());

            // Removes the animal from the cage.
            cage.Remove(animal);
        }
コード例 #3
0
ファイル: Zoo.cs プロジェクト: mtaylorhayden/OOP
        /// <summary>
        /// Initializes a new instance of the Zoo class.
        /// </summary>
        /// <param name="name">The name of the zoo.</param>
        /// <param name="capacity">The maximum number of guests the zoo can accommodate at a given time.</param>
        /// <param name="restroomCapacity">The capacity of the zoo's restrooms.</param>
        /// <param name="animalFoodPrice">The price of a pound of food from the zoo's animal snack machine.</param>
        /// <param name="ticketPrice">The price of an admission ticket to the zoo.</param>
        /// <param name="boothMoneyBalance">The initial money balance of the zoo's ticket booth.</param>
        /// <param name="attendant">The zoo's ticket booth attendant.</param>
        /// <param name="vet">The zoo's birthing room vet.</param>
        /// <param name="waterBottlePrice"> The price of the zoo's water bottles.</param>
        public Zoo(string name, int capacity, int restroomCapacity, decimal animalFoodPrice, decimal ticketPrice, decimal boothMoneyBalance, Employee attendant, Employee vet, decimal waterBottlePrice)
        {
            this.animals            = new List <Animal>();
            this.animalSnackMachine = new VendingMachine(animalFoodPrice, new Account());
            this.b168        = new BirthingRoom(vet);
            this.capacity    = capacity;
            this.cages       = new List <Cage>();
            this.guests      = new List <Guest>();
            this.ladiesRoom  = new Restroom(restroomCapacity, Gender.Female);
            this.mensRoom    = new Restroom(restroomCapacity, Gender.Male);
            this.name        = name;
            this.ticketBooth = new MoneyCollectingBooth(attendant, ticketPrice, waterBottlePrice, new MoneyBox());
            this.ticketBooth.AddMoney(boothMoneyBalance);
            this.informationBooth = new GivingBooth(attendant);

            // Loop through the enumerator. Create a cage for every different type of animal.
            foreach (AnimalType a in Enum.GetValues(typeof(AnimalType)))
            {
                // Create a new cage and get the correct cage type.
                Cage cage = new Cage(400, 800, Animal.ConvertAnimalTypeToType(a));

                // Add the created cage to the list of cages.
                this.cages.Add(cage);
            }
        }
コード例 #4
0
        /// <summary>
        /// Removes an animal from the zoo.
        /// </summary>
        /// <param name="animal">The animal to remove.</param>
        public void RemoveAnimal(Animal animal)
        {
            animal.IsActive = false;

            this.animals.Remove(animal);
            Cage cage = this.FindCage(animal.GetType());

            cage.Remove(animal);
        }
コード例 #5
0
        /// <summary>
        /// Finds the cage based on the type of animal.
        /// </summary>
        /// <param name="animalType"> The type of animal.</param>
        /// <returns> The cage for the animal.</returns>
        public Cage FindCage(Type animalType)
        {
            Cage cage = null;

            // Finds the cage of the animals type and the cages type.
            this.cages.TryGetValue(animalType, out cage);

            return(cage);
        }
コード例 #6
0
ファイル: Zoo.cs プロジェクト: mtaylorhayden/OOP
        /// <summary>
        /// Adds an animal to the zoo.
        /// </summary>
        /// <param name="animal">The animal to add.</param>
        public void AddAnimal(Animal animal)
        {
            // Add the animal to the list of animals.
            this.animals.Add(animal);

            // Find the animals cage and give the cage the type of animal being put into the cage.
            Cage cage = this.FindCage(animal.GetType());

            // Add the animal to the cage.
            cage.Add(animal);
        }
コード例 #7
0
ファイル: Zoo.cs プロジェクト: mtaylorhayden/OOP
        /// <summary>
        /// Initializes a new instance of the Zoo class.
        /// </summary>
        /// <param name="name">The name of the zoo.</param>
        /// <param name="capacity">The maximum number of guests the zoo can accommodate at a given time.</param>
        /// <param name="restroomCapacity">The capacity of the zoo's restrooms.</param>
        /// <param name="animalFoodPrice">The price of a pound of food from the zoo's animal snack machine.</param>
        /// <param name="ticketPrice">The price of an admission ticket to the zoo.</param>
        /// <param name="boothMoneyBalance">The initial money balance of the zoo's ticket booth.</param>
        /// <param name="attendant">The zoo's ticket booth attendant.</param>
        /// <param name="vet">The zoo's birthing room vet.</param>
        /// <param name="waterBottlePrice"> The price of the zoo's water bottles.</param>
        public Zoo(string name, int capacity, int restroomCapacity, decimal animalFoodPrice, decimal ticketPrice, decimal boothMoneyBalance, Employee attendant, Employee vet, decimal waterBottlePrice)
        {
            this.animalSnackMachine = new VendingMachine(animalFoodPrice, new Account());
            this.b168        = new BirthingRoom(vet);
            this.capacity    = capacity;
            this.cages       = new List <Cage>();
            this.guests      = new List <Guest>();
            this.ladiesRoom  = new Restroom(restroomCapacity, Gender.Female);
            this.mensRoom    = new Restroom(restroomCapacity, Gender.Male);
            this.name        = name;
            this.ticketBooth = new MoneyCollectingBooth(attendant, ticketPrice, waterBottlePrice, new MoneyBox());
            this.ticketBooth.AddMoney(boothMoneyBalance);
            this.informationBooth = new GivingBooth(attendant);

            // Make a new list of aniamls and add them to the list.
            this.animals = new List <Animal>()
            {
                new Chimpanzee("Bobo", 10, 128.2, Gender.Male),
                new Chimpanzee("Bubbles", 3, 103.8, Gender.Female),
                new Dingo("Spot", 5, 41.3, Gender.Male),
                new Dingo("Maggie", 6, 37.2, Gender.Female),
                new Dingo("Toby", 0, 15.0, Gender.Male),
                new Eagle("Ari", 12, 10.1, Gender.Female),
                new Hummingbird("Buzz", 2, 0.02, Gender.Male),
                new Hummingbird("Bitsy", 1, 0.03, Gender.Female),
                new Kangaroo("Kanga", 8, 72.0, Gender.Female),
                new Kangaroo("Roo", 0, 23.9, Gender.Male),
                new Kangaroo("Jake", 9, 153.5, Gender.Male),
                new Ostrich("Stretch", 26, 231.7, Gender.Male),
                new Ostrich("Speedy", 30, 213.0, Gender.Female),
                new Platypus("Patti", 13, 4.4, Gender.Female),
                new Platypus("Bill", 11, 4.9, Gender.Male),
                new Platypus("Ted", 0, 1.1, Gender.Male),
                new Shark("Bruce", 19, 810.6, Gender.Female),
                new Shark("Anchor", 17, 458.0, Gender.Male),
                new Shark("Chum", 14, 377.3, Gender.Male),
                new Squirrel("Chip", 4, 1.0, Gender.Male),
                new Squirrel("Dale", 4, 0.9, Gender.Male)
            };

            // Loop through the enumerator. Create a cage for every different type of animal.
            foreach (AnimalType a in Enum.GetValues(typeof(AnimalType)))
            {
                // Create a new cage and get the correct cage type.
                Cage cage = new Cage(400, 800, Animal.ConvertAnimalTypeToType(a));

                // Add the created cage to the list of cages.
                this.cages.Add(cage);
            }
        }
コード例 #8
0
        /// <summary>
        /// Adds an animal to the zoo.
        /// </summary>
        /// <param name="animal">The animal to add.</param>
        public void AddAnimal(Animal animal)
        {
            animal.OnPregnant = a => this.b168.PregnantAnimals.Enqueue(a);

            animal.IsActive = true;

            this.animals.Add(animal);
            Cage cage = this.FindCage(animal.GetType());

            cage = cages[animal.GetType()];
            cage.Add(animal);
            if (animal.IsPregnant == true)
            {
                this.b168.PregnantAnimals.Enqueue(animal);
            }
        }
コード例 #9
0
        /// <summary>
        /// Adds an animal to the zoo.
        /// </summary>
        /// <param name="animal">The animal to add.</param>
        public void AddAnimal(Animal animal)
        {
            // Find the animal's cage.
            Cage cage = this.FindCage(animal.GetType());

            // Add an animal to the zoo list.
            this.animals.Add(animal);

            if (animal.IsPregnant == true)
            {
                this.b168.PregnantAnimals.Enqueue(animal);
            }

            // Add the animal to the cage.
            cage.Add(animal);
        }
コード例 #10
0
ファイル: Zoo.cs プロジェクト: mtaylorhayden/OOP
        /// <summary>
        /// Finds the cage based on the type of animal.
        /// </summary>
        /// <param name="animalType"> The type of animal.</param>
        /// <returns> The cage for the animal.</returns>
        public Cage FindCage(Type animalType)
        {
            Cage cage = null;

            // Look through the list of cages.
            foreach (Cage c in this.cages)
            {
                // If the cage's type is the same as the animal's type then...
                if (c.AnimalType == animalType)
                {
                    cage = c;

                    break;
                }
            }
            return(cage);
        }
コード例 #11
0
ファイル: Zoo.cs プロジェクト: jonnymonty/School-Project-Zoo
        /// <summary>
        /// Removes a guest from the zoo.
        /// </summary>
        /// <param name="guest">The guest to remove.</param>
        public void RemoveGuest(Guest guest)
        {
            this.guests.Remove(guest);

            guest.IsActive = false;

            if (guest.AdoptedAnimal != null)
            {
                Cage cage = this.FindCage(guest.AdoptedAnimal.GetType());

                cage.Remove(guest);
            }

            if (this.OnRemoveGuest == null)
            {
                this.OnRemoveGuest(guest);
            }
        }
コード例 #12
0
        /// <summary>
        /// Removes an animal from the list of animals in the zoo.
        /// </summary>
        /// <param name="animal">The animal to remove.</param>
        public void RemoveAnimal(Animal animal)
        {
            Guest guest = null;

            // Find the animal's cage.
            Cage cage = this.FindCage(animal.GetType());

            foreach (Guest g in this.Guests)
            {
                guest = g;

                if (guest.AdoptedAnimal == animal)
                {
                    guest.AdoptedAnimal = null;
                    cage.Remove(guest);
                }
            }

            // Remove the animal from the zoo list.
            this.animals.Remove(animal);

            // Remove animal from the cage.
            cage.Remove(animal);
        }
コード例 #13
0
        /// <summary>
        /// Adds an animal to the zoo.
        /// </summary>
        /// <param name="animal">The animal to add.</param>
        public void AddAnimal(Animal animal)
        {
            // Call the OnAddGuest Delegate.
            this.OnAddAnimal(animal);


            // Add the animal to the list of animals.
            this.animals.Add(animal);

            // Put the animal in the queue of reproducers if it's pregnant.
            if (animal.IsPregnant == true)
            {
                this.b168.PregnantAnimals.Enqueue(animal);
            }

            // Find the animals cage and give the cage the type of animal being put into the cage.
            Cage cage = this.cages[animal.GetType()];


            // Cage cage = this.FindCage(animal.GetType());

            // Add the animal to the cage.
            cage.Add(animal);
        }
コード例 #14
0
        /// <summary>
        /// Initializes a new instance of the Zoo class.
        /// </summary>
        /// <param name="name">The name of the zoo.</param>
        /// <param name="capacity">The maximum number of guests the zoo can accommodate at a given time.</param>
        /// <param name="restroomCapacity">The capacity of the zoo's restrooms.</param>
        /// <param name="animalFoodPrice">The price of a pound of food from the zoo's animal snack machine.</param>
        /// <param name="ticketPrice">The price of an admission ticket to the zoo.</param>
        /// <param name="waterBottlePrice">The price of a water bottle.</param>
        /// <param name="boothMoneyBalance">The money balance of the money collecting booth.</param>
        /// <param name="attendant">The zoo's ticket booth attendant.</param>
        /// <param name="vet">The zoo's birthing room vet.</param>
        public Zoo(string name, int capacity, int restroomCapacity, decimal animalFoodPrice, decimal ticketPrice, decimal waterBottlePrice, decimal boothMoneyBalance, Employee attendant, Employee vet)
        {
            this.animals            = new List <Animal>();
            this.animalSnackMachine = new VendingMachine(animalFoodPrice, new Account());
            this.b168 = new BirthingRoom(vet);

            this.b168.OnTemperatureChange = (previousTemp, currentTemp) =>
            {
                if (this.OnBirthingRoomTemperatureChange != null)
                {
                    this.OnBirthingRoomTemperatureChange(previousTemp, currentTemp);
                }
            };

            this.capacity         = capacity;
            this.guests           = new List <Guest>();
            this.informationBooth = new GivingBooth(attendant);
            this.ladiesRoom       = new Restroom(restroomCapacity, Gender.Female);
            this.mensRoom         = new Restroom(restroomCapacity, Gender.Male);
            this.name             = name;
            this.ticketBooth      = new MoneyCollectingBooth(attendant, ticketPrice, waterBottlePrice, new MoneyBox());
            this.ticketBooth.AddMoney(boothMoneyBalance);

            foreach (AnimalType at in Enum.GetValues(typeof(AnimalType)))
            {
                Cage cage = new Cage(400, 800);
                cages.Add(Animal.ConvertAnimalTypeToType(at), cage);
            }

            // Animals for sorting
            this.AddAnimal(new Chimpanzee("Bobo", 10, 128.2, Gender.Male));
            this.AddAnimal(new Chimpanzee("Bubbles", 3, 103.8, Gender.Female));
            this.AddAnimal(new Dingo("Spot", 5, 41.3, Gender.Male));
            this.AddAnimal(new Dingo("Maggie", 6, 37.2, Gender.Female));
            this.AddAnimal(new Dingo("Toby", 0, 15.0, Gender.Male));
            this.AddAnimal(new Eagle("Ari", 12, 10.1, Gender.Female));
            this.AddAnimal(new Hummingbird("Buzz", 2, 0.02, Gender.Male));
            this.AddAnimal(new Hummingbird("Bitsy", 1, 0.03, Gender.Female));
            this.AddAnimal(new Kangaroo("Kanga", 8, 72.0, Gender.Female));
            this.AddAnimal(new Kangaroo("Roo", 0, 23.9, Gender.Male));
            this.AddAnimal(new Kangaroo("Jake", 9, 153.5, Gender.Male));
            this.AddAnimal(new Ostrich("Stretch", 26, 231.7, Gender.Male));
            this.AddAnimal(new Ostrich("Speedy", 30, 213.0, Gender.Female));
            this.AddAnimal(new Platypus("Patti", 13, 4.4, Gender.Female));
            this.AddAnimal(new Platypus("Bill", 11, 4.9, Gender.Male));
            this.AddAnimal(new Platypus("Ted", 0, 1.1, Gender.Male));
            this.AddAnimal(new Shark("Bruce", 19, 810.6, Gender.Female));
            this.AddAnimal(new Shark("Anchor", 17, 458.0, Gender.Male));
            this.AddAnimal(new Shark("Chum", 14, 377.3, Gender.Male));
            this.AddAnimal(new Squirrel("Chip", 4, 1.0, Gender.Male));
            this.AddAnimal(new Squirrel("Dale", 4, 0.9, Gender.Male));

            // Guests for sorting
            this.AddGuest(new Guest("Greg", 35, 100.0m, WalletColor.Crimson, Gender.Male, new Account()), new Ticket(0m, 0, 0));
            this.AddGuest(new Guest("Darla", 7, 10.0m, WalletColor.Brown, Gender.Female, new Account()), new Ticket(0m, 0, 0));
            this.AddGuest(new Guest("Anna", 8, 12.56m, WalletColor.Brown, Gender.Female, new Account()), new Ticket(0m, 0, 0));
            this.AddGuest(new Guest("Matthew", 42, 10.0m, WalletColor.Brown, Gender.Male, new Account()), new Ticket(0m, 0, 0));
            this.AddGuest(new Guest("Doug", 7, 11.10m, WalletColor.Brown, Gender.Male, new Account()), new Ticket(0m, 0, 0));
            this.AddGuest(new Guest("Jared", 17, 31.70m, WalletColor.Brown, Gender.Male, new Account()), new Ticket(0m, 0, 0));
            this.AddGuest(new Guest("Sean", 34, 20.50m, WalletColor.Brown, Gender.Male, new Account()), new Ticket(0m, 0, 0));
            this.AddGuest(new Guest("Sally", 52, 134.20m, WalletColor.Brown, Gender.Female, new Account()), new Ticket(0m, 0, 0));
        }
コード例 #15
0
        /// <summary>
        /// Initializes a new instance of the Zoo class.
        /// </summary>
        /// <param name="name">The name of the zoo.</param>
        /// <param name="capacity">The maximum number of guests the zoo can accommodate at a given time.</param>
        /// <param name="restroomCapacity">The capacity of the zoo's restrooms.</param>
        /// <param name="animalFoodPrice">The price of a pound of food from the zoo's animal snack machine.</param>
        /// <param name="ticketPrice">The price of an admission ticket to the zoo.</param>
        /// <param name="boothMoneyBalance">The initial money balance of the zoo's ticket booth.</param>
        /// <param name="attendant">The zoo's ticket booth attendant.</param>
        /// <param name="vet">The zoo's birthing room vet.</param>
        /// <param name="waterBottlePrice"> The price of the zoo's water bottles.</param>
        public Zoo(string name, int capacity, int restroomCapacity, decimal animalFoodPrice, decimal ticketPrice, decimal boothMoneyBalance, Employee attendant, Employee vet, decimal waterBottlePrice)
        {
            this.animalSnackMachine = new VendingMachine(animalFoodPrice, new Account());
            this.b168 = new BirthingRoom(vet);

            // Plugs the HandleBirthingRoomTemperatureChange method into the delegate.
            this.b168.OnTemperatureChange += this.HandleBirthingRoomTemperatureChange;

            this.capacity    = capacity;
            this.cages       = new Dictionary <Type, Cage>();
            this.guests      = new List <Guest>();
            this.ladiesRoom  = new Restroom(restroomCapacity, Gender.Female);
            this.mensRoom    = new Restroom(restroomCapacity, Gender.Male);
            this.name        = name;
            this.ticketBooth = new MoneyCollectingBooth(attendant, ticketPrice, waterBottlePrice, new MoneyBox());
            this.ticketBooth.AddMoney(boothMoneyBalance);
            this.informationBooth = new GivingBooth(attendant);

            //// Make a new list of aniamls and add them to the list.
            this.animals = new List <Animal>();
            //{
            //    new Chimpanzee("Bubbles", 3, 103.8, Gender.Female),
            //    new Dingo("Spot", 5, 41.3, Gender.Male),
            //    new Dingo("Maggie", 6, 37.2, Gender.Female),
            //    new Dingo("Toby", 0, 15.0, Gender.Male),
            //    new Eagle("Ari", 12, 10.1, Gender.Female),
            //    new Hummingbird("Buzz", 2, 0.02, Gender.Male),
            //    new Hummingbird("Bitsy", 1, 0.03, Gender.Female),
            //    new Kangaroo("Kanga", 8, 72.0, Gender.Female),
            //    new Kangaroo("Roo", 0, 23.9, Gender.Male),
            //    new Kangaroo("Jake", 9, 153.5, Gender.Male),
            //    new Ostrich("Stretch", 26, 231.7, Gender.Male),
            //    new Ostrich("Speedy", 30, 213.0, Gender.Female),
            //    new Platypus("Patti", 13, 4.4, Gender.Female),
            //    new Platypus("Bill", 11, 4.9, Gender.Male),
            //    new Platypus("Ted", 0, 1.1, Gender.Male),
            //    new Shark("Bruce", 19, 810.6, Gender.Female),
            //    new Shark("Anchor", 17, 458.0, Gender.Male),
            //    new Shark("Chum", 14, 377.3, Gender.Male),
            //    new Squirrel("Chip", 4, 1.0, Gender.Male),
            //    new Squirrel("Dale", 4, 0.9, Gender.Male)
            //};

            // Loop through the enumerator. Create a cage for every different type of animal.
            foreach (AnimalType a in Enum.GetValues(typeof(AnimalType)))
            {
                // Create a new cage and get the correct cage type.
                Cage cage = new Cage(400, 800);

                // Add the created cage to the list of cages.
                this.cages.Add(Animal.ConvertAnimalTypeToType(a), cage);
            }

            //// Creates and adds lots of animals to their own lists of childern.
            //Animal brutus = new Dingo("Brutus", 3, 36.0, Gender.Male);
            //Animal coco = new Dingo("Coco", 7, 38.3, Gender.Female);
            //coco.AddChild(brutus);

            //Animal toby = new Dingo("Toby", 4, 42.5, Gender.Male);
            //Animal steve = new Dingo("Steve", 4, 41.1, Gender.Male);
            //Animal maggie = new Dingo("Maggie", 7, 34.8, Gender.Female);
            //maggie.AddChild(toby);
            //maggie.AddChild(steve);

            //Animal lucy = new Dingo("Lucy", 7, 36.5, Gender.Female);
            //Animal ted = new Dingo("Ted", 7, 39.7, Gender.Male);
            //Animal bella = new Dingo("Bella", 10, 40.2, Gender.Female);
            //bella.AddChild(coco);
            //bella.AddChild(maggie);
            //bella.AddChild(lucy);
            //bella.AddChild(ted);

            //List<Animal> tempList = new List<Animal>();
            //tempList.Add(bella);
            //tempList.Add(new Dingo("Max", 12, 46.9, Gender.Male));

            //// Call the recursive method.
            //this.AddAnimalsToZoo(tempList);
        }