namespace Mosaic; /// /// Represents a single tile of a mosaic floor. /// public sealed class Tile { private readonly TileStyle _style; private readonly int _width; private readonly int _height; public readonly int Area; public Tile(TileStyle style, int width, int height) { _style = style; _width = width; _height = height; Area = width * height; } public decimal CalcProductionCost() { decimal pricePerCm = 0.016M; decimal sizeFactor = 1; switch (Area) { case < 100: sizeFactor = 1.5M; break; case < 400: sizeFactor = 1.2M; break; case > 2500: if (Area > 8100) { sizeFactor = 1.8M; break; } sizeFactor = 1.6M; break; } decimal styleFactor = 1; switch (_style) { case TileStyle.Raw: styleFactor = 0.8M; break; case TileStyle.FancyColor: styleFactor = 1.1M; break; case TileStyle.SimplePattern: styleFactor = 1.25M; break; case TileStyle.Ornate: styleFactor= 2.3M; break; } decimal areaInCm = Area / 100M; decimal cost = areaInCm * pricePerCm * sizeFactor * styleFactor; return cost; } }