本文整理汇总了C#中Lab4.Rectangle类的典型用法代码示例。如果您正苦于以下问题:C# Rectangle类的具体用法?C# Rectangle怎么用?C# Rectangle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Rectangle类属于Lab4命名空间,在下文中一共展示了Rectangle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
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: Main
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: Main
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: Rectangle
public Rectangle(Rectangle a)
{
setValue(a.width,a.height); setColor(a.color);
}
示例5: Triangle
public Triangle(Rectangle R)
: base(R.Color)
{
this.Width = R.Width;
this.Height = R.Height;
}
示例6: Rectangle
public Rectangle(Rectangle pRectangle)
: base(pRectangle.Color)
{
Width = pRectangle.Width;
Height = pRectangle.Height;
}
示例7: Rectangle
public Rectangle(Rectangle rec)
: base(rec.Color)
{
Width = rec.Width;
Height = rec.Height;
}
示例8: Rectangle
// : base(a.Color)
public Rectangle(Rectangle a)
{
_color = a.Color; // -
Height = a.Height;
Width = a.Width;
}
示例9: Rectangle
public Rectangle(Rectangle re)
{
color = re.Color;
width = re.width;
height = re.height;
}
示例10: printPerimeter
public static double printPerimeter(Rectangle r)
{
return r.getPerimeter();
}
示例11: Rectangle
public Rectangle(Rectangle a)
: base(a.Color)
{
Height = a.Height;
Width = a.Width;
}
示例12: Rectangle
//- Rectangle(Rectangle): copy constructor
public Rectangle(Rectangle inRec)
: base(inRec.Color)
{
Width = inRec.Width;
Height = inRec.Height;
}
示例13: Rectangle
public Rectangle(Rectangle a)
{
Height = a.Height;
Width = a.Width;
color = a.Color;
}
示例14: Rectangle
public Rectangle(Rectangle obj)
{
_color = obj._color;
_width = obj.Width;
_height = obj.Height;
}
示例15: Rectangle
public Rectangle(Rectangle r)
: base(r.color)
{
_Height = r._Height;
_Width = r._Width;
}