-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProgram.cs
79 lines (70 loc) · 1.7 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using DotNet.Docker.src;
using System;
class Program {
static void Main(string[] args)
{
// If there are no arguments we must produce an error
if (args.Length == 0 )
{
Console.WriteLine("You need to provide arguments. Type -h or --help for help");
return;
}
// This will display the help for the repository
if ("-h".Equals(args[0]) || "--help".Equals(args[0]))
{
try
{
if (args.Length < 2)
{
Help.PrintHelp();
}
else
{
Help.PrintHelp(args[1]);
}
}
catch (IllegalArgumentExeption ex)
{
Console.WriteLine(ex.Message);
}
return;
}
//We now start reading arguments. We will accept them in random possitions and mixed to make the programm more vercetile
List<int> ints = Statistics.GetInts(args); //CRUD creation
Dictionary<String, bool> operations = []; //CRUD creation
try
{
operations = Statistics.GetOperations(args); //CRUD updating
}
catch(IllegalArgumentExeption ex)
{
Console.WriteLine(ex.Message);
return;
}
// Depending on which flags are active we do the required computations
if (operations["individual"])
{
ints = Statistics.KeepUniqueValues(ints); //CRUD deleting
}
if (operations["min"])
{
Console.WriteLine($"The minimum is: {ints.Min()} "); //CRUD reading
}
if (operations["max"])
{
Console.WriteLine($"The maximum is: {ints.Max()} "); //CRUD reading
}
if (operations["mean"])
{
Console.WriteLine($"The mean is: {ints.Average()}"); //CRUD reading
}
if (operations["median"])
{
Console.WriteLine($"The median is: {Statistics.GetMedian(ints)}");
}
if (operations["mode"])
{
Console.WriteLine($"The mode is: {Statistics.GetMode(ints)}");
}
}
}