-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
50 lines (46 loc) · 1.82 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
using ExercMetodosAbstratos.Entities;
using ExercMetodosAbstratos.Entities.Enums;
using System;
using System.Globalization;
using System.Collections.Generic;
namespace ExercMetodosAbstratos
{
internal class Program
{
static void Main(string[] args)
{
Console.Write("Enter the number of shapes: ");
int n = int.Parse(Console.ReadLine());
List<Shape> shapeList = new List<Shape>();
for (int i = 1; i <= n; i++)
{
Console.WriteLine($"Shape #{i} data: ");
Console.Write("Rectangle or Circle (r / c)? ");
Char typeShape = char.Parse(Console.ReadLine().ToLower());
Console.Write("Color (Black/Blue/Red): ");
Color color = (Color)Enum.Parse(typeof(Color), Console.ReadLine());
if (typeShape == 'r')
{
Console.Write("Width: ");
double width = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
Console.Write("Height: ");
double height = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
shapeList.Add(new Rectangle(color, width, height));
}
else
{
Console.Write("Radius: ");
double radius = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
shapeList.Add(new Circle(color, radius));
}
}
Console.WriteLine("");
Console.WriteLine("SHAPE AREAS:");
foreach (Shape shape in shapeList)
{
Console.WriteLine(shape.Area().ToString("F2", CultureInfo.InvariantCulture));
}
Console.ReadLine();
}
}
}