com.nohrd.bike.Resistance.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of domain Show documentation
Show all versions of domain Show documentation
A library for reading data from a NOHrD Bike
The newest version!
package com.nohrd.bike
/**
* Denotes the resistance level applied to the bike.
*
* @param value A value in (0f, 1f), where 0f denotes the
* lowest resistance, and 1f the highest resistance value.
*/
public class Resistance private constructor(public val value: Float) {
public companion object {
public fun from(fraction: Float): Resistance {
return Resistance(fraction.coerceIn(0f, 1f))
}
}
override fun toString(): String {
return "Resistance(value=$value)"
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as Resistance
if (value != other.value) return false
return true
}
override fun hashCode(): Int {
return value.hashCode()
}
}