c# and stack over flow | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

c# and stack over flow

i got two question why i get stack overflow and why after changing area radius does not change class Program { static void Main(string[] args) { Circle a = new Circle(3,3,4);//R=3 Circle b = new Circle(5, 6, 3);//R =5 Console.WriteLine(a.CompareTwoCircles(b));// return -1 a<b a.Radius = 6; Console.WriteLine(a.CompareTwoCircles(b));//return 1 a >b //------------------------------------ Console.WriteLine(a.Area); Console.WriteLine(a.circumference); a.Area = 153.94; Console.WriteLine(a.Radius); //7 expected } } class Circle { private Cartesian centerOfcircle; public double Radius { set { this.Radius = Math.Abs(value); } get { return this.Radius; } } public double Area{ get { return Math.PI * (Radius * Radius); } set { this.Radius = Math.Abs(Math.Sqrt(this.Area / Math.PI)); } } public double circumference { get { return 2 * Math.PI * Radius; } set { this.Radius = Math.Abs(this.circumference / Math.PI / 2); } } public Circle(double radius , double x , double y) { this.centerOfcircle = new Cartesian(x, y); this.Radius = Math.Abs(radius); } public int CompareTwoCircles(Circle input) { if (Radius > input.Radius) return 1; else if (Radius == input.Radius) return 0; else return -1; } }

14th Jan 2021, 9:47 AM
navid
0 Answers