public static void Main(string[] args) { Shape s1 = new Rectangle("red", 4, 5); Console.WriteLine (s1); Shape s2 = new Triangle("blue", 4, 5); Console.WriteLine (s2); Shape s3 = new Rectangle(); Console.WriteLine (s3); Rectangle r1 = new Rectangle((Rectangle)s1); Console.WriteLine (r1); r1.Width=-5.0; r1.Height=15; Console.WriteLine (r1); Triangle t1 = new Triangle(); t1.Width=3; t1.Height=4; Console.WriteLine (t1); //Shape s4 = new Shape("green"); //Console.WriteLine (s4); Console.WriteLine ("Perimeter of s1: {0}",printPerimeter (s1)); Console.WriteLine ("Perimeter of s2: {0}",printPerimeter (s2)); Console.WriteLine ("Perimeter of s3: {0}",printPerimeter (s3)); Console.WriteLine ("Perimeter of r1: {0}",printPerimeter (r1)); Console.WriteLine ("Perimeter of t1: {0}",printPerimeter (t1)); }
public static double printPerimeter(Triangle s) { return s.getPerimeter(); }
public Triangle(Triangle t) : base(t.Color) { Width = t.Width; Height = t.Height; }
public Triangle(Triangle T) : base(T.Color) { _height = T.Height; _width = T.Width; }
public Triangle(Triangle r) : base(r.color) { Width = r.Width; Height = r.Height; }
public Triangle(Triangle A) : base(A.Color) { Width = A.Width; Height = A.Height; }
//- Triangle(Rectangle) : copy constructor public Triangle(Triangle t) { _color = t._color; Width = t.Width; Height = t.Height; }
public Triangle(Triangle t) : base(t.Color) { _Width = t._Width; _Height = t._Height; }
public Triangle(Triangle t1) : base(t1.Color) { _width = t1.Width; _height = t1.Height; }
public Triangle(Triangle t) { _color = t.Color; _height = t.Height; _width = t.Width; }
public Triangle(Triangle triangle) : base(triangle.Color) { width = triangle.width; height = triangle.height; }
public static double printPerimeter(Triangle s) { return(s.getPerimeter()); }
public Triangle(Triangle t) { _Color = t._Color; Width = t._Width; Height = t._Height; }
public Triangle(Triangle t) { Width = t.Width; Height = t.Height; _Color = t._Color; }