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(); } }
public void CreateAnimal_expectedSameAnimalType(animalType typeInput, animalType expected) { //Arrange //Act animalType typeActual = AnimalFactory.Instance().CreateAnimal(typeInput).type; //Assert Assert.AreEqual(expected, typeActual); }
//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); }
public void GenerateRandomList_Test() { //Arrange int expectedAmount = 3; //Act List <Animal> actualAnimalList = AnimalFactory.GenerateRandomAnimals(expectedAmount, seed); //Assert Assert.AreEqual(expectedAmount, actualAnimalList.Count); }
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); }
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); }
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); }
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); }
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()); } }
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(); }
private void Reproduce() { if (sex == BiologicalSex.Female) { AnimalFactory.CreateBabyHawk(dna, mate.GetComponent <Hawk>().dna, transform); } mate = null; mateOnSight = false; reproductionUrge = 0; state = State.Nourished; }
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"); }
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(); }
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); }
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(); }
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]); } }
// 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; }
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(); }
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(); }
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()); }
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); }
/// <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 }); }
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); }
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); } }
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); }
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; }
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); }
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); } }