-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
43 lines (38 loc) · 1.05 KB
/
Program.cs
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
using BinaryToDecimalConverter;
DecimalConverter converter = new();
if (args.Length == 0)
{
GreetRealtime();
string? input;
do
{
input = Console.ReadLine();
converter.Convert(input);
}
while (input?.ToUpper() != "QUIT");
}
else
{
GreetArgs();
foreach (var str in args)
{
if (converter.TryConvert(str, out var result))
Console.WriteLine($"{str} => {result}");
else
Console.WriteLine($"{str} is invalid");
}
}
void GreetRealtime()
{
string text = "Binary to decimal converter application. Input decimal number " +
"(number, based binary system, containing only \"0\" and \"1\"). Type \"quit\" to exit. " +
"Application also supports running with \"args\".";
Console.WriteLine(text);
}
void GreetArgs()
{
string text = "Binary to decimal converter. Running on values provided with \"args\". " +
"Application also supports realtime mode if you run it with empty \"args\".\n\n" +
"{binary} => {decimal}";
Console.WriteLine(text);
}