Ejemplo n.º 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));
        }
Ejemplo n.º 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");
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 4
0
 public Triangle(Triangle a)
     : base(a.Color)
 {
     Height = a.Height;
     Width = a.Width;
 }
Ejemplo n.º 5
0
 public Triangle(Triangle t)
 {
     Width = t.Width;
     Height = t.Height;
     color = t.color;
 }
Ejemplo n.º 6
0
 public static double printPerimeter(Triangle pTriangle)
 {
     return pTriangle.getPerimeter();
 }
Ejemplo n.º 7
0
 public Triangle(Triangle a)
 {
     Height = a.Height;
     Width = a.Width;
     color = a.Color;
 }
Ejemplo n.º 8
0
 public Triangle(Triangle pTriangle)
     : base(pTriangle.Color)
 {
     Width = pTriangle.Width;
     Height = pTriangle.Height;
 }
Ejemplo n.º 9
0
 public Triangle(Triangle r)
 {
     _color = r.Color;
     Width = r.Width;
     Height = r.Height;
 }
Ejemplo n.º 10
0
 //: base(a.Color)
 public Triangle(Triangle a)
 {
     _color = a.Color; //-
     Height = a.Height;
     Width = a.Width;
 }
Ejemplo n.º 11
0
 public Triangle(Triangle a)
 {
     _c = a.Color;
     Width = a.Width;
     Height = a.Height;
 }
Ejemplo n.º 12
0
 public Triangle(Triangle a)
 {
     width = a.width;
     height = a.height;
     _color = a.color;
 }
Ejemplo n.º 13
0
 public Triangle(Triangle t)
     : base(t.Color)
 {
     _Width = t._Width;
     _Height = t._Height;
 }
Ejemplo n.º 14
0
 public Triangle(Triangle obj)
 {
     _color = obj._color;
     _width = obj.Width;
     _height = obj.Height;
 }
Ejemplo n.º 15
0
 //- Triangle(Rectangle) : copy constructor
 public Triangle(Triangle inTri)
     : base(inTri.Color)
 {
     Width = inTri.Width;
     Height = inTri.Height;
 }
Ejemplo n.º 16
0
 public Triangle(Triangle rec)
     : base(rec.Color)
 {
     Width = rec.Width;
     Height = rec.Height;
 }
Ejemplo n.º 17
0
 public Triangle(Triangle re)
 {
     color = re.Color;
     width = re.width;
     height = re.height;
 }
Ejemplo n.º 18
0
 public Triangle(Triangle t)
     : base(t.Color)
 {
     prWidth = t.prWidth;
     prHeight = t.prHeight;
 }
Ejemplo n.º 19
0
 public Triangle(Triangle cpy)
     : base(cpy.color)
 {
     width = cpy.width;
     height = cpy.height;
 }
Ejemplo n.º 20
0
 public Triangle(Triangle a)
 {
     setValue(a.width,a.height); setColor(a.color);
 }
Ejemplo n.º 21
0
 public Triangle(Triangle t)
     : base(t.color)
 {
     Width = t.Width;
     Height = t.Height;
 }
Ejemplo n.º 22
0
 public static double printPerimeter(Triangle t)
 {
     return t.getPerimeter();
 }
Ejemplo n.º 23
0
 public Triangle(Triangle a)
 {
     Width = a.Width;
     Height = a.Height;
     _Color = a._Color;
 }
Ejemplo n.º 24
0
 public Triangle(Triangle tri)
     : base(tri.Color)
 {
     Width = tri.Width;
     Height = tri.Height;
 }