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 Rectangle(Rectangle a) { setValue(a.width,a.height); setColor(a.color); }
public Triangle(Rectangle R) : base(R.Color) { this.Width = R.Width; this.Height = R.Height; }
public Rectangle(Rectangle pRectangle) : base(pRectangle.Color) { Width = pRectangle.Width; Height = pRectangle.Height; }
public Rectangle(Rectangle rec) : base(rec.Color) { Width = rec.Width; Height = rec.Height; }
// : base(a.Color) public Rectangle(Rectangle a) { _color = a.Color; // - Height = a.Height; Width = a.Width; }
public Rectangle(Rectangle re) { color = re.Color; width = re.width; height = re.height; }
public static double printPerimeter(Rectangle r) { return r.getPerimeter(); }
public Rectangle(Rectangle a) : base(a.Color) { Height = a.Height; Width = a.Width; }
//- Rectangle(Rectangle): copy constructor public Rectangle(Rectangle inRec) : base(inRec.Color) { Width = inRec.Width; Height = inRec.Height; }
public Rectangle(Rectangle a) { Height = a.Height; Width = a.Width; color = a.Color; }
public Rectangle(Rectangle obj) { _color = obj._color; _width = obj.Width; _height = obj.Height; }
public Rectangle(Rectangle r) : base(r.color) { _Height = r._Height; _Width = r._Width; }
public Rectangle(Rectangle a) { _c = a.Color; Width = a.Width; Height = a.Height; }
public Rectangle(Rectangle r) { _color = r.color; _height = r.height; _width = r.width; }
public Rectangle(Rectangle cpy) : base(cpy.color) { width = cpy.width; height = cpy.height; }
public Rectangle(Rectangle a) { Width = a.Width; Height = a.Height; color = a.color; }
public static double printPerimeter(Rectangle pRectangle) { return pRectangle.getPerimeter(); }
public Triangle(Rectangle a) : base(a.color) { Width = a.Width; Height = a.Height; }
public Triangle(Rectangle i) : base(i.Color) { Width = i.Width; Height = i.Height; }
public Rectangle(Rectangle r) : base(r.Color) { Height = r.Height; Width = r.Width; }
public Triangle(Rectangle t) { Height = t.Height; Width = t.Width; _Color = t.Color; }
public Rectangle(Rectangle obj) : base(obj.Color) { Width = obj.Width; Height = obj.Height; }
public Rectangle(Rectangle r) : base(r.color) { Width = r.Width; Height = r.Height; }
public Rectangle(Rectangle r) { Height = r.Height; Width = r.Width; _Color = r.Color; }
public Rectangle(Rectangle r) : base(r.color) { _width = r._width; _height = r._height; }
public Rectangle(Rectangle R) : base(R.color) { _Width = R.Width; _Height = R.Height; }
public Triangle(Rectangle r) : base(r.Color) { width = r.Width; height = r.Height; }