using System; namespace april12 { public class Point { private double x; private double y; public Point(double x, double y) { this.x = x; this.y = y; } public double X { get { return x; } } public double Y { get { return y; } } } public abstract class Shape { private Point location; public Shape(Point p) { location = p; } public Point Location { get { return location; } } public abstract double Area(); } public class Circle : Shape { private double radius; public Circle(Point center, double r) : base(center) { radius = r; } public override double Area() { return Math.PI * Math.Pow(radius, 2.0); } } public class Rect : Shape { private Point toPoint; public Rect(Point from, Point to) : base(from) { toPoint = to; } public override double Area() { double width; double height; width = Math.Abs(toPoint.X - Location.X); height = Math.Abs(toPoint.Y - Location.Y); return width * height; } } public class TestShape { public static void Main() { Point center = new Point(3.0, 3.0); double radius = 2.0; Circle c = new Circle(center, radius); Console.WriteLine("Circle area: {0:F6}",c.Area()); Point from, to; from = new Point(1.0, 3.0); to = new Point(-3.0, 8.0); Rect r = new Rect(from, to); Console.WriteLine("Rect area: " + r.Area()); } } }