Skip to content

Instantly share code, notes, and snippets.

@alexaleluia12
Created October 19, 2023 14:51
Show Gist options
  • Save alexaleluia12/b6dbe370ca43fdee1c32a47964621cad to your computer and use it in GitHub Desktop.
Save alexaleluia12/b6dbe370ca43fdee1c32a47964621cad to your computer and use it in GitHub Desktop.
Google PlayGround
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