namespace DecoratorPattern
{
class Program
{
public interface SurgeryWard
{
string GetRoomName();
double GetPayment();
}
class FourBeddedRoom : SurgeryWard
{
private string roomname="Four Bedded Room";
private double roompayment = 1000.0;
public string GetRoomName()
{
return roomname;
}
public double GetPayment()
{
return roompayment;
}
}
class TwoBeddedRoom : SurgeryWard
{
private string roomname="Two Bedded Room";
private double roompayment = 2000.0;
public string GetRoomName()
{
return roomname;
}
public double GetPayment()
{
return roompayment;
}
}
class SingleRoom : SurgeryWard
{
private string roomname="SingleRoom";
private double roompayment = 3000.0;
public string GetRoomName()
{
return roomname;
}
public double GetPayment()
{
return roompayment;
}
}
public abstract class Decorator : SurgeryWard
{
SurgeryWard RoomType = null;
protected string addedamenity = "Undefined Decorator";
protected double amenitypayment = 0.0;
protected Decorator(SurgeryWard RoomTypee)
{
RoomType = RoomTypee;
}
#region SurgeryWard Members
string SurgeryWard.GetRoomName()
{
return string.Format("{0}, {1}", RoomType.GetRoomName(), addedamenity);
}
double SurgeryWard.GetPayment()
{
return amenitypayment + RoomType.GetPayment();
}
public void Show()
{
string a = string.Format("{0}, {1}", RoomType.GetRoomName(), addedamenity);
double b = amenitypayment + RoomType.GetPayment();
Console.WriteLine("RoomDetails {0} Payment {1}", a, b);
}
#endregion
}
class TelevisionDecorator : Decorator
{
public TelevisionDecorator(SurgeryWard RoomTypee)
: base(RoomTypee)
{
this.addedamenity = "Television";
this.amenitypayment = 100.0;
}
}
class LockerDecorator : Decorator
{
public LockerDecorator(SurgeryWard RoomTypee)
: base(RoomTypee)
{
this.addedamenity = "Locker";
this.amenitypayment = 200.0;
}
}
class WifiDecorator : Decorator
{
public WifiDecorator(SurgeryWard RoomTypee)
: base(RoomTypee)
{
this.addedamenity = "Wifi";
this.amenitypayment = 300.0;
}
}
class SofaBedDecorator : Decorator
{
public SofaBedDecorator(SurgeryWard RoomTypee)
: base(RoomTypee)
{
this.addedamenity = "SofaBed";
this.amenitypayment = 400.0;
}
}
class MiniFridgeDecorator : Decorator
{
public MiniFridgeDecorator(SurgeryWard RoomTypee)
: base(RoomTypee)
{
this.addedamenity = "MiniFridge";
this.amenitypayment = 500.0;
}
}
class WritingTableDecorator : Decorator
{
public WritingTableDecorator(SurgeryWard RoomTypee)
: base(RoomTypee)
{
this.addedamenity = "WritingTable";
this.amenitypayment = 6.0;
}
}
static void Main(string[] args)
{
SingleRoom sr = new SingleRoom();
WifiDecorator wd = new WifiDecorator(sr);
TelevisionDecorator td = new TelevisionDecorator(wd);
td.Show();
}
}
}