diff --git a/build.gradle.kts b/build.gradle.kts index 08780a4..cb2df04 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -20,7 +20,7 @@ tasks.test { } kotlin { - jvmToolchain(11) + jvmToolchain(17) } detekt { diff --git a/src/main/kotlin/mate/academy/NumberTransformation.kt b/src/main/kotlin/mate/academy/NumberTransformation.kt index 27818c6..d22e56e 100644 --- a/src/main/kotlin/mate/academy/NumberTransformation.kt +++ b/src/main/kotlin/mate/academy/NumberTransformation.kt @@ -6,6 +6,13 @@ package mate.academy If the number is not present return null */ -fun getReminder(numberStr: String?) : Int? { - return null +private const val MULTIPLIER = 3 +private const val ADDITION_VALUE = 10 +private const val DIVISOR = 11 + +fun getReminder(numberStr: String?): Int? { + return numberStr?.toInt() + ?.times(MULTIPLIER) + ?.plus(ADDITION_VALUE) + ?.rem(DIVISOR) } diff --git a/src/main/kotlin/mate/academy/TotalPrice.kt b/src/main/kotlin/mate/academy/TotalPrice.kt index d114745..5b7c1f9 100644 --- a/src/main/kotlin/mate/academy/TotalPrice.kt +++ b/src/main/kotlin/mate/academy/TotalPrice.kt @@ -1,9 +1,12 @@ package mate.academy +private const val DEFAULT_PRICE_PER_PRODUCT = 29.99 + /* Calculate the products total price based on the provide price per product and products amount. If the price is not provided, use default price per product equal to 29.99 */ -fun calculateTotalPrice(pricePerProduct: Double?, count: Int) : Double { - return 0.0 +fun calculateTotalPrice(pricePerProduct: Double?, count: Int): Double { + val price = pricePerProduct ?: DEFAULT_PRICE_PER_PRODUCT + return price * count }