示例#1
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();
        }
示例#2
0
        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);
        }
        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();
        }
示例#4
0
        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);
        }
示例#5
0
		public static Tomcat[] FillTomArr()
		{
			var tomArr = new Tomcat[rnd.Next(5, 21)];
			for (int i = 0; i < tomArr.Length; i++)
			{
				tomArr[i] = new Tomcat(GetRandomName(), (byte)rnd.Next(1, 16));
			}
			return tomArr;
		}
示例#6
0
        public static Tomcat[] FillTomArr()
        {
            var tomArr = new Tomcat[rnd.Next(5, 21)];

            for (int i = 0; i < tomArr.Length; i++)
            {
                tomArr[i] = new Tomcat(GetRandomName(), (byte)rnd.Next(1, 16));
            }
            return(tomArr);
        }
        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();
        }
        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();
        }
示例#9
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);
        }
示例#10
0
        static void Main(string[] args)
        {
            Dog[] dogs = new Dog[]
            {
                new Dog(7, "Sharo", false),
                new Dog(9, "Rita", true),
                new Dog(4, "Strela", true)
            };
            Frog[] frogs = new Frog[]
            {
                new Frog(2, "Pesho", false),
                new Frog(1, "Gosho", false)
            };
            Cat[] cats = new Cat[]
            {
                new Cat(4, "Boyko", false),
                new Cat(8, "Klara", true)
            };
            Kitten[] kittens = new Kitten[]
            {
                new Kitten(2, "Lora"),
                new Kitten(1, "Sara")
            };
            Tomcat[] tomcats = new Tomcat[]
            {
                new Tomcat(1, "Tom"),
                new Tomcat(2, "Johnny")
            };

            Console.WriteLine("Dogs average age: {0:F2}", Animal.AverageAge(dogs));
            Console.WriteLine("Frogs average age: {0:F2}", Animal.AverageAge(frogs));
            Console.WriteLine("Cats average age: {0:F2}", Animal.AverageAge(cats));
            Console.WriteLine("Kittens average age: {0:F2}", Animal.AverageAge(kittens));
            Console.WriteLine("Tomcats average age: {0:F2}", Animal.AverageAge(tomcats));

            Console.WriteLine(dogs[0].Bark());
            dogs[1].MakeSound();
            Console.WriteLine(frogs[1].Jump());
            frogs[0].MakeSound();
            Console.WriteLine(cats[0].Sleep());
            cats[1].MakeSound();
            Console.WriteLine(kittens[0].Play());
            kittens[1].MakeSound();
            Console.WriteLine(tomcats[0].Sleep());
            tomcats[1].MakeSound();
        }
示例#11
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());
        }
示例#12
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);
            }
        }
示例#13
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();
        }
示例#14
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();
		}