36 lines
863 B
C#
36 lines
863 B
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace Lab1
|
|||
|
{
|
|||
|
class StaffParking : ParkingType
|
|||
|
{
|
|||
|
public override decimal Calculate(decimal hours)
|
|||
|
{
|
|||
|
hours = Math.Ceiling(hours);
|
|||
|
if (hours < 0)
|
|||
|
{
|
|||
|
throw new ParkingException("Parked for no or negative hours");
|
|||
|
}
|
|||
|
else if (hours > 24)
|
|||
|
{
|
|||
|
throw new ParkingException("Vehicle was parked for too long");
|
|||
|
}
|
|||
|
decimal value = hours > 0 ? ParkingRate : 0;
|
|||
|
if (hours <= 10)
|
|||
|
{
|
|||
|
hours = 0;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
hours -= 10;
|
|||
|
}
|
|||
|
value += hours * ParkingRate;
|
|||
|
return value;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|