using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Apps
{
class Doctor
{
protected string name, specialization;
public Doctor(string name, string specialization)
{
this.name = name;
this.specialization = specialization;
}
public void Print()
{
Console.WriteLine(name);
Console.WriteLine(specialization);
}
}
class ResidentalDoctors : Doctor
{
protected int salary;
public ResidentalDoctors(string name, string specialization, int salary)
: base(name, specialization)
{
this.salary = salary;
}
public new void Print()
{
base.Print();
Console.WriteLine(salary);
}
public int GetPay()
{
return salary;
}
}
class Consultant : Doctor
{
protected int fees, visitNum;
public Consultant(string name, string specialization, int fees, int visitNum)
: base(name, specialization)
{
this.fees = fees;
this.visitNum = visitNum;
}
public new void Print()
{
base.Print();
Console.WriteLine(fees);
Console.WriteLine(visitNum);
}
public int GetPay()
{
return fees * visitNum;
}
}
class UnderstandingInheritanceConcept
{
public static void Main()
{
ResidentalDoctors rd = new ResidentalDoctors("Steve", "General", 100);
Consultant c = new Consultant("Chitti", "General", 300, 10);
Console.WriteLine(rd.GetPay());
Console.WriteLine(c.GetPay());
rd.Print();
c.Print();
}
}
}
No comments:
Post a Comment