// compile with: csc -target:library -reference:abstractshape.dll shapes.cs
public class Square : Shape
{
private int side;
public Square(int side, string id)
: base(id)
{
this.side = side;
}
public override double Area
{
get
{
// Given the side, return the area of a square:
return side * side;
}
}
}
public class Circle : Shape
{
private int radius;
public Circle(int radius, string id)
: base(id)
{
this.radius = radius;
}
public override double Area
{
get
{
// Given the radius, return the area of a circle:
return radius * radius * System.Math.PI;
}
}
}
public class Rectangle : Shape
{
private int width;
private int height;
public Rectangle(int width, int height, string id)
: base(id)
{
this.width = width;
this.height = height;
}
public override double Area
{
get
{
// Given the width and height, return the area of a rectangle:
return width * height;
}
}
}