Skip to content

Implemented getReminder() and calculateTotalPrice() - #151

Open
ddryzhov wants to merge 2 commits into
mate-academy:mainfrom
ddryzhov:total-transformation
Open

Implemented getReminder() and calculateTotalPrice()#151
ddryzhov wants to merge 2 commits into
mate-academy:mainfrom
ddryzhov:total-transformation

Conversation

@ddryzhov

Copy link
Copy Markdown

No description provided.

Copilot AI review requested due to automatic review settings April 20, 2026 12:16

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some actions are not successful, please fix it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements the previously stubbed Kotlin utility functions for computing a total price with a default unit price and for transforming a numeric string into a remainder value.

Changes:

  • Implement calculateTotalPrice() to apply a default unit price when pricePerProduct is null and multiply by count.
  • Implement getReminder() to parse an optional numeric string and compute (n * 3 + 10) % 11.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/main/kotlin/mate/academy/TotalPrice.kt Adds default-price handling and computes total price.
src/main/kotlin/mate/academy/NumberTransformation.kt Adds parsing and transformation logic for the remainder calculation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


fun getReminder(numberStr: String?) : Int? {
return null
return numberStr?.toIntOrNull()?.let { number -> (number * 3 + 10) % 11 }

Copilot AI Apr 20, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The arithmetic (number * 3 + 10) is performed in Int and can overflow for large (but still valid) Int inputs, producing an incorrect remainder. Consider doing the computation in Long (or using exact math) before applying % 11 and returning the Int result.

Suggested change
return numberStr?.toIntOrNull()?.let { number -> (number * 3 + 10) % 11 }
return numberStr?.toIntOrNull()?.let { number -> ((number.toLong() * 3 + 10) % 11).toInt() }

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants