using System;
public class BaseClass
{
public string lastName;
public string firstName;
public BaseClass(string lastName, string firstName)
{
this.lastName = lastName;
this.firstName = firstName;
}
public virtual void Accelerate()
{
Console.WriteLine("In BaseClass Accelerate() method");
Console.WriteLine(firstName + " accelerating");
}
}
public class DerivedClass : BaseClass
{
public DerivedClass(string lastName, string firstName) : base(lastName, firstName)
{
}
sealed public override void Accelerate()
{
Console.WriteLine("In DerivedClass Accelerate() method");
Console.WriteLine(firstName + " accelerating");
}
}
class MainClass
{
public static void Main()
{
DerivedClass myDerivedClass = new DerivedClass("A", "M");
Console.WriteLine("Calling myDerivedClass.Accelerate()");
myDerivedClass.Accelerate();
}
}
|