using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace _00.Demo
{
internal class Triangle
{
private double _a;
private double _b;
private double _c;
private void ValidateSide(double value, string sideName)
{
if (value <= 0)
{
throw new ArgumentException($"The side {sideName} has to be more than zero");
}
}
public double A
{
get
{
return this._a;
}
private set
{
ValidateSide(value, nameof(A));
this._a = value;
}
}
public double B
{
get
{
return this._b;
}
private set
{
ValidateSide(value, nameof(B));
this._b = value;
}
}
public double C
{
get
{
return this._c;
}
private set
{
ValidateSide(value, nameof(A));
this._c = value;
}
}
public Triangle(double a, double b, double c)
{
if (a + c <= b ||
b + c <= a ||
a + b <= c)
{
throw new ArgumentException("The triangle does not exist");
}
this.A = a;
this.B = b;
this.C = c;
}
public double P()
{
return this.A + this.B + this.C;
}
public double S()
{
double p = P() / 2;
double S = Math.Sqrt(p * (p - this.A) * (p - this.B) * (p - this.C));
return S;
}
}
}