예제 #1
0
        static void Main(string[] args)
        {
            Dog jango = new Dog()
            {
                Id   = 1,
                Name = "Jango",
                //Type = "Dog",
                Race = "Poodle"
            };

            jango.PrintInfo();
            jango.Eat();

            jango.Bark();

            Console.WriteLine();

            Animal dambo = new Animal()
            {
                Id   = 2,
                Name = "Dambo",
                Type = AnimalTypes.Other
            };

            dambo.PrintInfo();
            dambo.Eat();

            Console.WriteLine();

            Cat kitty = new Cat()
            {
                Id   = 3,
                Name = "Kitty",
                //Type = "Cat",
                Laziness = "Very lazy"
            };

            kitty.PrintInfo();
            kitty.Meow();
            kitty.Eat();

            Console.WriteLine();

            WeekDays tuesday = WeekDays.Tuesday;

            Console.WriteLine(tuesday);
            Console.WriteLine(tuesday.ToString() == "Tuesday");
            Console.WriteLine(tuesday == (WeekDays)2);

            Console.WriteLine();

            Mouse mouse = new Mouse();
        }
예제 #2
0
        public void Run()
        {
            var fluf = new Cat();

            Console.WriteLine($"{fluf.Speak()}");
            fluf.Purr();
            fluf.Eat();

            var spot = new Dog();

            Console.WriteLine($"{spot.Speak()}");
            spot.Breed = "Chihuahua";
            spot.TellBreed();
            spot.Eat();
        }
예제 #3
0
        static void Main(string[] args)
        {
            Puppy puppy = new Puppy();//Multiple Inheritance

            puppy.Eat();
            puppy.Bark();
            puppy.Weep();
            Dog dog = new Dog();//Single Inheritance

            dog.Bark();
            dog.Eat();
            Cat cat = new Cat();//Heirarchial Inheritance

            cat.Meow();
            cat.Eat();
        }
예제 #4
0
        static void Main(string[] args)
        {
            Dog objDog = new Dog();

            objDog.Bark();
            objDog.Eat();

            Console.WriteLine("//////////////////////////");

            Cat objCat = new Cat();

            objCat.Meow();
            objCat.Eat();

            Console.ReadLine();
        }
예제 #5
0
        static void Main(string[] args)
        {
            Animal dumbo = new Animal()
            {
                Id   = 1,
                Name = "Dumbo",
                Type = "elephant",
                // IsHappy = true - we can't access this here
            };

            dumbo.PrintInfo();
            dumbo.Eat();
            Console.WriteLine("-----------------------------------------");

            Dog baron = new Dog()
            {
                Id   = 2,
                Type = "dog",
                Name = "Barron",
                Race = "German sheppard"
            };

            baron.PrintInfo();
            baron.Eat();
            baron.Bark();
            baron.IsDogHappy();
            Console.WriteLine("-----------------------------------------");

            Cat garfield = new Cat()
            {
                Id       = 3,
                Name     = "Garfield",
                Laziness = "very much"
            };

            // we don't tell the type here
            garfield.PrintInfo();
            garfield.Eat();
            garfield.Meow();
            Console.WriteLine("-----------------------------------------");

            Console.ReadLine();
        }
예제 #6
0
        static void Main(string[] args)
        {
            //Console.WriteLine("Single Inheritance");

            /*Console.WriteLine("Multiple Inheritance");
             * Puppy puppy = new Puppy();
             * puppy.Eat();
             * puppy.Bark();
             * puppy.Weep();*/
            Console.WriteLine("Hierarchial Inheritance");
            Dog dog = new Dog();

            dog.Eat();
            dog.Bark();
            Cat cat = new Cat();

            cat.Eat();
            cat.Meow();
        }
예제 #7
0
        static void Main(string[] args)
        {
            Dog rex = new Dog("Rex");

            rex.SayWoof();
            rex.Eat();


            Cat firstCat = new Cat("Murzik");

            firstCat.SayMeow();
            firstCat.Eat();


            Bird greatBird = new Bird("Eagle");

            greatBird.Chirip();
            greatBird.Eat();
            Console.ReadKey();
        }
예제 #8
0
        static void Main(string[] args)
        {
            Dog myDog = new Dog();

            myDog.Eat();
            myDog.Bark();
            Console.WriteLine();

            Puppy myPyppy = new Puppy();

            myPyppy.Eat();
            myPyppy.Bark();
            myPyppy.Weep();
            Console.WriteLine();

            Cat myCat = new Cat();

            myCat.Eat();
            myCat.Meow();
        }
예제 #9
0
        static void Main(string[] args)
        {
            Animal animal = new Animal()
            {
                Id   = 1,
                Name = "Ben",
                Type = "Dog",
            };

            Dog majlo = new Dog()
            {
                Id    = 2,
                Name  = "Majlo",
                Type  = "Dog",
                Breed = "Husky"
            };

            Cat garfild = new Cat()
            {
                Id       = 3,
                Name     = "Garfild",
                Lazyness = "Very"
            };

            Tiger tiger = new Tiger()
            {
                Id       = 4,
                Name     = "Tiger",
                Lazyness = "Non",
            };

            animal.Eat();
            majlo.Eat();
            garfild.Eat();
            garfild.Meow();
            tiger.Eat();
            tiger.Meow();
            tiger.PrintInfo();

            Console.ReadLine();
        }
예제 #10
0
        static void Main(string[] args)
        {
            Dog   fido  = new Dog();
            Puppy puppy = new Puppy();
            Cat   cat   = new Cat();

            Console.WriteLine("Fido:");
            fido.Eat();
            fido.Bark();
            Console.WriteLine();

            Console.WriteLine("Puppy:");
            puppy.Eat();
            puppy.Bark();
            puppy.Weep();
            Console.WriteLine();

            Console.WriteLine("Cat:");
            cat.Eat();
            cat.Meow();
        }
예제 #11
0
        static void Main(string[] args)
        {
            Wolf wolf1 = new Wolf(1);

            wolf1.Eat();
            wolf1.Move();

            Console.WriteLine($"К волку добавился еще один волк и стало их {wolf1++}");
            Console.WriteLine($"В стаде случился прирост на 200%  и cтало их {wolf1 * 2}");

            Cat cat1 = new Cat();
            Cat cat2 = new Cat();

            cat1.Eat();
            cat2.Move();
            List <Cat> cats = new List <Cat> {
                cat1, cat2
            };
            List <Cat> cat = cats - cat2;

            Console.Read();
        }
예제 #12
0
        static void Main(string[] args)
        {
            Animal animal = new Animal();

            Console.WriteLine(animal.Eat());

            Dog dog = new Dog();

            Console.WriteLine(dog.Eat());
            Console.WriteLine(dog.Bark());

            Cat cat = new Cat();

            Console.WriteLine(cat.Eat());
            Console.WriteLine(cat.Meow());

            Puppy puppy = new Puppy();

            Console.WriteLine(puppy.Eat());
            Console.WriteLine(puppy.Bark());
            Console.WriteLine(puppy.Weep());
        }
예제 #13
0
        static void Main(string[] args)
        {
            Console.WriteLine("Inheritance in C#!");
            Console.WriteLine("------------------------------");

            Animal dumbo = new Animal()
            {
                Id   = 1,
                Name = "Dumbo",
                Type = "elephant"
                       // IsHappy = true - we can't access it here it's protected
            };

            dumbo.PrintInfo();
            dumbo.Eat();
            Console.WriteLine("------------------------------");
            Dog vele = new Dog()
            {
                Id    = 2,
                Type  = "dog",
                Name  = "Vele",
                Breed = "dzukela"
            };

            vele.PrintInfo();
            vele.Eat();
            vele.Bark();
            vele.IsDogHappy();
            Console.WriteLine("------------------------------");
            Cat garfield = new Cat()
            {
                Id       = 3,
                Name     = "Garfield",
                Laziness = "very much"
            };

            // we don't tell the type
            garfield.PrintInfo();
            garfield.Eat();
            // another overload is
            garfield.Eat("fish");
            garfield.Meow();
            Console.WriteLine("------------------------------");

            #region Enums
            // Enumerators
            Console.WriteLine(DayOfWeek.Tuesday);
            DiscountDay dayOne = new DiscountDay()
            {
                Discount = 10,
                Day      = DayOfWeek.Monday
            };
            Console.WriteLine($"On {dayOne.Day} you would have {dayOne.Discount}% discount");
            int dayOneInteger = (int)dayOne.Day;
            Console.WriteLine(dayOneInteger);

            // casting into integer
            DateTime today = DateTime.Now;
            // casting into integer
            int dayWeekToday = (int)today.DayOfWeek;
            Console.WriteLine(dayWeekToday);
            #endregion
            Console.ReadLine();
        }