Created
February 27, 2022 17:49
-
-
Save adriatikgashi/1a373a1cf0e5605a984f4cf456de34b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Order { | |
let lineItems: [String] | |
let shipping: String | |
func getShippingCost() -> Double { | |
if shipping == "ground" { | |
if getTotal() > 100 { | |
return 0 | |
} | |
// $1.5 per kilogram, but $10 minimum | |
return max(10, getTotalWeight() * 1.5) | |
} | |
if shipping == "air" { | |
return max(20, getTotalWeight() * 3) | |
} | |
return 0.0 | |
} | |
func getTotal() -> Double { | |
// calculate the total | |
return 0.0 | |
} | |
func getTotalWeight() -> Double { | |
// calculate the total weight | |
return 0.0 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment