I have designed classes for the system as below diagram shown:
public abstract class Service
{
public abstract double price { get; }
public int quantity { get; set; }
public double Cost { get { return price * quantity; } }
}
public class FaxService : Service
{
public FaxService()
{
}
public override double price
{
get { return 1; }
}
}
public class PrintingService : Service
{
public PrintingService()
{
}
public override double price
{
get { return 0.5; }
}
}
public class ColorPrintingService : PrintingService
{
public ColorPrintingService()
{
}
}
I have few different services inherit from Service class which are Fax, Scan and Printing. The ColorPrinting from PrintingService because I would like to reuse back the PrintingService price, for example
this.price = this.price + 10;
as ColorPrinting price. If any price update in PrintingService, it will reflect to ColorPrinting too.
Aucun commentaire:
Enregistrer un commentaire