Completed Tile.cs Completed TilePattern.cs Completed CalcPiecesPerHour method in Company.cs
66 lines
No EOL
1.6 KiB
C#
66 lines
No EOL
1.6 KiB
C#
namespace Mosaic;
|
|
|
|
/// <summary>
|
|
/// Represents a single tile of a mosaic floor.
|
|
/// </summary>
|
|
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;
|
|
}
|
|
} |