From 41a03f3e59ad08984ada06e7389773b5c4fdd7b2 Mon Sep 17 00:00:00 2001 From: Awsmeworld304 Date: Sat, 31 Jan 2026 14:10:51 -0500 Subject: [PATCH 1/5] Fix PARTsUnit same-type conversion cases. --- src/org/parts3492/partslib/PARTsUnit.java | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/src/org/parts3492/partslib/PARTsUnit.java b/src/org/parts3492/partslib/PARTsUnit.java index d985ea1..7f28581 100644 --- a/src/org/parts3492/partslib/PARTsUnit.java +++ b/src/org/parts3492/partslib/PARTsUnit.java @@ -18,9 +18,7 @@ public enum PARTsUnitType { Foot, Percent, Rotations, - MetersPerSecond, - Pound, - Kilogram + MetersPerSecond } private double value; @@ -126,20 +124,6 @@ public double to(PARTsUnitType unitType) { case Percent: throw new RuntimeException( message + " Percent cannot not be translated to any other type."); - case Pound: - switch (unitType) { - case Kilogram: - return this.value * 0.453592; - default: - throw new RuntimeException(message); - } - case Kilogram: - switch (unitType) { - case Pound: - return this.value * 2.2046226218; - default: - throw new RuntimeException(message); - } default: throw new RuntimeException(message); } From e6c0c1054e030222658f47f2e2693189d293666e Mon Sep 17 00:00:00 2001 From: James Date: Sun, 25 Jan 2026 13:25:16 -0500 Subject: [PATCH 2/5] Add kg and lbs to PARTsUnit --- src/org/parts3492/partslib/PARTsUnit.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/org/parts3492/partslib/PARTsUnit.java b/src/org/parts3492/partslib/PARTsUnit.java index 7f28581..d985ea1 100644 --- a/src/org/parts3492/partslib/PARTsUnit.java +++ b/src/org/parts3492/partslib/PARTsUnit.java @@ -18,7 +18,9 @@ public enum PARTsUnitType { Foot, Percent, Rotations, - MetersPerSecond + MetersPerSecond, + Pound, + Kilogram } private double value; @@ -124,6 +126,20 @@ public double to(PARTsUnitType unitType) { case Percent: throw new RuntimeException( message + " Percent cannot not be translated to any other type."); + case Pound: + switch (unitType) { + case Kilogram: + return this.value * 0.453592; + default: + throw new RuntimeException(message); + } + case Kilogram: + switch (unitType) { + case Pound: + return this.value * 2.2046226218; + default: + throw new RuntimeException(message); + } default: throw new RuntimeException(message); } From 94aab50593693e25b9f69e98fe1227cab4cde8dc Mon Sep 17 00:00:00 2001 From: Awsmeworld304 Date: Sat, 31 Jan 2026 14:18:45 -0500 Subject: [PATCH 3/5] Fix same-type conversions for different cases. --- src/org/parts3492/partslib/PARTsUnit.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/org/parts3492/partslib/PARTsUnit.java b/src/org/parts3492/partslib/PARTsUnit.java index d985ea1..571fe02 100644 --- a/src/org/parts3492/partslib/PARTsUnit.java +++ b/src/org/parts3492/partslib/PARTsUnit.java @@ -120,16 +120,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 +146,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); } From 236884a05d0e5e72c180c4df60fb34215b6bb9af Mon Sep 17 00:00:00 2001 From: Awsmeworld304 Date: Sat, 31 Jan 2026 14:21:29 -0500 Subject: [PATCH 4/5] Refactor angle conversions to use cases instead of if statements. --- src/org/parts3492/partslib/PARTsUnit.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/org/parts3492/partslib/PARTsUnit.java b/src/org/parts3492/partslib/PARTsUnit.java index 571fe02..ed556c3 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; From 94d153b6f12e94da0be944c5cbc027a57a6e7570 Mon Sep 17 00:00:00 2001 From: Awsmeworld304 Date: Sat, 31 Jan 2026 14:22:45 -0500 Subject: [PATCH 5/5] Fix formatting for PARTsUnit. --- src/org/parts3492/partslib/PARTsUnit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/parts3492/partslib/PARTsUnit.java b/src/org/parts3492/partslib/PARTsUnit.java index ed556c3..9387e69 100644 --- a/src/org/parts3492/partslib/PARTsUnit.java +++ b/src/org/parts3492/partslib/PARTsUnit.java @@ -136,7 +136,7 @@ public double to(PARTsUnitType unitType) { return this.value; default: throw new RuntimeException( - message + " Percent cannot not be translated to any other type."); + message + " Percent cannot not be translated to any other type."); } case Pound: switch (unitType) {