package com.example.watch.ui.activity

import java.text.DecimalFormat

class BaseData {
    val heigh = 146
    val sex = 1
    val age = 4
    val weight = 21
    val head = "123.jpg"
    val peaceHr = 70

    //  运动强度计算
    public fun calcActivity(Hr: Int, Sex: Int, Weight: Int, Age: Int, T: Int): String {
        var calc: Double
        if (Sex == 1) {
            calc =
                (((-55.0969 + (0.6309 * Hr) + (0.1988 * Weight) + (0.2017 * Age)) / 4.184) * 60 * T)
        } else {
            calc =
                (((-20.4022 + (0.4472 * Hr) + (0.1263 * Weight) + (0.074 * Age)) / 4.184) * 60 * T)
        }
//        强度最大100
        calc = if (calc >= 100.0) 100.0 else calc
        calc = if (calc <= 0.0) 0.0 else calc
        println(calc)
        val res = calc.toInt().toString()
        return res
    }

    //    todo 计算运动消耗
    public fun calcSportCalc(Hr: Int, Sex: Int, Weight: Int, Age: Int, T: Int): String {
        var res = "0"
        val calc = Hr.toDouble() * 0.98
        if (calc > 1) {
            res = calc.toInt().toString()
        }
        return res
    }

    //    todo 计算全部消耗
    public fun calcSumCalc(calorie: Int): String {
        var res = "0"
        val calc = calorie / weight
        val df = DecimalFormat("######0.00")
        if (calc > 1) {
            res = calc.toInt().toString()
        } else {
            res = df.format(calc.toDouble())
        }
        return res
    }

    //    todo 计算CK
    public fun calcCk(Hr: Int): String {
//        卡路里除以体重
        var res = "0"
        val calc = Hr.toDouble() / weight
        if (calc > 1) {
            res = calc.toInt().toString()
        }
        return res
    }
}