Created
October 19, 2023 14:51
-
-
Save alexaleluia12/b6dbe370ca43fdee1c32a47964621cad to your computer and use it in GitHub Desktop.
Google PlayGround
This file contains hidden or 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
fun main() { | |
val winningBid = Bid(5000, "Private Collector") | |
println("Item A is sold at ${auctionPrice(winningBid, 2000)}.") | |
println("Item B is sold at ${auctionPrice(null, 3000)}.") | |
} | |
class Bid(val amount: Int, val bidder: String) | |
fun auctionPrice(bid: Bid?, minimumPrice: Int): Int { | |
return bid?.amount ?: minimumPrice | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment