How many cakes?

Report a typo

You are provided with a function getCakesBought that takes in an argument x representing the number of cakes bought by a user. The function returns a string to inform the user of the number of cakes bought.

Given the plurals resource below, finish implementing the function so that it returns an appropriate string from the resource.

<plurals name="cakes">
    <item quantity="one">You have bought %d cake</item>
    <item quantity="other">You have bought %d cakes</item>
</plurals>

You have access to the Resources instance through resources.

Sample Input 1:

1

Sample Output 1:

You bought 1 cake
Write a program in Kotlin
fun getCakesBought(x: Int): String {
// Write your code here!

}
___

Create a free account to access the full topic