How do I reorganize this project?
class Service : IChargeable, IExtendable<br />
{
}
interface IChargeable
{
decimal? ChargeableAmount {
get;
}
}
interface IExtendable
{
bool IsExtendable {
get;
}
}
class DayService : Service { }
class NightService : Service { }
class TwentFourService : Service { }
The problem is that these services are paid at different rates, depending on whether they can expand or depending on their type.
A percentage of the paid amount is charged if the service is extended. Service Charge - ChargeableAmount * Seasonal rate that is different for each service.
. SeasonalRate, ServiceType, SeasonalRate? , , , .
SeasonalRates ServiceClass ( )? , SeasonalRates ServiceTypes?
SeasonalRate, , , DiscountRate, ZipCodeRate ..
ServiceType, ?
: ServiceType. , SeasonalRates
/ , , , :
interface IVisitable
{
Accept(IVisitor visitor);
}
interface IVisitor
{
Visit(IVisitable visitable);
}
interface IRate
{
Rate { get; }
}
class Service : IVisitable
{
public virtual Accept(IVisitor visitor);
}
class Visitor : IVisitor
{
public virtual Visit(IVisitable visitable) { }
public virtual Visit(DayService visitable) { }
public virtual Visit(NightService visitable) { }
}
class RateVisitor : Visitor, IRateVisitor
{
decimal? _Rate;
override Visit(IVisitable visitable) { };
override Visit(DayService visitable) {
public virtual Rate
{
return this._Rate;
}
}