Skip to content

Commit

Permalink
🔨 Rounding temperature
Browse files Browse the repository at this point in the history
  • Loading branch information
wonseok committed Feb 1, 2025
1 parent ad7dd36 commit c38c37a
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import com.toyProject7.karrot.user.controller.User
import com.toyProject7.karrot.user.service.UserService
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import java.math.BigDecimal
import java.math.RoundingMode

@Service
class MannerService(
Expand Down Expand Up @@ -54,9 +56,15 @@ class MannerService(
}

if (mannerType.name.startsWith("NEG_")) {
userEntity.temperature -= 0.1
userEntity.temperature =
BigDecimal(userEntity.temperature - 0.1)
.setScale(1, RoundingMode.HALF_UP)
.toDouble()
} else {
userEntity.temperature += 0.1
userEntity.temperature =
BigDecimal(userEntity.temperature + 0.1)
.setScale(1, RoundingMode.HALF_UP)
.toDouble()
}

if (userEntity.temperature > 100) {
Expand Down

0 comments on commit c38c37a

Please sign in to comment.