-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
59 lines (47 loc) · 1.96 KB
/
Program.cs
File metadata and controls
59 lines (47 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using static RightTriangle.ConsoleUtilites;
namespace RightTriangle
{
class Program
{
static void Main(string[] args)
{
while (true)
{
int[] _sides = new int[3];
for (int _sideNumber = 0; _sideNumber < _sides.Length; _sideNumber++)
{
while (true)
{
Write(String.Format("{0} side, value = ", _sideNumber + 1), MessageType.Any);
var _userInput = Console.ReadLine();
bool _isInteger = Int32.TryParse(_userInput, out int _sideValue);
if (_isInteger == false)
{
Write("Error, input is not integer", MessageType.Error);
continue;
}
if (_sideValue <= 0)
{
Write("Triangle does'nt exist, rewrite side", MessageType.Error);
continue;
}
_sides[_sideNumber] = _sideValue;
break;
}
}
bool _isExist = TriangleUtils.IsRightTriangleExist(_sides);
Write(String.Format("This right triangle exist: {0}", _isExist.ToString()), MessageType.Error);
if (_isExist == false)
{
Console.ReadKey();
break;
}
Write(String.Format("Hypotenuse in this triangle equal: {0}",TriangleUtils.GetHypotenuse(_sides).ToString()), MessageType.Error);
Write(String.Format("Square in this triangle equal: {0}", TriangleUtils.GetTriangleSquare(_sides).ToString()), MessageType.Error);
Console.ReadKey();
break;
}
}
}
}