Package io.github.srcimon.screwbox.core
Class Percent
java.lang.Object
io.github.srcimon.screwbox.core.Percent
- All Implemented Interfaces:
Serializable
A percent value between 0.0 and 1.0.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionadd
(double value) Returns a new instance with the sum of both values.boolean
static Percent
half()
Returns 50 percent.int
hashCode()
invert()
Returns the inverted value of the percentage.boolean
isMax()
Returnstrue
if value is 1.0.boolean
isZero()
Returnstrue
if value is 0.static Percent
max()
Returns 100 percent.multiply
(double value) Returns a new instance with the current value multiplied with the given value.static Percent
of
(double value) Returns a new instance with the given values.static Percent
quater()
Returns 25 percent.substract
(double value) Returns a new instance with the current value minus the given value.static Percent
Returns 75 percent.toString()
double
value()
Returns the represented value betweeen 0.0 and 1.0.static Percent
zero()
Returns 0 percent.
-
Method Details
-
of
-
quater
Returns 25 percent. -
half
Returns 50 percent. -
threeQuarter
Returns 75 percent. -
zero
Returns 0 percent. -
max
Returns 100 percent. -
value
public double value()Returns the represented value betweeen 0.0 and 1.0. -
isZero
public boolean isZero()Returnstrue
if value is 0. -
isMax
public boolean isMax()Returnstrue
if value is 1.0. -
toString
-
hashCode
public int hashCode() -
equals
-
invert
Returns the inverted value of the percentage. -
add
Returns a new instance with the sum of both values. Returnsmax()
when the sum is above 100 percent. -
substract
Returns a new instance with the current value minus the given value. Returnszero()
when the sum is below 0 percent. -
multiply
Returns a new instance with the current value multiplied with the given value.
-