Exemplo n.º 1
0
        //---- COURS 3 -----
        // UML
        //---- COURS 4 -----
        // Probleme avec la librarie Systeme.Drawing chez moi donc j'ai mis
        // les couleurs en String

        public static void PointTranslation()
        {
            ColouredPoint cp = new ColouredPoint(1, 2, "Red");

            Console.WriteLine(cp);
            Console.WriteLine(cp.Translate(1, 0));
        }
Exemplo n.º 2
0
        public static void ShowPoint()
        {
            Point p = new ColouredPoint(7, 5, "Red");

            Console.WriteLine(p.ToString());
            Console.WriteLine(p);             // ToString from ColouredPoint
        }
Exemplo n.º 3
0
        public static void SumOfPoint()
        {
            Point p = new Point(3, 5);

            ColouredPoint cp = new ColouredPoint(1, 2, "Red");

            Console.WriteLine(sum(p, cp));
        }
Exemplo n.º 4
0
        public static void RealTypeOfPoint()
        {
            ColouredPoint cp = new ColouredPoint(1, 2, "Red");

            Console.WriteLine((cp is Point) + " / " + (cp is ColouredPoint));

            Console.WriteLine(cp.GetType() == typeof(Point));
            Console.WriteLine(cp.GetType() == typeof(ColouredPoint));
        }
Exemplo n.º 5
0
        public static void PolymorfPoint()
        {
            Point p = new Point(3, 5);

            ColouredPoint cp = new ColouredPoint(1, 2, "Red");

            Console.WriteLine((p is Point) + " / " + (p is ColouredPoint));
            Console.WriteLine((cp is Point) + " / " + (cp is ColouredPoint));
        }
Exemplo n.º 6
0
        public static void ColorOfPoint()
        {
            Point q = new ColouredPoint(1, 2, "Red");

            if (q is ColouredPoint)
            {
                ColouredPoint cp = (ColouredPoint)q;
                Console.WriteLine(IsRed(cp));
            }
        }
Exemplo n.º 7
0
 private static bool IsRed(ColouredPoint p)
 {
     return(p.Colour.Equals("Red"));
 }