//---- 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)); }
public static void ShowPoint() { Point p = new ColouredPoint(7, 5, "Red"); Console.WriteLine(p.ToString()); Console.WriteLine(p); // ToString from ColouredPoint }
public static void SumOfPoint() { Point p = new Point(3, 5); ColouredPoint cp = new ColouredPoint(1, 2, "Red"); Console.WriteLine(sum(p, cp)); }
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)); }
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)); }
public static void ColorOfPoint() { Point q = new ColouredPoint(1, 2, "Red"); if (q is ColouredPoint) { ColouredPoint cp = (ColouredPoint)q; Console.WriteLine(IsRed(cp)); } }
private static bool IsRed(ColouredPoint p) { return(p.Colour.Equals("Red")); }