Search⌘ K
AI Features

Solution: E-Commerce Shipping Calculator

Explore how to implement an e-commerce shipping calculator by applying C# object-oriented programming concepts such as inheritance, virtual methods, and polymorphism. Understand how to override methods for custom calculations and output dynamic shipping costs for different shipment types.

We'll cover the following...
C# 14.0
namespace Retail;
public class PostalShipment
{
public double WeightInPounds { get; init; }
public virtual decimal CalculateCost()
{
return 5.00m + (decimal)(WeightInPounds * 0.5);
}
}
public class ExpressShipment : PostalShipment
{
public override decimal CalculateCost()
{
return base.CalculateCost() + 10.00m;
}
}
...