About us |  Help us improve
intelliVERB - Get a fair search of the Internet !
Visual studio .net
SQL Server
Oracle
Main  >  Object oriented  >  Inheritance Email this page to friend
Inheritance
Multiple inheritance
 
 
 
 
 
C#InheritanceTop

/// <summary>
/// Employee_Factory derived from Factory class
/// and override and implement its methods
/// </summary>

public class Employee_Factory:Factory
{
 public override object Create()
 {
  Employee oEmployee=new Employee();
  //.........
  //.........
  //.........

  return oEmployee;
 }

 public override bool Update(object oEmployee)
 {
  //update instructions
  //.........
  //.........
  //.........

  return true;
 }
 public override bool Delete(object oEmployee)
 {
  //delete instructions
  //.........
  //.........
  //.........

  return true;
 }
}

/// <summary>
/// Task class implement ITask interface
/// </summary>

public class Task:ITask
{
 public int .Task_Id;
 public string Title;
 public bool isDone;
 //
 public DateTime Deadline;
 //Achievement date
 public DateTime AchievedOn;

 
 public bool IsPending(out DateTime p_Deadline)
 {
  p_Deadline=this.Deadline;
  return (! this.isDone);
 }
 public bool IsDone(out DateTime p_AchievedOn)
 {
  p_AchievedOn=this.AchievedOn;
  return (this.isDone);
 
 }
 public bool HasPassedDealine(out DateTime p_Deadline)
 {
  p_Deadline=this.Deadline;
  return (DateTime.Now>this.Deadline);
 }
}

/// <summary>
/// Employee class implement IEmployee class
/// </summary>

public class Employee:IEmployee
{
 private string m_Empl_Id;
 private string m_First_Name;
 private string m_Last_Name;
 private DateTime m_DOB;

 public string Empl_Id
 {
  get{return m_Empl_Id;}
  set{m_Empl_Id=value; }
 }
 public string First_Name
 {
  get{return m_First_Name; }
  set{First_Name=value;}
 }
 public string Last_Name
 {
  get{return m_Last_Name; }
  set{m_Last_Name=value;}
 }
 public DateTime DOB
 {
  get{return m_DOB;}
  set{m_DOB=value;}
 }
 public double CalculateAge()
 {
  return DateTime.Now.Year - DOB.Year;
 }
}


C#Multiple inheritanceTop

/// <summary>
/// Developper class inplement a case of mutiple inheritance
/// of interfaces IEmployee and IDeveloper
/// </summary>

public class Developer:IEmployee,IDeveloper
{
 private Employee oEmployee;
 private string m_CurrentProject;
 private Developer_Level m_Level;
 private Task[] m_ToDoList;
 
 public Developer()
 {
  this.oEmployee=new Employee();
 }

 #region IEmployee Members
 public string Empl_Id
 {
  get
  {
   return this.oEmployee.Empl_Id;
  }
  set
  {
   this.oEmployee.Empl_Id=value;
  }
 }

 public string First_Name
 {
  get
  {
   return this.oEmployee.First_Name;
  }
  set
  {
   this.oEmployee.First_Name=value;
  }
 }

 public string Last_Name
 {
  get
  {
   return this.oEmployee.Last_Name;
  }
  set
  {
   this.oEmployee.Last_Name=value;
  }
 }

 public DateTime DOB
 {
  get
  {
   return this.oEmployee.DOB;
  }
  set
  {
   this.oEmployee.DOB=value;
  }
 }

 public double CalculateAge()
 {
  return this.oEmployee.CalculateAge();
 }
 #endregion

 #region IDeveloper Members
 public Developer_Level Level
 {
  get
  {
   return this.m_Level;
  }
  set
  {
   this.m_Level=value;
  }
 }
 public string CurrentProject
 {
  get
  {
   return this.m_CurrentProject;
  }
  set
  {
   this.m_CurrentProject=value;
  }
 }
 public Task[] ToDoList
 {
  get
  {
   return m_ToDoList;
  }
  set
  {
   m_ToDoList=value;
  }
 }
 public Task[] PendingTasks()
 {
  Task[] aTask=new Task[0];
  for (int .i=0;i<m_ToDoList.Length;i++)
  {
   //get tasks with isDone=false
   if (! m_ToDoList[i].isDone)
   {
    aTask=addTask(aTask,m_ToDoList[i]);
   }
  }
  return aTask;
 }
 #endregion

 
}

You last visited
XML
Assemblies
DDL Sql Server
Sql Server Basic functions
COM +
DML Sql Server
 
 
Make a secure donation now with PayPal!