C#: PLease add inheritance and polymorphism in the code. And display the vehicle/s. Thanks! using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DemoApplication { public class Vehicle { protected int VehicleID; protected string VehicleName; public void SetTutorial(int pID,string pName) { VehicleID=pID; VehicleName=pName; } public String GetVehicle() { return VehicleName; } } public class VehicleDetails:Vehicle { public void RenameVehicle(String pNewName) { VehicleName=pNewName; } static void Main(string[] args) { VehicleDetails VD=new VehicleDetails(); VD.RenameVehicle("CarName:Audi"); VD.RenameVehicle("Number of doors:4"); VD.RenameVehicle("Number of wheels:4"); VD.RenameVehicle("Maxspeed:180 KMPH"); VD.RenameVehicle("Fuel capacity:50 lts"); Console.WriteLine(VD.GetVehicle()); Console.ReadKey(); } } }
C#: PLease add inheritance and polymorphism in the code. And display the vehicle/s. Thanks!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DemoApplication
{
public class Vehicle
{
protected int VehicleID;
protected string VehicleName;
public void SetTutorial(int pID,string pName)
{
VehicleID=pID;
VehicleName=pName;
}
public String GetVehicle()
{
return VehicleName;
}
}
public class VehicleDetails:Vehicle
{
public void RenameVehicle(String pNewName)
{
VehicleName=pNewName;
}
static void Main(string[] args)
{
VehicleDetails VD=new VehicleDetails();
VD.RenameVehicle("CarName:Audi");
VD.RenameVehicle("Number of doors:4");
VD.RenameVehicle("Number of wheels:4");
VD.RenameVehicle("Maxspeed:180 KMPH");
VD.RenameVehicle("Fuel capacity:50 lts");
Console.WriteLine(VD.GetVehicle());
Console.ReadKey();
}
}
}
Step by step
Solved in 2 steps