Ejemplo n.º 1
0
        public void Run()
        {
            // assign derived instance to base reference
            Telephone phone1 = new DigitalPhone();
            Telephone phone2 = new TalkingPhone();
            Telephone phone3 = new DigitalCellPhone();
            phone1.Ring(); // accessing the polymorphic method
            phone2.Ring(); // accessing the polymorphic method
            phone3.Ring(); // accessing the polymorphic method

            DigitalPhone phone4 = new DigitalPhone();
            DigitalPhone phone5 = new DigitalCellPhone();
            phone4.VoiceMail();
            phone5.VoiceMail();
        }
Ejemplo n.º 2
0
        public void Run()
        {
            // assign derived instance to base reference
            Telephone phone1 = new DigitalPhone();
            Telephone phone2 = new TalkingPhone();
            Telephone phone3 = new DigitalCellPhone();

            phone1.Ring(); // accessing the polymorphic method
            phone2.Ring(); // accessing the polymorphic method
            phone3.Ring(); // accessing the polymorphic method

            DigitalPhone phone4 = new DigitalPhone();
            DigitalPhone phone5 = new DigitalCellPhone();

            phone4.VoiceMail();
            phone5.VoiceMail();
        }