Closed ghost closed 7 months ago
@itsanikethere Thank you for your feedback! We value your suggestions and appreciate you taking the time to reach out. Training apps focus on teaching specific concepts, and their requirements vary based on the course curriculum. To maintain their simplicity for learning purposes, we might not be able to implement changes at this moment. However, your feedback is helpful for future development.
@android-dev-lxl Thank you for the reply. The reason I raised this issue was because in the codelab starter app code, the feature of default tip percentage already exists, and during the codelab, the goal is to add one more feature of custom percentage for tip calculation. However, in the final output code, the already existing feature was broken. But do what you feel is correct I am still new to android and you better understand the repository.
Yes you are correct, this is done on purpose, we are trying to change the hardcoded tip percentage to custom value entered by the user.
Okay! Thank you for responding.
URL of codelab https://developer.android.com/codelabs/basic-android-kotlin-compose-calculate-tip?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fandroid-basics-compose-unit-2-pathway-3%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fbasic-android-kotlin-compose-calculate-tip#5
In which task and step of the codelab can this issue be found? Task : Calculate Custom Tip Step : 4. Add a tip-percentage text field
Describe the problem The default value assigned to tipPercent parameter is never used. Due to which user is bound to enter tip percentage:
Fix 1) Don't pass argument to calculateTip method if tipPercent is 0.0 (Also created pull request for this https://github.com/google-developer-training/basic-android-kotlin-compose-training-tip-calculator/pull/192) Replace
val tip = calculateTip(amount, tipPercent, roundUp)
->Fix 2) Change elvis operator fallback value from 0.0 to 15.0 Replace
val tipPercent = tipInput.toDoubleOrNull() ?: 0.0
->val tipPercent = tipInput.toDoubleOrNull() ?: 15.0
Fix 3) Altogether remove the default value from tipPercent parameter to the avoid confusion.
private fun calculateTip(amount: Double, tipPercent: Double = 15.0, roundUp: Boolean): String
->private fun calculateTip(amount: Double, tipPercent: Double, roundUp: Boolean): String
Steps to reproduce?
Versions Android Studio version: Android Studio Iguana | 2023.2.1 Patch 1 API version of the emulator: 34
Additional information Before:
After: