static void Main()
{
CEmployee objCEmployee = new CManager();
objCEmployee = objCEmployee.Action();
objCEmployee = objCEmployee.Action();
objCEmployee = objCEmployee.Action();
// Wait for user
Console.ReadKey();
}
///
/// The 'CEmployee' abstract class
///
abstract class CEmployee
{
public abstract CEmployee Action();
}
class CManager: CEmployee
{
public override CEmployee Action()
{
Console.WriteLine(“This is Manager’s Work.”);
return new CDeveloper();
}
}
class CDeveloper : CEmployee
{
public override CEmployee Action()
{
Console.WriteLine(“This is Developer’s Work.”);
return new CManager();
}
}
No comments:
Post a Comment