Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace PlaneLib
- {
- class Circle : PlaneFigure
- {
- static Random rnd = new Random();
- private string name;
- public string Name
- {
- get { return name; }
- }
- private double radius;
- public double Radius
- {
- get { return radius; }
- set
- {
- if (value <= 0)
- {
- throw new PlaneFigureException("the circle's radius is non-positive");
- }
- else
- {
- radius = value;
- }
- }
- }
- public Circle(string name, double _radius) : base(name)
- {
- this.Radius = _radius;
- this.name = name;
- }
- public override double Area
- {
- get
- {
- return Math.PI * this.Radius * this.Radius;
- }
- }
- public override void ChangePlaneFigure()
- {
- double curr = -1;
- while (curr <= 0)
- {
- curr = rnd.Next(-2, 6) + rnd.NextDouble();
- this.Radius = curr;
- }
- }
- public override string ToString()
- {
- return base.ToString() + $"Circle with radius: {Radius} cm";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement