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 void Main(string[] args) { Shape s1 = new Rectangle("red", 4, 5); Console.WriteLine (s1); Console.WriteLine ("Area is " + s1.getArea()); Shape s2 = new Triangle("blue", 4, 5); Console.WriteLine (s2); Console.WriteLine ("Area is " + s2.getArea()); // Cannot create instance of an abstract class - Compilation Error!! // Shape s3 = new Shape("green"); }
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 s1: "+printPerimeter (s1)); Console.WriteLine ("Perimeter s1: "+printPerimeter (s2)); Console.WriteLine ("Perimeter s1: "+printPerimeter (s3)); Console.WriteLine ("Perimeter s1: "+printPerimeter (r1)); Console.WriteLine ("Perimeter s1: "+printPerimeter (t1)); Console.ReadKey(); }
public Triangle(Triangle a) : base(a.Color) { Height = a.Height; Width = a.Width; }
public Triangle(Triangle t) { Width = t.Width; Height = t.Height; color = t.color; }
public static double printPerimeter(Triangle pTriangle) { return pTriangle.getPerimeter(); }
public Triangle(Triangle a) { Height = a.Height; Width = a.Width; color = a.Color; }
public Triangle(Triangle pTriangle) : base(pTriangle.Color) { Width = pTriangle.Width; Height = pTriangle.Height; }
public Triangle(Triangle r) { _color = r.Color; Width = r.Width; Height = r.Height; }
//: base(a.Color) public Triangle(Triangle a) { _color = a.Color; //- Height = a.Height; Width = a.Width; }
public Triangle(Triangle a) { _c = a.Color; Width = a.Width; Height = a.Height; }
public Triangle(Triangle a) { width = a.width; height = a.height; _color = a.color; }
public Triangle(Triangle t) : base(t.Color) { _Width = t._Width; _Height = t._Height; }
public Triangle(Triangle obj) { _color = obj._color; _width = obj.Width; _height = obj.Height; }
//- Triangle(Rectangle) : copy constructor public Triangle(Triangle inTri) : base(inTri.Color) { Width = inTri.Width; Height = inTri.Height; }
public Triangle(Triangle rec) : base(rec.Color) { Width = rec.Width; Height = rec.Height; }
public Triangle(Triangle re) { color = re.Color; width = re.width; height = re.height; }
public Triangle(Triangle t) : base(t.Color) { prWidth = t.prWidth; prHeight = t.prHeight; }
public Triangle(Triangle cpy) : base(cpy.color) { width = cpy.width; height = cpy.height; }
public Triangle(Triangle a) { setValue(a.width,a.height); setColor(a.color); }
public Triangle(Triangle t) : base(t.color) { Width = t.Width; Height = t.Height; }
public static double printPerimeter(Triangle t) { return t.getPerimeter(); }
public Triangle(Triangle a) { Width = a.Width; Height = a.Height; _Color = a._Color; }
public Triangle(Triangle tri) : base(tri.Color) { Width = tri.Width; Height = tri.Height; }