You know what definitely never changes? Shipping prices. Famously static, despite all economic conditions and the same across all shipping providers. It doesn't matter where you're shipping from, or to, you know exactly what the price will be to ship that package at all times.
Wait, what? You don't think that's true? It must be true, because Chris sent us this function, which calculates shipping prices, and it couldn't be wrong, could it?
public double getShippingCharge(String shippingType, bool saturday, double subTot)
{
double shCharge = 0.00;
if(shippingType.Equals("Ground"))
{
if(subTot <= 29.99 && subTot > 0)
{
shCharge = 4.95;
}
else if(subTot <= 99.99 && subTot > 29.99)
{
shCharge = 7.95;
}
else if(subTot <= 299.99 && subTot > 99.99)
{
shCharge = 9.95;
}
else if(subTot > 299.99)
{
shCharge = subTot * .05;
}
}
else if(shippingType.Equals("Two-Day"))
{
if(subTot <= 29.99 && subTot > 0)
{
shCharge = 14.95;
}
else if(subTot <= 99.99 && subTot > 29.99)
{
shCharge = 19.95;
}
else if(subTot <= 299.99 && subTot > 99.99)
{
shCharge = 29.95;
}
else if(subTot > 299.99)
{
shCharge = subTot * .10;
}
}
else if(shippingType.Equals("Next Day"))
{
if(subTot <= 29.99 && subTot > 0)
{
shCharge = 24.95;
}
else if(subTot <= 99.99 && subTot > 29.99)
{
shCharge = 34.95;
}
else if(subTot <= 299.99 && subTot > 99.99)
{
shCharge = 44.95;
}
else if(subTot > 299.99)
{
shCharge = subTot * .15;
}
}
else if(shippingType.Equals("Next Day a.m."))
{
if(subTot <= 29.99 && subTot > 0)
{
shCharge = 29.95;
}
else if(subTot <= 99.99 && subTot > 29.99)
{
shCharge = 39.95;
}
else if(subTot <= 299.99 && subTot > 99.99)
{
shCharge = 49.95;
}
else if(subTot > 299.99)
{
shCharge = subTot * .20;
}
}
return shCharge;
}
Next you're going to tell me that passing the shipping types around as stringly typed data instead of enums is a mistake, too!
