using System.Collections.Generic;
using System.Threading.Tasks;
static void Main(string[] args)
var lannasCorvette = new Car
Options = new List<BaseCarOption>
var stevesGrandCherokee = new Car
Model = "Grand Cherokee",
Options = new List<BaseCarOption>
new LeatherSeatsOption(),
Console.WriteLine($"Lanna just bought a new {lannasCorvette.Year} {lannasCorvette.Make} {lannasCorvette.Model} and it costed her ${lannasCorvette.TotalPrice}");
Console.Write($"Steve just bought a new {stevesGrandCherokee.Year} {stevesGrandCherokee.Make} {stevesGrandCherokee.Model} and it costed him ${stevesGrandCherokee.TotalPrice}");
public CarType Type { get; set; }
public int Year { get; set; }
public string Make { get; set; }
public string Model { get; set; }
public Dictionary<CarType, double> BasePrices { get; set; }
public double TotalPrice {
return BasePrices[Type] + Options.Sum(x => x.Prices[Type]);
public List<BaseCarOption> Options { get; set; }
BasePrices = new Dictionary<CarType, double>()
{ CarType.Coupe, 15000 },
{ CarType.Truck, 25000 },
public class BaseCarOption
public string OptionType { get; set; }
public Dictionary <CarType, double> Prices { get; set;}
public class V8Option : BaseCarOption
OptionType = "V8 Engine";
Prices = new Dictionary<CarType, double>()
public class V6Option : BaseCarOption
OptionType = "V6 Engine";
Prices = new Dictionary<CarType, double>()
public class SunRoofOption : BaseCarOption
Prices = new Dictionary<CarType, double>()
public class LeatherSeatsOption : BaseCarOption
public LeatherSeatsOption()
OptionType = "Leather Seats";
Prices = new Dictionary<CarType, double>()