Пример #1
0
        void Expoly()
        {
            Pen pen = new Pen();

            pen.SetColor("red");

            WhiteBoardPen whiteBoardPen = new WhiteBoardPen();

            whiteBoardPen.SetColor("red");

            whiteBoardPen.ImAWhiteBordPen();

            Pen wbPen = whiteBoardPen;

            //will not work - wbPen.ImAWhiteBordPen

            wbPen.WriteToScreen("Poly? yes but can only call on Pen members");
        }
Пример #2
0
        //----- exampel code methods ------------------------------

        void ExInheritance()
        {
            Pen pen = new Pen();

            pen.WriteToScreen("Hello World!");

            pen.SetColor("red");

            pen.WriteToScreen("Hello World!");

            WhiteBoardPen whiteBoardPen = new WhiteBoardPen();

            whiteBoardPen.WriteToScreen("Im a whitebord pen");

            whiteBoardPen.SetColor("red");

            whiteBoardPen.WriteToScreen("Im a red whitebord pen");
        }