Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public abstract class Figure {
- private int _n;
- private int _mass;
- protected Figure(Int32 n, Int32 mass) {
- if (n < 0 || mass < 0)
- throw new ArgumentException();
- _n = n;
- _mass = mass;
- }
- protected Figure(Int32 n) {
- if (n < 0)
- throw new ArgumentException();
- _n = n;
- _mass = 1;
- }
- int N {
- get {
- return _n;
- }
- }
- //Масса фигуры
- int Mass {
- get {
- return _mass;
- }
- }
- //Площадь фигуры
- public abstract double Area {
- get;
- }
- //Плотность фигуры
- public double CondDensity {
- get {
- return Mass / Area;
- }
- }
- public override String ToString() {
- return $"Тип фигуры: {GetType()}. Количество вершин: {N}. Масса: {Mass}. Площадь: {Area:f3}. Условная плотность: {CondDensity:f3}";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement