Esempio n. 1
0
        public async Task <IActionResult> Create([Bind("ID,Name,BirthDate")] Animals animals)
        {
            if (ModelState.IsValid)
            {
                _context.Add(animals);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(animals));
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([Bind("AN_ID,AN_NAME,AN_HEIGHT,AN_WEIGHT")] Animals animals)
        {
            if (ModelState.IsValid)
            {
                _context.Add(animals);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(animals));
        }
Esempio n. 3
0
 public void ExportPDF()
 {
     if (Animals != null && Animals.Count() != 0)
     {
         DocumentManager.ExportDataPDF(AnimalInfo.ConvertToList(Animals), "Export zvířata");
     }
     else
     {
         MessageBox.Show("Žádná data pro export.");
     }
 }
Esempio n. 4
0
 private void AddAnimal(Animal animal)
 {
     if (animal.FoodType == AnimalType.Carnivore)
     {
         ContainsCarnivore         = true;
         SmallestAnimalIsCarnivore = true;
         SmallestAnimal            = animal.AnimalSize;
     }
     IsTheAnimalTheSmallest(animal);
     Animals.Add(animal);
     Weight += (int)animal.AnimalSize;
 }
Esempio n. 5
0
    static void Main(string[] args)
    {
        Animals tiger = new Animals();

        tiger.SetAnimalName("Simba");
        Console.WriteLine(tiger.GetAnimalName());

        Animals deer = new Animals();

        deer.SetAnimalName("Luvly");
        Console.WriteLine(deer.GetAnimalName());
    }
Esempio n. 6
0
    static void Main(string[] args)
    {
        Animals animalCollection = new Animals();

        animalCollection.Add("A", new Cow("A"));
        animalCollection.Add("B", new Chicken("B"));
        foreach (Animal myAnimal in animalCollection)
        {
            Console.WriteLine(myAnimal.ToString());
            Console.WriteLine(myAnimal.Name);
        }
    }
Esempio n. 7
0
        public void FindNewOwner()
        {
            int randAdopter = new Random().Next(0, Adopters.Count);
            int randAnimal  = new Random().Next(0, Animals.Count);

            if (randAdopter < Animals.Count && randAnimal < Adopters.Count)
            {
                Animals[randAnimal].OwnerName = Adopters[randAdopter];
                Animals.RemoveAt(randAnimal);
                Adopters.RemoveAt(randAdopter);
            }
        }
Esempio n. 8
0
        public IActionResult Create(Animals model)
        {
            if (ModelState.IsValid)
            {
                var maxId = dogRepository.GetDogs().Max(x => x.Id) + 1;

                model.Id = maxId;
                dogRepository.AddDog(model);
                return(RedirectToAction("List"));
            }
            return(View(model));
        }
 public ActionResult ConfirmEdit(Animals obj)
 {
     if (ModelState.IsValid)
     { // check valid state
         service.Update(obj);
         return(RedirectToAction("Index"));
     }
     else // not valid so redisplay
     {
         return(View(obj));
     }
 }
Esempio n. 10
0
    private void Unlock(GameObject animal)
    {
        GameObject lockedAnimal;

        if (lockedAnimals.TryGetValue(animal.name, out lockedAnimal))
        {
            //Debug.Log("Unlocking " + animal.name);
            UnlockLockedAnimal(lockedAnimal);
            Animals.Unlock(lockedAnimal.name);
            lockedAnimals.Remove(animal.name);
        }
    }
Esempio n. 11
0
 public bool AddAnimalToWagon(Animal animal)
 {
     if (FitAnimal(animal) && CompatibleAnimals(animal))
     {
         Animals.Add(animal);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 12
0
        public void LoadData()
        {
            Habitates.Add("Dschungel");
            Habitates.Add("Süßwasser");
            Habitates.Add("Steppe");
            Habitates.Add("Luft");

            Animals.Add(new AnimalVM("Tiger", 10, "Raubkatze", "Dschungel", 7000, true));
            Animals.Add(new AnimalVM("Goldbrasse", 4, "Fisch", "Süßwasser", 70000, false));
            Animals.Add(new AnimalVM("Coala", 20, "Beuteltier", "Steppe", 6000, false));
            Animals.Add(new AnimalVM("Eisvogel", 1, "Vogel", "Luft", 5000, true));
        }
Esempio n. 13
0
        static void Main(string[] args)
        {
            Animals animalCollection = new Animals();

            animalCollection.Add("Cow", new Animal("Cow"));
            animalCollection.Add("Fox", new Animal("Fox"));

            foreach (var animal in animalCollection)
            {
                Console.WriteLine(animal);
            }
        }
    public static void Main()
    {
        Animals animals = new Animals(typeof(Cow));

        animals.Add(new Cow());
        IEnumerable <Cow> cows = animals.GetAnimals <Cow>();

        foreach (var cow in cows)
        {
            // do something
        }
    }
Esempio n. 15
0
        public UserControlSelectPet()
        {
            SelectedPet = new Animals();

            InitializeComponent();

            rbtn_oneMonth.Checked += AgeChoice_CheckedChanged;
            rbtn_sixMonth.Checked += AgeChoice_CheckedChanged;
            rbtn_year.Checked     += AgeChoice_CheckedChanged;

            DataContext = this;
        }
Esempio n. 16
0
        public IHttpActionResult PostAnimals(Animals animals)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Animals.Add(animals);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = animals.Id }, animals));
        }
Esempio n. 17
0
        public AnimalsViewModel()
        {
            CollectionOfAllAnimals =
                new ObservableCollection <AnimalViewModel>();
            this.ViewCommand = new ViewCommands(this);
            var animals = new Animals();

            foreach (var temp in animals.AnimalsList)
            {
                CollectionOfAllAnimals.Add(new AnimalViewModel(temp));
            }
        }
Esempio n. 18
0
 public void DeleteAnimal()
 {
     using (AnimalContext context = new AnimalContext())
     {
         context.Animal.Attach(SelectedAnimal);
         context.Animal.Remove(SelectedAnimal);
         context.SaveChanges();
     }
     SelectedAnimal = new Animal();
     Animals.Clear();
     GetAllAnimals();
 }
Esempio n. 19
0
        public static void Run()
        {
            ContinentFactory africa = new AfricaFactory();
            var animals             = new Animals(africa);

            animals.RunFoodChain();

            ContinentFactory america = new AmericaFactory();

            animals = new Animals(america);
            animals.RunFoodChain();
        }
Esempio n. 20
0
 public void SaveAnimal()
 {
     using (AnimalContext acx = new AnimalContext())
     {
         acx.Gender.Attach(SelectedAnimal.Gender);
         acx.Species.Attach(SelectedAnimal.Species);
         acx.Animal.AddOrUpdate(SelectedAnimal);
         acx.SaveChanges();
     }
     SelectedAnimal = new Animal();
     Animals.Clear();
     GetAllAnimals();
 }
Esempio n. 21
0
        public void NewWay(Animals animal)
        {
            var animalSound = animal switch
            {
                Animals.Dog => "Woof",
                Animals.Cat => "Meow",
                Animals.Sheep => "Baa",
                Animals.Cow => "Moo",
                _ => throw new ArgumentOutOfRangeException()
            };

            Console.WriteLine($"The animal makes the sound: {animalSound}");
        }
Esempio n. 22
0
        static void Main(string[] args)
        {
            Animals animals = new Animals();

            if (args.Length > 0)
            {
                animals.AddAnimal(args);
            }
            else
            {
                animals.Usage();
            }
        }
Esempio n. 23
0
        public Prey     FindPrey()
        {
            List <Animal> tasty = Animals.Where((x) => x.IsAlive && Utils.IsPrey(x)).ToList();

            if (tasty.Count() > 0)
            {
                return((Prey)tasty.ElementAt(new Random().Next(0, tasty.Count())));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 24
0
        public Animal   FindMate(Animal a)
        {
            List <Animal> sexy = Animals.Where((x) => x.IsAlive && x.GetType() == a.GetType() && a.Sexe != x.Sexe).ToList();

            if (sexy.Count() > 0)
            {
                return(sexy.ElementAt(new Random().Next(sexy.Count())));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 25
0
 public void Accommodate(IAnimal animal)
 {
     if (Capacity <= 0)
     {
         throw new InvalidOperationException("Not enough capacity");
     }
     if (Animals.ContainsKey(animal.Name))
     {
         throw new ArgumentException($"Animal {animal.Name} already exist");
     }
     Animals.Add(animal.Name, animal);
     Capacity--;
 }
Esempio n. 26
0
        public static object[] createModel()
        {
            TestModelParser modelParser   = new TestModelParser();
            ModelInstance   modelInstance = modelParser.EmptyModel;

            Animals animals = modelInstance.newInstance(typeof(Animals));

            modelInstance.DocumentElement = animals;

            createBird(modelInstance, "tweety", Gender.Female);

            return(new object[] { "created", modelInstance, modelParser });
        }
Esempio n. 27
0
 public bool IsAnimalAdded(Animal animal)
 {
     if (animal != null && DoesAnimalFit(animal))
     {
         if (DoesAnimalGetEaten(animal) == false)
         {
             Animals.Add(animal);
             Occupied += (int)animal.Size;
             return(true);
         }
     }
     return(false);
 }
Esempio n. 28
0
        private void OOP()
        {
            Birds fish = new Birds("hh");

            fish.Move();

            var anim = new Animals[] { new Fish("Jon"), new Birds("Don"), new Mammals("Shiki") };

            foreach (var an in anim)
            {
                an.Move();
            }
        }
Esempio n. 29
0
 public ActionResult Edit(Animals record)
 {
     if (ModelState.IsValid)
     {
         record.AddingDate = DateTime.Now;
         recordsDAO.EditRecord(record);
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View("Edit"));
     }
 }
Esempio n. 30
0
    Animals OppositeAnimals(Animals ani)
    {
        if (ani == Animals.Cat)
            ani = Animals.Dog;
        else if (ani == Animals.Dog)
            ani = Animals.Cat;
        else if (ani == Animals.Chinchilla)
            ani = Animals.Hamster;
        else if (ani == Animals.Hamster)
            ani = Animals.Chinchilla;

        return ani;
    }
Esempio n. 31
0
        }                                      // баланс Пет шоп

        public void PrintAssortiment()
        {
            var cats = Animals.Where(animal => animal is Cat).ToList(); // Животное, где животное Кот
            var dogs = Animals.Where(animal => animal is Dog).ToList(); // Животное, где животное Собака

            Console.WriteLine($"Total animals count: {Animals.Count}");
            Console.WriteLine($"cats count: {cats.Count}");
            Console.WriteLine($"dogs count: {dogs.Count}");


            cats.ForEach(x => x.Print());
            dogs.ForEach(x => x.Print());
        }
Esempio n. 32
0
    static void Main()
    {
        Animals[] someNoise = new Animals[]
        {
            new Dog(12, "Sharo", Sex.male),
            new Cat(5, "Tomi", Sex.male),
            new Frog(1, "Krqkla", Sex.female),
            new Kitten(0.6, "Siva", Sex.female),
            new Tomcat(0.2, "Drebko", Sex.male)
        };
        foreach(Animals animal in someNoise)
        {
            Console.Write("{0} says: ", animal.Name);
            animal.MakeSomeNoise();
        }

        Dog[] dogs = new Dog[]
        {
            new Dog(3, "Lasi", Sex.female),
            new Dog(1, "Sharo", Sex.male),
            new Dog(8, "Topcho", Sex.male),
            new Dog(4, "Djina", Sex.female)
        };
        double avg = Animals.AverageAge(dogs);
        Console.WriteLine("The average age of the dogs is {0:0.00}", avg);

        Cat[] cats = new Cat[]
        {
            new Cat(7, "Bella", Sex.female),
            new Cat(1, "Puhcho", Sex.male),
            new Cat(2, "Rijko", Sex.male),
            new Cat(3, "Siva", Sex.female)
        };
        avg = Animals.AverageAge(cats);
        Console.WriteLine("The average age of the cats is {0:0.00}", avg);

        Frog[] frogs = new Frog[]
        {
            new Frog(1.5, "Krastavelka", Sex.female),
            new Frog(2, "Zelenushko", Sex.male),
            new Frog(4.3, "Skoklio", Sex.male),
            new Frog(1, "Krqkla", Sex.female)
        };
        avg = Animals.AverageAge(frogs);
        Console.WriteLine("The average age of the frogs is {0:0.00}", avg);

        Kitten[] kittens = new Kitten[]
        {
            new Kitten(0.5, "Puhi", Sex.female),
            new Kitten(0.7, "Tigyrka", Sex.female),
            new Kitten(0.9, "Rijka", Sex.female),
            new Kitten(0.2, "Mynichka", Sex.female)
        };
        avg = Animals.AverageAge(kittens);
        Console.WriteLine("The average age of the kittens is {0:0.00}", avg);

        Tomcat[] tomcats = new Tomcat[]
        {
            new Tomcat(0.3, "Puhcho", Sex.male),
            new Tomcat(0.2, "Tigyr", Sex.male),
            new Tomcat(0.9, "Rijko", Sex.male),
            new Tomcat(1, "Chernyo", Sex.male)
        };
        avg = Animals.AverageAge(tomcats);
        Console.WriteLine("The average age of the tomcats is {0:0.00}", avg);
    }
Esempio n. 33
0
 void Start()
 {
     combo = 0;
     bestCombo = 0;
     missed = 0;
     hbar.maxValue = 100;
     fightManager = GameObject.Find ("Fight").GetComponent<Animals> ();
     master = GameObject.Find ("GameController").GetComponent<GameController> ();
 }