using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Drawing; namespace TestTut { public class Circle { private Point myPoint; private double myRadius; /// /// Constructor for circle, default location, able to pass radius /// /// radius of the circle public Circle(double r) { myRadius = r; myPoint = new Point(0, 0); } /// /// Constructor for circle, able to pass in both location and radius /// /// Cordinate point circle lies on /// radius of the circle public Circle(Point loc, double r) { myRadius = r; myPoint = loc; } /// /// Circle Property for radius. Get and Set radius of circle /// public double Radius { get { return myRadius; } set { myRadius = value; } } /// /// Circle Property for diameter. Get and Set diameter of circle /// public double Diameter { get { return myRadius*2; } set { myRadius = value/2; } } /// /// Calculate the circumference of a circle within 2 decimal places /// /// returns the double value of the circumference public double getCircumference() { return ( (( 16 / 5 - 4 / 239 ) - ( 1 / 3 * ( 16 / 53 - 4 / 2393 ) ) ) + .14)*2*myRadius; } /// /// Calculate the area of a circle /// /// public double getArea() { return Math.PI*Math.Pow(this.Diameter,2); } /// /// The pie-shaped piece of a circle 'cut out' by two radii. /// /// the angle between the radii must be /// between 0(exclusive) and 360(exclusive) /// returns the area of the sector public double getSectorArea(double theta) { if( theta <= 0 || theta > 360 ) throw new ArgumentException("Angle must be between 0 and 360"); return (Math.Pow( myRadius, 2) * theta)/2; } /// /// Calculates the length of a side of a square that is circumscibed /// inside of the circle (Really make sure ur test code is working) /// /// Returns the length of one side of the square public double lengthOfCircumscribedSquare() { double sqrDiagonal = this.Diameter; //Pythagorean Thereom, in said case 'a'='b' because its a square, //therefore we will just use 's' instead; double c= sqrDiagonal; double s = Math.Sqrt( c/2); return s; } } }