point/point-representation-independence/version5a/AbstractPoint.cs - The abstract class Point with four abstract properties. | Lecture 8 - slide 8 : 37 Program 1 |
using System; abstract public class AbstractPoint { public enum PointRepresentation {Polar, Rectangular} // We have not yet decided on the data representation of Point public abstract double X { get ; set ; } public abstract double Y { get ; set ; } public abstract double R { get ; set ; } public abstract double A { get ; set ; } public void Move(double dx, double dy){ X += dx; Y += dy; } public void Rotate(double angle){ A += angle; } public override string ToString(){ return "(" + X + ", " + Y + ")" + " " + "[r:" + R + ", a:" + A + "] "; } protected static double RadiusGivenXy(double x, double y){ return Math.Sqrt(x * x + y * y); } protected static double AngleGivenXy(double x, double y){ return Math.Atan2(y,x); } protected static double XGivenRadiusAngle(double r, double a){ return r * Math.Cos(a); } protected static double YGivenRadiusAngle(double r, double a){ return r * Math.Sin(a); } }