| using System;
public class Point {
  public enum PointRepresentation {Polar, Rectangular}
  private double r, a;     // polar data repr: radius, angle
  // Construct a point with polar coordinates
  private Point(double r, double a){
     this.r = r;
     this.a = a;
  }
  public static Point MakePolarPoint(double r, double a){
    return new Point(r,a);
  }
  public static Point MakeRectangularPoint(double x, double y){
    return new Point(RadiusGivenXy(x,y),AngleGivenXy(x,y));
  }
  private static double RadiusGivenXy(double x, double y){
    return Math.Sqrt(x * x + y * y);
  }
  private static double AngleGivenXy(double x, double y){
    return Math.Atan2(y,x);
  }
  // Remaining Point operations not shown
} |