theme changed
This commit is contained in:
42
labs/lab9/MyClass/Triangle.cs
Normal file
42
labs/lab9/MyClass/Triangle.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
|
||||
class Triangle
|
||||
{
|
||||
private int a;
|
||||
private int b;
|
||||
private int c;
|
||||
|
||||
public Triangle(int a, int b, int c)
|
||||
{
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.c = c;
|
||||
}
|
||||
|
||||
public void Show()
|
||||
{
|
||||
Console.WriteLine("a: {0}\nb: {1}\nc: {2}", a, b, c);
|
||||
}
|
||||
|
||||
public int Perimeter()
|
||||
{
|
||||
return a + b + c;
|
||||
}
|
||||
|
||||
public double Area()
|
||||
{
|
||||
double p = Perimeter() / 2;
|
||||
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
|
||||
}
|
||||
|
||||
public bool Exists()
|
||||
{
|
||||
if (a <= 0 || b <= 0 || c <= 0) return false;
|
||||
|
||||
double maxSide = Math.Max(Math.Max(a, b), Math.Max(b, c));
|
||||
|
||||
if (maxSide >= a + b + c - maxSide) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user