Esempio n. 1
0
        static void Main()
        {
            string input = Console.ReadLine();
            AnimalFactory animalFactory=new AnimalFactory();
            FoodFactory foodFactory=new FoodFactory();
            Animal.Animal a;
            Food.Food food;
            while (!input.Equals("End"))
            {
                string[] animalInput = input.Split(' ');
                if (animalInput.Length == 4)
                {
                    a = animalFactory.CreateAnimal(animalInput[0], animalInput[1], double.Parse(animalInput[2]),
                        animalInput[3]);
                }
                else
                {
                    a = animalFactory.CreateAnimal(animalInput[0], animalInput[1], double.Parse(animalInput[2]),
                        animalInput[3],animalInput[4]);
                }

                string[] foodInput = Console.ReadLine().Split(' ');

                food = foodFactory.CreateFood(foodInput[0], int.Parse(foodInput[1]));

                a.MakeNoise();
                a.EatFood(food);
                Console.WriteLine(a);
                input = Console.ReadLine();
            }
        }
Esempio n. 2
0
        public void CreateAnimal_expectedSameAnimalType(animalType typeInput, animalType expected)
        {
            //Arrange

            //Act
            animalType typeActual = AnimalFactory.Instance().CreateAnimal(typeInput).type;

            //Assert

            Assert.AreEqual(expected, typeActual);
        }
Esempio n. 3
0
        //Add Herbivores
        private void AddHerbivores_Click(object sender, EventArgs e)
        {
            int animalAmount = Convert.ToInt32(numUDAnimalCount.Value);

            List <Animal> ToBeAddedAnimals = AnimalFactory.GenerateHerbivores(animalAmount, seed);

            AllAnimalList = AnimalFactory.MergeAnimalLists(AllAnimalList, ToBeAddedAnimals);

            SetAnimalBox(AllAnimalList);
            CheckFactory(animalAmount);
        }
Esempio n. 4
0
        public void GenerateRandomList_Test()
        {
            //Arrange
            int expectedAmount = 3;

            //Act
            List <Animal> actualAnimalList = AnimalFactory.GenerateRandomAnimals(expectedAmount, seed);

            //Assert
            Assert.AreEqual(expectedAmount, actualAnimalList.Count);
        }
Esempio n. 5
0
        public void C5_IsFriendsWith_C3()
        {
            var animals = new AnimalFactory(0, 1, 1, 0, 0, 0).GetCreatedAnimals().ToList();

            animals = OrderAnimals(animals);
            var C3 = animals.Where(animal => animals.IndexOf(animal) != 1).ToList();
            var C5 = animals.Where(animal => animals.IndexOf(animal) != 0).ToList();

            var result = C5[0].IsFriendsWith(C3);

            Assert.IsTrue(result);
        }
Esempio n. 6
0
        public void H1_IsFriendsWith_C1()
        {
            var animals = new AnimalFactory(1, 0, 0, 1, 0, 0).GetCreatedAnimals().ToList();

            animals = OrderAnimals(animals);
            var C1 = animals.Where(animal => animals.IndexOf(animal) != 1).ToList();
            var H1 = animals.Where(animal => animals.IndexOf(animal) != 0).ToList();

            var result = H1[0].IsFriendsWith(C1);

            Assert.IsFalse(result);
        }
Esempio n. 7
0
        public void H5_IsFriendsWith_C5()
        {
            var animals = new AnimalFactory(0, 0, 1, 0, 0, 1).GetCreatedAnimals().ToList();

            animals = OrderAnimals(animals);
            var C5 = animals.Where(animal => animals.IndexOf(animal) != 1).ToList();
            var H5 = animals.Where(animal => animals.IndexOf(animal) != 0).ToList();

            var result = H5[0].IsFriendsWith(C5);

            Assert.IsFalse(result);
        }
Esempio n. 8
0
        public void H3_IsFriendsWith_H5()
        {
            var animals = new AnimalFactory(0, 0, 0, 0, 1, 1).GetCreatedAnimals().ToList();

            animals = OrderAnimals(animals);
            var H5 = animals.Where(animal => animals.IndexOf(animal) != 1).ToList();
            var H3 = animals.Where(animal => animals.IndexOf(animal) != 0).ToList();

            var result = H3[0].IsFriendsWith(H5);

            Assert.IsTrue(result);
        }
Esempio n. 9
0
 private void generateMockDataButton_Click(object sender, EventArgs e)
 {
     createdAnimalsBox.Items.Clear();
     for (int i = 0; i < 10; i++)
     {
         train.AnimalsToAdd.Add(AnimalFactory.CreateRandomAnimal());
     }
     foreach (Animal animal in train.AnimalsToAdd)
     {
         createdAnimalsBox.Items.Add(animal.getString());
     }
 }
Esempio n. 10
0
        static void Main(string[] args)
        {
            var    factory = new AnimalFactory();
            Animal tweety  = factory.CreateAnimale("b", "Tweety");
            Animal spike   = factory.CreateAnimale("d", "Spike");

            tweety.Eat();
            tweety.Run();

            spike.Eat();
            spike.Run();
        }
Esempio n. 11
0
    private void Reproduce()
    {
        if (sex == BiologicalSex.Female)
        {
            AnimalFactory.CreateBabyHawk(dna, mate.GetComponent <Hawk>().dna, transform);
        }

        mate             = null;
        mateOnSight      = false;
        reproductionUrge = 0;
        state            = State.Nourished;
    }
Esempio n. 12
0
    static void Main(string[] args)
    {
        animalFactory = new ShelterAnimalFactory();
        larFeliz      = new AnimalShelter();
        InicializeData();
        Animal testAnimal = Program.larFeliz.PickOne("cat");

        Console.WriteLine(testAnimal.Name);
        Console.WriteLine(Program.larFeliz.PickOne("cat").Name);
        Console.WriteLine(Program.larFeliz.PickOne("cat").Name);
        Program.larFeliz.PickOne("cat");
    }
Esempio n. 13
0
        public void C1_IsFriendsWith_H3()
        {
            var animals = new AnimalFactory(1, 0, 0, 0, 1, 0).GetCreatedAnimals().ToList();

            animals = OrderAnimals(animals);
            var C1 = animals.Where(animal => animals.IndexOf(animal) != 1).ToList();
            var H3 = animals.Where(animal => animals.IndexOf(animal) != 0).ToList();

            var result = C1[0].IsFriendsWith(H3);

            Assert.IsTrue(result);
        }
    public void BuyNewKind(string kind)
    {
        if (!DataManager.TryAndBuyForMoney(Translator.KindToPrice(kind)))
        {
            return;
        }
        Animal animal = AnimalFactory.NewAnimalOfKind(kind, activeCage.transform);

        animal.data.male          = false;
        animal.transform.position = activeCage.GetFreeTileInGrid();
        cageIcons.GetChild(GameManager.Ins.currentCageIndex).GetComponent <Image>().sprite = Resources.Load <Sprite>($"Animals/{kind}/CageIcon");
        Refresh();
    }
Esempio n. 15
0
        public void Distribute_Test_03()
        {
            //Arrange
            int expectedWagonAmount = 5;

            List <Animal> DistributedAnimals = AnimalFactory.GenerateCarnivores(expectedWagonAmount, seed);

            //Act
            List <Wagon> actualWagonList = WagonDistributor.Distribute(DistributedAnimals);

            //Assert
            Assert.AreEqual(expectedWagonAmount, actualWagonList.Count);
        }
Esempio n. 16
0
        static void Main(string[] args)
        {
            var vet = new Vet();
            var mgr = new Manager();
            var zoo = new Zoo {
                mgr = mgr, vet = vet
            };
            AnimalFactory <Horse> factory = new AnimalFactory <Horse>();
            var horse = factory.Create("Milly", zoo);

            horse.Hungry();
            vet.BeginVaccination();
        }
Esempio n. 17
0
        public void Distribute_Test_01()
        {
            //Arrange
            List <Animal> Animals1 = AnimalFactory.GenerateSelectAnimal(FoodEnum.FoodType.Carnivore, 3, 10);
            //Act
            List <Wagon> actualWagonList = WagonDistributor.Distribute(Animals1);

            //Assert
            for (int i = 0; i < actualWagonList.Count; i++)
            {
                Assert.AreEqual(Animals1[i], actualWagonList[i].FilledAnimals[0]);
            }
        }
Esempio n. 18
0
    // Use this for initialization
    void Start()
    {
        //worldState = new WorldState();
        AnimalFactory animalFactory = GetComponent <AnimalFactory>();

        worldState.Initialize(animalFactory);

        TraitFactory.instantiateAllTraits();

        homeState = new HomeState();
        homeState.Initialize();
        activeState = homeState;
    }
Esempio n. 19
0
        public void SerializeTest()
        {
            var pet   = AnimalFactory.CreateAnimal("Cat", Gender.Male, "Wiskers");
            var pizza = new Pizza();
            var steak = new Steak();

            pet.FoodsInfinite = new List <Food> {
                pizza, steak
            };
            var player = new Player(pet);

            player.Serialize();
        }
Esempio n. 20
0
        static void Main()
        {
            InputReader         reader             = new InputReader();
            OutputWriter        writer             = new OutputWriter();
            IDatabase           db                 = new Database();
            IAnimalFactory      animalFactory      = new AnimalFactory();
            ICommandFactory     commandFactory     = new CommandFactory();
            ICommandInterpreter commandInterpreter = new CommandInterpreter(db, animalFactory, commandFactory, writer);

            Engine engine = new Engine(db, commandInterpreter, reader, writer);

            engine.Run();
        }
Esempio n. 21
0
        static void Main(string[] args)
        {
            AnimalFactory factory = new AnimalFactory();
            Animal        dog     = factory.GetAnimal("dog");

            Console.WriteLine(dog.Eat());
            Animal cat = factory.GetAnimal("cat");

            Console.WriteLine(cat.Eat());
            Animal elephant = factory.GetAnimal("elephant");

            Console.WriteLine(elephant.Eat());
        }
Esempio n. 22
0
    public static AbstractFactory GetFactory(FactoryType factoryType)
    {
        switch (factoryType)
        {
        case FactoryType.Human:
            AbstractFactory humanFactory = new HumanFactory();
            return(humanFactory);

        case FactoryType.Animal:
            AbstractFactory animalFactory = new AnimalFactory();
            return(animalFactory);
        }
        return(null);
    }
Esempio n. 23
0
        /// <summary>
        /// Adds animal to the wagon
        /// </summary>
        /// <param name="animal"></param>
        public void AddAnimal(Animal animal)
        {
            animalsInWagon.Add(animal);
            occupation += animal.Size;

            IAnimalDal dal = AnimalFactory.GetAnimalDal();

            dal.Add(new AnimalDto
            {
                Name        = animal.Name,
                Size        = animal.Size,
                IsCarnivore = animal.IsCarnivore
            });
        }
Esempio n. 24
0
        public void CreateAnimalShould()
        {
            var displayMoq = new Mock <IPresenting>().Object;

            var instance = new AnimalFactory(displayMoq);

            var bird     = instance.CreateAnimal <Bird>("orange");
            var dog      = instance.CreateAnimal <Dog>("orange");
            var hedgehog = instance.CreateAnimal <Hedgehog>("orange");

            Assert.True(bird is Bird);
            Assert.True(dog is Dog);
            Assert.True(hedgehog is Hedgehog);
        }
Esempio n. 25
0
		public void CheckContents_Test()
		{
			//Arrange
			Animal expected1 = new Animal(FoodEnum.FoodType.Carnivore, 5);
			Wagon wagon = new Wagon();

			Animal actual = AnimalFactory.GenerateSelectAnimal(FoodEnum.FoodType.Carnivore, 5, 1).FirstOrDefault();
			//Act
			wagon.AddAnimal(actual);

			//Assert
			Assert.AreEqual(expected1.Food, wagon.FilledAnimals.FirstOrDefault().Food);
			Assert.AreEqual(expected1.Size, wagon.FilledAnimals.FirstOrDefault().Size);
		}
        public void Run()
        {
            string        input            = Console.ReadLine();
            int           inputLineCounter = default;
            List <Animal> animals          = new List <Animal>();
            AnimalFactory animalFactory    = new AnimalFactory();
            FoodFactory   foodFactory      = new FoodFactory();

            while (input != "End")
            {
                if (inputLineCounter % 2 == 0)
                {
                    string[] cmdArgs   = input.Split(' ', '-', StringSplitOptions.RemoveEmptyEntries);
                    Animal   newAnimal = animalFactory.CreateAnimal(cmdArgs);
                    Console.WriteLine(newAnimal.AskForFood());
                    animals.Add(newAnimal);
                }
                else
                {
                    string[] cmdArgs          = input.Split(' ', '-', StringSplitOptions.RemoveEmptyEntries);
                    Food     newFood          = foodFactory.CreateFood(cmdArgs);
                    string   animalType       = animals[animals.Count - 1].GetType().Name;
                    string   foodType         = newFood.GetType().Name;
                    bool     isNewFoodEatable = CheckIfFoodIsEatable(animalType, foodType);

                    if (!isNewFoodEatable)
                    {
                        Console.WriteLine(String.Format(Messages.DOES_NOT_EAT_THIS_TYPE_OF_FOOD,
                                                        animalType, foodType));
                    }
                    else
                    {
                        Animal animal            = animals[animals.Count - 1];
                        double totalWeightGained = animal.WeightGain * newFood.Quantity;
                        animal.Weight    += totalWeightGained;
                        animal.FoodEaten += newFood.Quantity;
                    }
                }

                inputLineCounter++;

                input = Console.ReadLine();
            }

            foreach (var animal in animals)
            {
                Console.WriteLine(animal);
            }
        }
Esempio n. 27
0
        private void CreateAnimalButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(ConsumptionTypeBox.Text) || string.IsNullOrEmpty(SizeBox.Text))
            {
                MessageBox.Show("Je hebt nog geen gegevens ingevuld!", "Mislukt!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            Animal animal = AnimalFactory.Create(
                (ConsumptionType)Enum.Parse(typeof(ConsumptionType), ConsumptionTypeBox.SelectedItem.ToString().ToUpper()),
                (Sizes)Enum.Parse(typeof(Sizes), SizeBox.SelectedItem.ToString().ToUpper()));

            train.AnimalsToAdd.Add(animal);
            createdAnimalsBox.Items.Add(animal.getString());
            MessageBox.Show("Dier toegevoegd met de volgende attributen: " + animal.getString(), "Succes!", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Esempio n. 28
0
    private void Reproduce()
    {
        if (sex == BiologicalSex.Female)
        {
            for (int i = 0; i < Random.Range(1, 4); i++)
            {
                AnimalFactory.CreateBabyMonkey(dna, mate.GetComponent <Monkey>().dna, transform);
            }
        }

        mate             = null;
        mateOnSight      = false;
        reproductionUrge = 0;
        state            = State.Nourished;
    }
Esempio n. 29
0
        public void LargeCarnivore_LargeHerbivore_Sort()
        {
            var Animals = new List <Animal>();

            Animals.Add(AnimalFactory.CreateBigCarnivore());
            Animals.Add(AnimalFactory.CreateBigHerbivore());

            var CircusTrain = new Train();

            CircusTrain.LoadAnimals(Animals);

            var Carts = CircusTrain.GetCarts();

            Assert.IsTrue(Carts.Count > 1);
        }
Esempio n. 30
0
        public void SmallCarnivore_MediumHerbivore_Sort()
        {
            var Animals = new List <Animal>();

            Animals.Add(AnimalFactory.CreateSmallCarnivore());
            Animals.Add(AnimalFactory.CreateMediumHerbivore());

            var CircusTrain = new Train();

            CircusTrain.LoadAnimals(Animals);

            var Carts = CircusTrain.GetCarts();

            Assert.IsTrue(Carts.Count == 1);
        }
        /// <summary>
        /// Adds an new animal to the zoo.
        /// </summary>
        /// <param name="sender">The object that initiated the event.</param>
        /// <param name="e">The event arguments of the event.</param>
        private void addAnimalButton_Click(object sender, RoutedEventArgs e)
        {
            AnimalType animalType = (AnimalType)this.animalTypeComboBox.SelectedItem;

            Animal animal = AnimalFactory.CreateAnimal(animalType, "Animal", 0, 0.0, Gender.Female);

            AnimalWindow window = new AnimalWindow(animal);

            window.ShowDialog();

            if (window.DialogResult == true)
            {
                this.comoZoo.AddAnimal(animal);
            }
        }