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 int Year { get; set; }
public string Make { get; set; }
public string Model { get; set; }
public double BasePrice { get; set; }
public double TotalPrice {
return BasePrice + Options.Sum(x => x.Price);
public List<BaseCarOption> Options { get; set; }
public class BaseCarOption
public string OptionType { get; set; }
public double Price { get; set;}
public class V8Option : BaseCarOption
OptionType = "V8 Engine";
public class V6Option : BaseCarOption
OptionType = "V6 Engine";
public class SunRoofOption : BaseCarOption
public class LeatherSeatsOption : BaseCarOption
public LeatherSeatsOption()
OptionType = "Leather Seats";