diff --git a/src/org/parts3492/partslib/PARTsUnit.java b/src/org/parts3492/partslib/PARTsUnit.java index d985ea1..9387e69 100644 --- a/src/org/parts3492/partslib/PARTsUnit.java +++ b/src/org/parts3492/partslib/PARTsUnit.java @@ -76,9 +76,14 @@ public double to(PARTsUnitType unitType) { String message = "No to type for unit."; switch (this.unitType) { case Angle: - if (unitType == PARTsUnitType.Radian) return this.value * Math.PI / 180.0; - else if (unitType == this.unitType) return this.value; - throw new RuntimeException(message); + switch (unitType) { + case Radian: + return this.value * Math.PI / 180.0; + case Angle: + return this.value; + default: + throw new RuntimeException(message); + } case Radian: if (unitType == PARTsUnitType.Angle) return this.value * 180.0 / Math.PI; else if (unitType == this.unitType) return this.value; @@ -120,16 +125,25 @@ public double to(PARTsUnitType unitType) { switch (unitType) { case Angle: return this.value * 360; + case Rotations: + return this.value; default: throw new RuntimeException(message); } case Percent: - throw new RuntimeException( - message + " Percent cannot not be translated to any other type."); + switch (unitType) { + case Percent: + return this.value; + default: + throw new RuntimeException( + message + " Percent cannot not be translated to any other type."); + } case Pound: switch (unitType) { case Kilogram: return this.value * 0.453592; + case Pound: + return this.value; default: throw new RuntimeException(message); } @@ -137,6 +151,8 @@ public double to(PARTsUnitType unitType) { switch (unitType) { case Pound: return this.value * 2.2046226218; + case Kilogram: + return this.value; default: throw new RuntimeException(message); }