-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
75 lines (68 loc) · 2.98 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
using System;
using System.Collections.Generic;
namespace Case_Study
{
class Program
{
static void Main(string[] args)
{
List<Shape> Shapes = new List<Shape>();
Shapes.Add(new Shape("rechthoek", "lengte", "breedte", "lengte * breedte"));
Shapes.Add(new Shape("driehoek", "basis", "hoogte", "(basis * hoogte) / 2"));
Shapes.Add(new Shape("cirkel", "straal", null, "straal * straal * pi"));
double ShapeValueA = 0;
double ShapeValueB = 0;
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("Welkom! Laatst gewijzigd op 2/12/2020 22:07\n");
Console.ForegroundColor = ConsoleColor.White;
//Show all possible shapes
int counter = 1;
foreach (Shape shape in Shapes) {
Console.WriteLine(counter.ToString() + ". " + shape.getName());
counter++;
}
//Ask which shape
int ShapeNumber = -1;
do {
Console.Write("Van welke vorm wil je de oppervlakte berekenen? ");
try {
ShapeNumber = Convert.ToInt32(Console.ReadLine());
}
catch {
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("\nDe ingevoerde waarde is niet correct!");
Environment.Exit(1);
}
}
while (ShapeNumber > Shapes.Count || ShapeNumber < 1);
Shape ShapeSelected = Shapes[ShapeNumber-1];
//Ask the value's needed to calculate the surface
Console.WriteLine("\nEen " + ShapeSelected.getName() + " wordt op de volgende manier berekend: " + ShapeSelected.getCalculation());
Console.Write(ShapeSelected.getValueA() + ": ");
try {
ShapeValueA = Double.Parse(Console.ReadLine());
}
catch {
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("\nDe ingevoerde waarde is niet correct!");
Environment.Exit(1);
}
if (ShapeSelected.getValueB() != null) {
Console.Write(ShapeSelected.getValueB() + ": ");
try {
ShapeValueB = Double.Parse(Console.ReadLine());
}
catch {
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("\nDe ingevoerde waarde is niet correct!");
Environment.Exit(1);
}
}
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("\nDe berekende " + ShapeSelected.getName() + " heeft als oppervlakte: " + ShapeSelected.calculateResult(ShapeValueA, ShapeValueB));
Console.ForegroundColor = ConsoleColor.White;
Console.Write("\nDruk enter om het programma af te sluiten.");
Console.Read();
}
}
}