Integers
You learned in Chapter 2 that an integer is a number that does not have a decimal point – a whole number – and is represented in Kotlin with the Int type. Int is good for representing a quantity or count of “things”: the remaining pints of mead, the number of tavern patrons, or the count of gold and silver coins a player possesses.
Time to do some coding. Open Tavern.kt and add Int variables to represent the current gold and silver in the player’s purse. Uncomment the call to placeOrder to pass the menu data for an order of Dragon’s Breath and remove your order of a Shirley’s Temple.
Also, add a placeholder performPurchase function that will handle the logic for making a purchase and a function to display the player’s ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access