Пример #1
0
        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));
        }
Пример #2
0
        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");
        }
Пример #3
0
        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();
        }
Пример #4
0
 public Rectangle(Rectangle a)
 {
     setValue(a.width,a.height); setColor(a.color);
 }
Пример #5
0
 public Triangle(Rectangle R)
     : base(R.Color)
 {
     this.Width = R.Width;
     this.Height = R.Height;
 }
Пример #6
0
 public Rectangle(Rectangle pRectangle)
     : base(pRectangle.Color)
 {
     Width = pRectangle.Width;
     Height = pRectangle.Height;
 }
Пример #7
0
 public Rectangle(Rectangle rec)
     : base(rec.Color)
 {
     Width = rec.Width;
     Height = rec.Height;
 }
Пример #8
0
 // : base(a.Color)
 public Rectangle(Rectangle a)
 {
     _color = a.Color; // -
     Height = a.Height;
     Width = a.Width;
 }
Пример #9
0
 public Rectangle(Rectangle re)
 {
     color = re.Color;
     width = re.width;
     height = re.height;
 }
Пример #10
0
 public static double printPerimeter(Rectangle r)
 {
     return r.getPerimeter();
 }
Пример #11
0
 public Rectangle(Rectangle a)
     : base(a.Color)
 {
     Height = a.Height;
     Width = a.Width;
 }
Пример #12
0
 //- Rectangle(Rectangle): copy constructor
 public Rectangle(Rectangle inRec)
     : base(inRec.Color)
 {
     Width = inRec.Width;
     Height = inRec.Height;
 }
Пример #13
0
 public Rectangle(Rectangle a)
 {
     Height = a.Height;
     Width = a.Width;
     color = a.Color;
 }
Пример #14
0
 public Rectangle(Rectangle obj)
 {
     _color = obj._color;
     _width = obj.Width;
     _height = obj.Height;
 }
Пример #15
0
 public Rectangle(Rectangle r)
     : base(r.color)
 {
     _Height = r._Height;
     _Width = r._Width;
 }
Пример #16
0
 public Rectangle(Rectangle a)
 {
     _c = a.Color;
     Width = a.Width;
     Height = a.Height;
 }
Пример #17
0
 public Rectangle(Rectangle r)
 {
     _color = r.color;
     _height = r.height;
     _width = r.width;
 }
Пример #18
0
 public Rectangle(Rectangle cpy)
     : base(cpy.color)
 {
     width = cpy.width;
     height = cpy.height;
 }
Пример #19
0
 public Rectangle(Rectangle a)
 {
     Width = a.Width;
     Height = a.Height;
     color = a.color;
 }
Пример #20
0
 public static double printPerimeter(Rectangle pRectangle)
 {
     return pRectangle.getPerimeter();
 }
Пример #21
0
 public Triangle(Rectangle a)
     : base(a.color)
 {
     Width = a.Width;
     Height = a.Height;
 }
Пример #22
0
 public Triangle(Rectangle i)
     : base(i.Color)
 {
     Width = i.Width;
     Height = i.Height;
 }
Пример #23
0
 public Rectangle(Rectangle r)
     : base(r.Color)
 {
     Height = r.Height;
     Width = r.Width;
 }
Пример #24
0
 public Triangle(Rectangle t)
 {
     Height = t.Height;
     Width = t.Width;
     _Color = t.Color;
 }
Пример #25
0
 public Rectangle(Rectangle obj)
     : base(obj.Color)
 {
     Width = obj.Width;
     Height = obj.Height;
 }
Пример #26
0
 public Rectangle(Rectangle r)
     : base(r.color)
 {
     Width = r.Width;
     Height = r.Height;
 }
Пример #27
0
 public Rectangle(Rectangle r)
 {
     Height = r.Height;
     Width = r.Width;
     _Color = r.Color;
 }
Пример #28
0
 public Rectangle(Rectangle r)
     : base(r.color)
 {
     _width = r._width;
     _height = r._height;
 }
Пример #29
0
 public Rectangle(Rectangle R)
     : base(R.color)
 {
     _Width = R.Width;
     _Height = R.Height;
 }
Пример #30
0
 public Triangle(Rectangle r)
     : base(r.Color)
 {
     width = r.Width;
     height = r.Height;
 }