static void Main(string[] args)
        {
            var animalTypes = new List<string> { "Cat", "Kitten", "Tomcat", "Dog", "Frog" };

            Kitten kotyo = new Kitten("Kotyo", 3);
            Tomcat silvestyr = new Tomcat("Silvestyr", 5);
            Frog barny = new Frog("Barny", 2, Animal.Gender.Male);
            Dog rex = new Dog("Rex", 7, Animal.Gender.Male);
            Cat Bud = new Cat("Bud", 5, Animal.Gender.Female);

            List<Animal> animals = new List<Animal>() { kotyo, silvestyr, barny, rex, Bud };

            Kitten[] kittens = new Kitten[] { kotyo, new Kitten("Fluffy", 1), new Kitten("Bet", 2) };
            Tomcat[] tomcats = new Tomcat[] { silvestyr, new Tomcat("Jack", 2), new Tomcat("Malcho", 1), new Tomcat("Pikachhu", 6) };
            Frog[] frogs = new Frog[] { barny, new Frog("Bobolina", 1, Animal.Gender.Female), new Frog("Burt", 2, Animal.Gender.Male) };
            Dog[] dogs = new Dog[] { rex, new Dog("Sharo", 3, Animal.Gender.Male), new Dog("Sancho", 10, Animal.Gender.Male) };
            Cat[] cats = new Cat[] { Bud };

            Console.WriteLine("Animals:\n");

            foreach (Animal animal in animals)
            {
                Console.WriteLine(animal);
                animal.ProduceSound();
                Console.WriteLine();
            }

            Console.WriteLine("\nAnimals' average age:\n");
            AverageAge(animals, animalTypes);
            Console.WriteLine();
        }
        public static void Main()
        {
            var animals = new List<Animal>();
            animals.Add(new Cat("Tom", 2, "male"));
            animals.Add(new Frog("Kasandra", 3, "female"));
            animals.Add(new Dog("Djoni", 5, "male"));
            animals.Add(new Cat("Gosho", 3, "male"));
            animals.Add(new Frog("Rapuncel", 8, "female"));
            animals.Add(new Dog("Kira", 2, "female"));

            foreach (var animal in animals)
            {
                Console.WriteLine(animal.Name + " is " + animal.Age + " years old and is " + animal.Sex);
            }
            Console.WriteLine();

            TomCat[] tomCats = new TomCat[3] { new TomCat("Tom", 2, "male"), new TomCat("Gosho", 3, "male"), new TomCat("Kuncho", 7, "male") };
            Kittens[] kittenCats = new Kittens[2] { new Kittens("Lora", 2, "female"), new Kittens("Zori", 3, "female") };
            Frog[] frogs = new Frog[3] { new Frog("Tom", 5, "male"), new Frog("Gosho", 8, "male"), new Frog("Kuncho", 7, "male") };
            Dog[] dogs = new Dog[2] { new Dog("Tom", 5, "male"), new Dog("Gosho", 8, "male") };

            Console.WriteLine(tomCats.Average(x => x.Age));
            Console.WriteLine(kittenCats.Average(x => x.Age));
            Console.WriteLine(frogs.Average(x => x.Age));
            Console.WriteLine(dogs.Average(x => x.Age));
        }
        static void Main()
        {
            Cat presi = new Cat("Presi", "Female", 3, "Mrrr");
            Tomcat kris = new Tomcat("Kris", 2, "Miaaaauu");
            Kitten vili = new Kitten("Vili", 1, "Mrrrrr");
            Dog sharo = new Dog("Sharo", "Male", 5, "Bau Bau");
            Dog djondjo = new Dog("Djondjo", "Male", 3, "Bau Bau");
            Frog green = new Frog("Grinko", "Male", 1, "Kvak");

            Animals[] cats = new Animals[]
            {
                presi,
                kris,
                vili,
            };

            Animals[] dogs = new Animals[]
            {
                sharo,
                djondjo,
            };

            double averAgeCats = cats.Average(x => x.Age);
            double averAgeDogs = dogs.Average(x => x.Age);

            Console.WriteLine("Average Age in Cats is : {0}", averAgeCats);
            Console.WriteLine("Average Age in Dogs is : {0}", averAgeDogs);
        }
Exemple #4
0
		public static Frog[] FillFrogArr()
		{
			var frogArr = new Frog[rnd.Next(5, 21)];
			for (int i = 0; i < frogArr.Length; i++)
			{
				frogArr[i] = new Frog(GetRandomName(), (byte)rnd.Next(1, 16), rnd.Next(1, 3) == 1);
			}
			return frogArr;
		}
        static void Main()
        {
            Cat[] cats = new Cat[]
            {
                new Cat (2, "Puhi", "female"),
                new Cat (1, "Chernio", "male"),
                new Cat (3, "Choki", "female")
            };

            Dog[] dogs = new Dog[]
            {
                new Dog (3, "Sharo", "male"),
                new Dog (1, "Chernio", "male"),
                new Dog (3, "Sasho", "male")
            };

            Frog[] frogs = new Frog[]
            {
                new Frog (1, "Kio", "male"),
                new Frog (1, "Kao", "female"),
                new Frog (1, "Mao", "female"),
            };

            Kitten[] kittens = new Kitten[]
            {
                new Kitten (2, "Mio"),
                new Kitten (2, "Kio")
            };

            Tomcat[] tomcats = new Tomcat[]
            {
                new Tomcat (3, "Tao"),
                new Tomcat (3, "Vao")
            };

            Console.WriteLine("The average age of cats is: {0}", Math.Round(Animal.CalculateAverageAge(cats), 2));
            Console.WriteLine("The average age of dogs is: {0}", Math.Round(Animal.CalculateAverageAge(dogs), 2));
            Console.WriteLine("The average age of frogs is: {0}", Math.Round(Animal.CalculateAverageAge(frogs), 2));
            Console.WriteLine("The average age of kittens is: {0}", Math.Round(Animal.CalculateAverageAge(kittens), 2));
            Console.WriteLine("The average age of tomcats is: {0}", Math.Round(Animal.CalculateAverageAge(tomcats), 2));

            Console.Write("Cats say: ");
            cats[0].Sound();
            Console.Write("Dogs say: ");
            dogs[0].Sound();
            Console.Write("Frogs say: ");
            frogs[0].Sound();
        }
Exemple #6
0
        public static void Main(string[] args)
        {
            Dog myDog = new Dog("Mike", 5, "male");
            Dog myDog2 = new Dog("Frank", 12, "male");
            Frog myFrog = new Frog("Jaba", 12, "female");
            Kitten myKitten = new Kitten("Kitty", 10);
            Tomcat myTomcat = new Tomcat("Gosho", 5);

            myDog.SaySomething();
            myFrog.SaySomething();
            myKitten.SaySomething();
            myTomcat.SaySomething();

            double averageAge = Animal.CalculateAverageAge();
            Console.WriteLine(averageAge);
        }
Exemple #7
0
        static void Main()
        {
            Cat[] arrayOfCats = new Cat[]
            {
                new Cat("Betty",1,true),
                new Cat("Tom",3,false)
            };

            Kitten[] arrayOfKittens = new Kitten[]
            {
                new Kitten("Johny",1),
                new Kitten("Persia",2)
            };

            Tomcat[] arrayOfTomcats = new Tomcat[]
            {
                new Tomcat("John",4),
                new Tomcat("Toby",2)
            };

            Dog[] arrayOfDogs = new Dog[]
            {
                new Dog("Oliver", 2, false, "German Shepherd"),
                new Dog("Olivia",3, true, "Shih Tzu")
            };

            Frog[] arrayOfFrogs = new Frog[]
            {
                new Frog("Candy",2,true),
                new Frog("Abidin",4,false)
            };

            Console.WriteLine("Average age of cats: {0}",Animals.CalcAvgAge(arrayOfCats));
            Console.WriteLine("Average age of kittens: {0}", Animals.CalcAvgAge(arrayOfKittens));
            Console.WriteLine("Average age of tomcats: {0}", Animals.CalcAvgAge(arrayOfTomcats));
            Console.WriteLine("Average age of dogs: {0}", Animals.CalcAvgAge(arrayOfDogs));
            Console.WriteLine("Average age of frogs: {0}", Animals.CalcAvgAge(arrayOfFrogs));
            Console.WriteLine("\nAnimal sounds:\n {0}\n {1}\n {2}\n",
                              arrayOfCats[1].ProduceSound(),arrayOfDogs[0].ProduceSound(),arrayOfFrogs[1].ProduceSound());
            Console.WriteLine("Animal actions:\n {0}\n {1}\n {2}\n",
                              arrayOfCats[0].WagTail(),arrayOfDogs[1].ChewBone(),arrayOfFrogs[1].Leap());
        }
Exemple #8
0
        static void Main()
        {
            Dog dog = new Dog("Sharo", 2, Gender.Male);
            Console.WriteLine(dog);
            Frog frog = new Frog("Froggy", 1, Gender.Female);
            Console.WriteLine(frog);
            Tomcat tomcat = new Tomcat("Stalin", 5);
            Console.WriteLine(tomcat.Sex);
            Console.WriteLine(tomcat);
            Kitten kitty = new Kitten("Kitty", 3);
            Console.WriteLine(kitty.Sex);
            Console.WriteLine(kitty);

            Animal[] animals = new Animal[]
            {
                new Dog("Balkan",7,Gender.Male),
                new Dog("Ceaser",3,Gender.Male),
                new Dog("Chara",5,Gender.Female),
                new Cat("Lucky",4, Gender.Female),
                new Cat("Rijko",2,Gender.Male),
                new Cat("Sivcho",3,Gender.Male),
                new Frog("Sims",2, Gender.Male),
                new Frog("Jojo",6,Gender.Female),
                new Kitten("Djudji",6),
                new Kitten("Charlie",3),
                new Tomcat("Al Gor",5),
                new Tomcat ("Prince",8)
            };

            Console.WriteLine();
            Console.WriteLine("Average ages:");

            var averageAges=Animal.AverageAge(animals);

            foreach (var animalType in averageAges)
            {
                Console.WriteLine(animalType.Item1 +"-->"+ animalType.Item2);
            }
        }
Exemple #9
0
        static void Main(string[] args)
        {
            var animalTypes = new List <string> {
                "Cat", "Kitten", "Tomcat", "Dog", "Frog"
            };

            Kitten kotyo     = new Kitten("Kotyo", 3);
            Tomcat silvestyr = new Tomcat("Silvestyr", 5);
            Frog   barny     = new Frog("Barny", 2, Animal.Gender.Male);
            Dog    rex       = new Dog("Rex", 7, Animal.Gender.Male);
            Cat    Bud       = new Cat("Bud", 5, Animal.Gender.Female);

            List <Animal> animals = new List <Animal>()
            {
                kotyo, silvestyr, barny, rex, Bud
            };

            Kitten[] kittens = new Kitten[] { kotyo, new Kitten("Fluffy", 1), new Kitten("Bet", 2) };
            Tomcat[] tomcats = new Tomcat[] { silvestyr, new Tomcat("Jack", 2), new Tomcat("Malcho", 1), new Tomcat("Pikachhu", 6) };
            Frog[]   frogs   = new Frog[] { barny, new Frog("Bobolina", 1, Animal.Gender.Female), new Frog("Burt", 2, Animal.Gender.Male) };
            Dog[]    dogs    = new Dog[] { rex, new Dog("Sharo", 3, Animal.Gender.Male), new Dog("Sancho", 10, Animal.Gender.Male) };
            Cat[]    cats    = new Cat[] { Bud };

            Console.WriteLine("Animals:\n");

            foreach (Animal animal in animals)
            {
                Console.WriteLine(animal);
                animal.ProduceSound();
                Console.WriteLine();
            }

            Console.WriteLine("\nAnimals' average age:\n");
            AverageAge(animals, animalTypes);
            Console.WriteLine();
        }
Exemple #10
0
		public static void TestCreatures()
		{
			Dog charlie = new Dog("Charlie", 4, true);
			Console.WriteLine(charlie);
			charlie.SaySomething();

			Console.WriteLine();

			Frog quackster = new Frog("Rab", 1, false);
			Console.WriteLine(quackster);
			quackster.SaySomething();

			Console.WriteLine();

			Cat miew = new Cat("Dangleton", 3, false);
			Console.WriteLine(miew);
			miew.SaySomething();

			Console.WriteLine();

			Kitten kitty = new Kitten("KittyCat", 3);
			Console.WriteLine(kitty);
			kitty.SaySomething();

			Console.WriteLine();

			Tomcat tom = new Tomcat("Tom", 2);
			Console.WriteLine(tom);
			tom.SaySomething();
		}