using System;
public class Name {
public string firstName;
public string lastName;
public Name(string firstName, string lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
public virtual void Accelerate() {
Console.WriteLine("In Name Accelerate() method");
Console.WriteLine(lastName + " accelerating");
}
}
public class MyName : Name {
public MyName(string firstName, string lastName) : base(firstName, lastName) {
}
sealed public override void Accelerate() {
Console.WriteLine("In MyName Accelerate() method");
Console.WriteLine(lastName + " accelerating");
}
}
class Test{
public static void Main() {
Console.WriteLine("Creating a MyName object");
MyName myMyName = new MyName("Toyota", "MR2");
// call the MyName object's Accelerate() method
Console.WriteLine("Calling myMyName.Accelerate()");
myMyName.Accelerate();
}
}