public string Make { get; set; }
public string Model { get; set; }
public int Year { get; set; }
public decimal Price { get; set; }
public Vehicle(string make, string model, int year, decimal price)
public virtual void DisplayInfo()
Console.WriteLine($"{Year} {Make} {Model}, Price: ${Price}");
public class Car : Vehicle
public int PassengerCapacity { get; set; }
public string BodyStyle { get; set; }
public Car(string make, string model, int year, decimal price, int passengerCapacity, string bodyStyle)
: base(make, model, year, price)
PassengerCapacity = passengerCapacity;
Console.WriteLine($"{Make} {Model} started.");
public override void DisplayInfo()
Console.WriteLine($"Passenger Capacity: {PassengerCapacity}, Body Style: {BodyStyle}");
public class Truck : Vehicle
public int CargoCapacity { get; set; }
public string TruckType { get; set; }
public Truck(string make, string model, int year, decimal price, int cargoCapacity, string truckType)
: base(make, model, year, price)
CargoCapacity = cargoCapacity;
Console.WriteLine($"Loading cargo into {Make} {Model}.");
public override void DisplayInfo()
Console.WriteLine($"Cargo Capacity: {CargoCapacity} tons, Truck Type: {TruckType}");
public class Motorcycle : Vehicle
public string Type { get; set; }
public bool HasFairing { get; set; }
public Motorcycle(string make, string model, int year, decimal price, string type, bool hasFairing)
: base(make, model, year, price)
Console.WriteLine($"Accelerating the {Make} {Model}.");
public override void DisplayInfo()
Console.WriteLine($"Type: {Type}, Has Fairing: {(HasFairing ? "Yes" : "No")}");
static void Main(string[] args)
Car car = new Car("Toyota", "Camry", 2023, 30000m, 5, "Sedan");
Truck truck = new Truck("Ford", "F-150", 2022, 45000m, 2, "Pickup");
Motorcycle motorcycle = new Motorcycle("Harley-Davidson", "Sportster", 2023, 15000m, "Cruiser", true);
motorcycle.DisplayInfo();