コード例 #1
0
        /// <summary>
        /// Creates a new zoo.
        /// </summary>
        /// <returns> The created zoo.</returns>
        public static Zoo NewZoo()
        {
            Zoo zoo = new Zoo("Como Zoo", 1000, 4, 0.75m, 15.00m, 3640.25m, new Employee("Sam", 42), new Employee("Flora", 98), 3);

            // Add money to the animal snack machine.
            zoo.AnimalSnackMachine.AddMoney(42.75m);

            // Create the animals using the factory and add them all to the list of animals.

            Animal animal = AnimalFactory.CreateAnimal(AnimalType.Dingo, "Dolly", 4, 35.3, Gender.Female);

            animal.MakePregnant();

            zoo.AddAnimal(animal);

            animal = AnimalFactory.CreateAnimal(AnimalType.Dingo, "Dixie", 3, 33.8, Gender.Female);

            animal.MakePregnant();

            zoo.AddAnimal(animal);

            animal = AnimalFactory.CreateAnimal(AnimalType.Platypus, "Patty", 2, 15.5, Gender.Female);

            animal.MakePregnant();

            zoo.AddAnimal(animal);

            animal = AnimalFactory.CreateAnimal(AnimalType.Hummingbird, "Harold", 1, 0.5, Gender.Male);

            zoo.AddAnimal(animal);

            animal = AnimalFactory.CreateAnimal(AnimalType.Chimpanzee, "Noah", 12, 500, Gender.Male);

            zoo.AddAnimal(animal);

            animal = AnimalFactory.CreateAnimal(AnimalType.Eagle, "Tracy", 300, 10, Gender.Male);

            zoo.AddAnimal(animal);

            animal = AnimalFactory.CreateAnimal(AnimalType.Kangaroo, "Jeff", 25, 30, Gender.Male);

            zoo.AddAnimal(animal);

            animal = AnimalFactory.CreateAnimal(AnimalType.Ostrich, "Jake", 40, 200, Gender.Female);

            zoo.AddAnimal(animal);

            animal = AnimalFactory.CreateAnimal(AnimalType.Shark, "Max", 23, 185, Gender.Male);

            zoo.AddAnimal(animal);

            animal = AnimalFactory.CreateAnimal(AnimalType.Squirrel, "Matt", 21, 200, Gender.Male);

            zoo.AddAnimal(animal);

            Account account = new Account();

            account.AddMoney(50m);

            // Create a guest.
            Guest guest = new Guest("Greg", 44, 150.35m, WalletColor.Brown, Gender.Male, account);

            // Add the guest and sell the ticket to the guest.
            zoo.AddGuest(guest, zoo.SellTicket(guest));


            Wallet wallet = guest.Wallet;

            // Create a guest.
            guest = new Guest("Darla", 11, 25.25m, WalletColor.Salmon, Gender.Female, guest.Wallet);

            // Add the guest and sell the ticket to the guest.
            zoo.AddGuest(guest, zoo.SellTicket(guest));


            return(zoo);
        }
コード例 #2
0
ファイル: Zoo.cs プロジェクト: mtaylorhayden/OOP
        /// <summary>
        /// Creates a new zoo.
        /// </summary>
        /// <returns> The created zoo.</returns>
        public static Zoo NewZoo()
        {
            Zoo zoo = new Zoo("Como Zoo", 1000, 4, 0.75m, 15.00m, 3640.25m, new Employee("Sam", 42), new Employee("Flora", 98), 3);

            // Add money to the animal snack machine.
            zoo.AnimalSnackMachine.AddMoney(42.75m);

            // Define an animal variable.
            Animal animal;

            // Create a new Dingo and add him to the list of animals.
            animal = new Dingo("Dolly", 4, 35.3);

            animal.MakePregnant();

            zoo.AddAnimal(animal);

            // Create a new Dingo and add him to the list of animals.
            animal = new Dingo("Dixie", 3, 33.8);

            animal.MakePregnant();

            zoo.AddAnimal(animal);

            // Create a new platypus and add him to the list of animals.
            animal = new Platypus("Patty", 2, 15.5);

            animal.MakePregnant();

            zoo.AddAnimal(animal);

            // Create a new Hummingbird and add him to the list of animals.
            animal = new Hummingbird("Harold", 1, 0.5);

            zoo.AddAnimal(animal);

            // Create a new chimp and add him to the list of animals.
            animal = new Chimpanzee("Noah", 12, 500);

            zoo.AddAnimal(animal);

            // Create a new eagle and add him to the list of animals.
            animal = new Eagle("Tracy", 300, 10);

            zoo.AddAnimal(animal);

            // Create a new kangaroo and add him to the list of animals.
            animal = new Kangaroo("Jeff", 25, 30);

            zoo.AddAnimal(animal);

            // Create a new ostrich and add him to the list of animals.
            animal = new Ostrich("Jake", 40, 200);

            zoo.AddAnimal(animal);

            // Create a new shark and add him to the list of animals.
            animal = new Shark("Max", 23, 185);

            zoo.AddAnimal(animal);

            // Create a new squirrel and them to the list.
            animal = new Squirrel("Matt", 21, 200);

            zoo.AddAnimal(animal);

            // Create a guest.
            Guest guest = new Guest("Greg", 44, 150.35m, "Brown");

            // Add the guest and sell the ticket to the guest.
            zoo.AddGuest(guest, zoo.SellTicket(guest));

            // Create a guest.
            guest = new Guest("Darla", 11, 25.25m, "Salmon");

            // Add the guest and sell the ticket to the guest.
            zoo.AddGuest(guest, zoo.SellTicket(guest));

            return(zoo);
        }