Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Man    m = new Man();
            Kid    k = new Kid();
            Boy    b = new Boy();
            Infant i = new Infant();

            /*
             *          case1();
             *          Console.WriteLine();
             *          case2();
             *          Console.WriteLine();
             *          case3();
             *          Console.WriteLine();
             *          case4();
             */
            try {
                Man m1 = new Boy();
                m1.Play();
                Boy b1;
                b1 = (Boy)m1;
                b1.Eat();
            }
            catch (Exception e) {
                Console.WriteLine(e.ToString());
            }

            Console.WriteLine(k is Man);
            Console.WriteLine(b is Man);
            Console.WriteLine(i is Man);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Man    m = new Man();
            Boy    b = new Boy();
            Kid    k = new Kid();
            Infant i = new Infant();

            case1();
            case2();
            case3();
            case4();
            case5();
            atThePark(i);
        }
Ejemplo n.º 3
0
 static void Main(string[] args)
 {
     Case1();
     Case2();
     Case3();
     Case4();
     try {
         Infant i = (Infant) new Man();
         i.Plays();
     }
     catch (InvalidCastException ex)
     {
         Console.WriteLine(ex.Message);
     }
     Console.ReadLine();
 }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            Man x = new Boy();

            x.Play(); // who will paly



            Boy y = new Boy();

            y.Play();//who will play


            Man t = new Infant();

            t.Play();//who willpaly
        }