Ejemplo n.º 1
0
        private void Cage_Add_Button_Click(object sender, EventArgs e)
        {
            // Store Cage Values for Constructor
            decimal Cage_Quantity = Cage_Quantity1.Value;
            decimal Cage_Doors    = Cage_Doors1.Value;
            object  Animal_Type   = Animal_Type1.SelectedIndex;
            object  Cage_Location = Cage_Location1.SelectedIndex;

            Cage c = new Cage(cage_list.Count(), Cage_Quantity, Cage_Location1.SelectedIndex.ToString(), Cage_Doors, Animal_Type1.SelectedIndex.ToString());

            for (int j = 0; j < Cage_Quantity; ++j)
            {
                cage_list.Add(c);
            }

            // Populate List of Cages
            Delete_Cage_List.Items.Clear();
            CageUI_List.Items.Clear();
            for (int i = 0; i < cage_list.Count(); ++i)
            {
                CageUI_List.Items.Add(cage_list[i].c_Cage_Name.ToString());
                Delete_Cage_List.Items.Add(cage_list[i].c_Cage_Name.ToString());
            }

            MessageBox.Show("Cage(s) Added.");
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Cage <Ape>   apeCage   = new Cage <Ape>(CageType.Glass);
            Cage <Tiger> tigerCage = new Cage <Tiger>(CageType.Gitter);
            Ape          ape       = GenericObject.GenerateObject <Ape>(new object[] { "APE", "Bert", CageType.Glass });

            apeCage.AddAnimal(ape);
            Tiger tiger = GenericObject.GenerateObject <Tiger>(new object[] { "TIGER", "Luzifer", CageType.Glass });

            tigerCage.AddAnimal(tiger);
            apeCage.RemoveAnimal(ape);
        }
Ejemplo n.º 3
0
 public static void DemolishCage(long cageID)
 {
     try
     {
         Cage cageToBeDemolished = cagesDB.Find(x => x.CageID == cageID);
         cagesDB.Remove(cageToBeDemolished);
     }
     catch (Exception)
     {
         throw new UnitNotFoundException("There is no Cage with such ID!");
     }
 }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            ZooPark zoo   = new ZooPark();
            Lione   lion  = new Lione(zoo.GetManager(), 1, 10);
            Tiger   tiger = new Tiger(zoo.GetManager(), 3, 12);
            Cage    cage  = new Cage();

            cage.AddAnimal("Diego", tiger);
            cage.AddAnimal("Sam", lion);



            zoo.StartWork();
        }
Ejemplo n.º 5
0
        // Load DB from files
        private static void LoadData()
        {
            string[] fileEntries = Directory.GetFiles(FolderName);
            string[] fileData;
            string[] objectData;
            Object[] args = new Object[20];
            foreach (string fullFileName in fileEntries)
            {
                fileData = File.ReadAllLines(fullFileName);
                string dbName = System.IO.Path.GetFileName(fullFileName).Replace(".txt", "");
                foreach (var record in fileData)
                {
                    objectData = record.Split('#');
                    for (int i = 1; i < objectData.Length; i++)
                    {
                        args[i - 1] = objectData[i];
                    }
                    switch (dbName)
                    {
                    case "animals":
                        Animal animal = (Animal)Activator.CreateInstance(Type.GetType(objectData[0]), args);
                        AcquireAnimal(animal);
                        break;

                    case "budget":
                        BudgetInfo = (Budget)Activator.CreateInstance(Type.GetType(objectData[0]), args);
                        break;

                    case "cages":
                        Cage cage = (Cage)Activator.CreateInstance(Type.GetType(objectData[0]), args);
                        cagesDB.Add(cage);
                        break;

                    case "employees":
                        Employee employee = (Employee)Activator.CreateInstance(Type.GetType(objectData[0]), args);
                        staffDB.Add(employee);
                        break;

                    case "food":
                        FoodStorage food = (FoodStorage)Activator.CreateInstance(Type.GetType(objectData[0]), args);
                        foodStoragesDB.Add(food);
                        break;

                    default:
                        break;
                    }
                }
            }
        }
        static void Main(string[] args)
        {
            Cage c0 = new Cage(5);

            c0.Add(new Animal("Kormos", true, 10, Animal_type.dog));
            c0.Add(new Animal("Kormos_0", true, 10, Animal_type.dog));
            c0.Add(new Animal("Kormos_1", true, 125, Animal_type.bear));
            c0.Add(new Animal("Kormos_2", false, 1, Animal_type.cat));

            /*
             * Console.WriteLine(c0.TypeNum(Animal_type.bear));
             * Console.WriteLine(c0.TypeNum(Animal_type.cat));
             * Console.WriteLine(c0.TypeNum(Animal_type.dog));
             */
            /*
             * Console.WriteLine(c0.TypeAndGender(Animal_type.bear, false));
             * Console.WriteLine(c0.TypeAndGender(Animal_type.bear, true));
             */

            // Animal[] anims = c0.TypeAnimals(Animal_type.bear);

            // Console.WriteLine(c0.TypeAvgWeight(Animal_type.dog));

            /*
             * Cat c = new Cat("Kormos_21", true, 1);
             * c.Meow();
             */

            /*
             * Animal[] anims = new Animal[3];
             * anims[0] = c;
             *
             * anims[1] = new Dog("Kormos_22", false, 10);
             *
             * (anims[1] as Dog).Bark(); // null
             * ((Dog)anims[1]).Bark(); // invalid cast
             */

            Console.ReadKey();
        }
Ejemplo n.º 7
0
        static void Main()
        {
            Cage cagney = new Cage("Rainforest", true);



            //int inputAnimal;
            //bool loop = true;

            //while (loop == true)
            //{
            //    Fish AnglerFish = new Fish("Cocaine", "male", false, "none", "cold water", true, true, 3, 2, "5m x 5m x 5m");
            //    Fish Blobfish = new Fish("Jack", "female", false, "paracetamol", "cold water", true, true, 1, -5, "5m x 5m x 5m");
            //    Fish Pufferfish = new Fish("Lol", "Male", true, "none", "warm water", true, true, 0.05, 25, "5m x 10m x 5m");

            //    Birds Toucan = new Birds("Frog", "male", false, "none", "rainforest", "Black and white", "Large", false, "10ft x 15ft", "squawk");
            //    Birds Cockatoo = new Birds("Kiril", "female", false, "none", "tropical", "Yellow and white", "Snall", false, "5ft x 10ft", "squawk and talk");
            //    Birds Macaw = new Birds("xavier", "female", false, "none", "tropical", "Yellow, Red, Blue, and Green", "Medium", false, "10ft x 15ft", "squawk and talk");

            //    Mammals redPanda = new Mammals("THE WONDERFUL THING ABOUT TIGERS", "Female", false, "None", "cold climates", "FLUFFY", "Squeak", "10pm-5am", 150);
            //    Mammals PolarBear = new Mammals("mog", "Female", false, "None", "Arctic tundra", "Thick fur", "growl", "7pm-8am", 100);
            //    Mammals Tiger = new Mammals("Polly", "Female", false, "None", "Asia", "Thin fur", "growl", "9pm-5am", 300);
            //    Mammals Cheetah = new Mammals("Margaret", "Fe", false, "Pills", "Savannah", "Thin fur", "growl", "9pm-5am", 300);
            //    Mammals Dolphin = new Mammals("Steven", "Female", false, "None", "Tropical Oceans", "Skin", "Whistles and clicks", "-", 400);
            //    Mammals Lemur = new Mammals("Gary", "Male", false, "none", "Treetops", "Slightly Fluffy", "Squeal", "10pm-5am", 150);
            //    Mammals Orca = new Mammals("Dave", "Neuter", true, "nope", "lol", "Skin", "Whale noises", "-", 400);

            //    Animal[] animals = new Animal[] { redPanda, PolarBear, Tiger, Cheetah, Dolphin, Lemur, Orca, Toucan, Cockatoo, Macaw, AnglerFish, Blobfish, Pufferfish };

            //    Console.WriteLine("~~~~~~ENTER AN ANIMAL!~~~~~~");
            //    Console.WriteLine("MAMMALS");
            //    Console.WriteLine("1 - Red Panda");
            //    Console.WriteLine("2 - Polar Bear");
            //    Console.WriteLine("3 - Tiger");
            //    Console.WriteLine("4 - Cheetah");
            //    Console.WriteLine("5 - Dolphin");
            //    Console.WriteLine("6 - Lemur");
            //    Console.WriteLine("7 - Orca");
            //    Console.WriteLine("BIRDS");
            //    Console.WriteLine("8 - Toucan");
            //    Console.WriteLine("9 - Cockatoo");
            //    Console.WriteLine("10 - Macaw");
            //    Console.WriteLine("FISH");
            //    Console.WriteLine("11 - Angler Fish");
            //    Console.WriteLine("12 - Blobfish");
            //    Console.WriteLine("13 - Pufferfish");

            //    //for (int x = 0; x != animals.Length; x++)
            //    //{
            //    //    Console.WriteLine(x + 1 + " - " + animals.Name[x]);
            //    //}

            //    Console.WriteLine("~~~~~~~~~~~~~~~~~~~~");
            //    //Console.WriteLine("-1 -  Create an animal");
            //    Console.WriteLine("0 - Exit the Program");
            //    Console.Write(">>> ");
            //    inputAnimal = Int32.Parse(Console.ReadLine());

            //    Console.Clear();


            //    if (inputAnimal == 0)
            //    {
            //        loop = false;
            //    }
            //    //else if (inputAnimal == -1)
            //    //{
            //    //    animalMaker();
            //    //}
            //    else
            //    {
            //        DisplayStuff(animals[inputAnimal - 1]);
            //        Console.WriteLine("~~~~~~~~~~~~~~~~~~~");
            //        Console.WriteLine("Press enter to exit");
            //        Console.Write(">>> ");
            //        Console.ReadLine();
            //        Console.Clear();
            //    }

            //}
        }
Ejemplo n.º 8
0
 public static void Main(string[] args)
 {
     Cage d = Cage.CreateCage(Cage.CageSize.Medium);
 }
Ejemplo n.º 9
0
        private void Cage_Add_Button_Click(object sender, EventArgs e)
        {
            // Store Cage Values for Constructor
              decimal Cage_Quantity = Cage_Quantity1.Value;
              decimal Cage_Doors = Cage_Doors1.Value;
              object Animal_Type = Animal_Type1.SelectedIndex;
              object Cage_Location = Cage_Location1.SelectedIndex;

              Cage c = new Cage(cage_list.Count(), Cage_Quantity, Cage_Location1.SelectedIndex.ToString(), Cage_Doors, Animal_Type1.SelectedIndex.ToString());
              for(int j = 0; j < Cage_Quantity; ++j)
            cage_list.Add(c);

              // Populate List of Cages
              Delete_Cage_List.Items.Clear();
              CageUI_List.Items.Clear();
              for (int i = 0; i < cage_list.Count(); ++i)
              {
            CageUI_List.Items.Add(cage_list[i].c_Cage_Name.ToString());
            Delete_Cage_List.Items.Add(cage_list[i].c_Cage_Name.ToString());
              }

              MessageBox.Show("Cage(s) Added.");
        }
Ejemplo n.º 10
0
 // Cages management
 public static void BuildCage(Cage cage)
 {
     cagesDB.Add(cage);
     Budget.Instance.AddExpense(cage.Type.ToString(), cage.Price);
 }
Ejemplo n.º 11
0
 public void AddCage(Cage cage)
 {
     _cages.Add(cage);
 }
Ejemplo n.º 12
0
        static void Process(int choose)
        {
            zoo = new Zoo();

            switch (choose)
            {
            case 1:
            {
                Console.WriteLine("Add a new cage: ");
                Console.Write("--- Enter the cage's number: ");
                string str = Console.ReadLine();

                while (!int.TryParse(str, out cageNumber))
                {
                    Console.Write("Enter again! ");
                    str = Console.ReadLine();
                }
                MenuAnimal();


                cage = new Cage(cageNumber);
                zoo.AddAnimal(cage);
            }
            break;

            case 2:
            {
                Console.WriteLine("Enter the cage's number you want to remove: ");
                string str = Console.ReadLine();

                while (!int.TryParse(str, out cageNumber))
                {
                    Console.Write("Enter again! ");
                    str = Console.ReadLine();
                }
                zoo.RemoveCage(cageNumber);
            }
            break;

            case 3:
            {
                Console.Write("Choose 'dog'(press 1), 'cat' (press 2) or 'tiger' (press 3) to add: ");
                str = Console.ReadLine();
                int child;
                while (!int.TryParse(str, out child))
                {
                    Console.Write("Enter again! ");
                    str = Console.ReadLine();
                }
                switch (child)
                {
                case 1:
                    Console.Write("Enter the name of dog: ");
                    string name = Console.ReadLine();

                    dog = new Dog(name);
                    cage.AddAnimal(dog);
                    break;

                case 2:
                    Console.Write("Enter the name of cat: ");
                    name = Console.ReadLine();
                    cat  = new Cat(name);
                    cage.AddAnimal(cat);
                    break;

                case 3:
                    Console.Write("Enter the name of tiger: ");
                    name  = Console.ReadLine();
                    tiger = new Tiger(name);
                    cage.AddAnimal(tiger);
                    break;

                default:
                    Console.Write("Enter again! ");
                    str = Console.ReadLine();
                    break;
                }
            }
            break;

            case 4:
            {
                Console.Write("Enter the name of animal you want to remove: ");
                string name = Console.ReadLine();
                cage.RemoveAnimal(name);
            }
            break;

            case 5:
            {
                Console.WriteLine("\nIterate animal in the cage:");
                Console.Write("Animal");
                cage.IterateAnimals();
            }
            break;

            case 6:
                Console.WriteLine("Exit.");
                Environment.Exit(Environment.ExitCode);
                break;

            default:
                Console.WriteLine("Enter 1, 2, 3, 4 or 5: ");
                Menu();
                break;
            }
            Menu();
        }