コード例 #1
0
        public void AddFish(string name, SpeciesEnum specie, int age) // adding the fish by the console
        {
            Type type    = Type.GetType("Csharquarium.Models.Species." + specie.ToString());
            Fish newFish = (Fish)Activator.CreateInstance(type, name, age);

            AddToArray(newFish);
        }
コード例 #2
0
        public void AddFish(string name, Genders gender) // add fishes to the aquarium
        {
            SpeciesEnum randomSpecie = (SpeciesEnum)RNG.Next(0, Enum.GetNames(typeof(SpeciesEnum)).Length);
            Type        type         = Type.GetType("Csharquarium.Models.Species." + randomSpecie.ToString());
            Fish        newFish      = (Fish)Activator.CreateInstance(type, name, gender);

            AddToArray(newFish);
        }