Skip to content

Commit

Permalink
Simplifed conversion (lb/kg) to only use the singular
Browse files Browse the repository at this point in the history
  • Loading branch information
frossm committed Aug 31, 2024
1 parent 1a5db95 commit 8ec1da0
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 26 deletions.
8 changes: 4 additions & 4 deletions mdbook/src/Chapters/Conversions.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if `frac 5` would have been entered (which means 1/5 is maximum granularity), yo
| ft2in | Converts the value in `line1` from feet to inches |
| deg2rad | Convert `line1` from degrees into [radians](https://en.wikipedia.org/wiki/Radian) |
| rad2deg | Convert `line1` from radians into degrees |
| gram2oz<br>grams2oz | Convert `line1` from grams into ounces using the constant of 0.035274 ounces / gram |
| oz2gram<br>oz2grams | Convert `line1` from ounces into grams using the constant of 28.349523125 grams / ounce |
| kg2lbs<br>kgs2lbs | convert `line1` from kilograms to US pounds using the constant of 2.2046226218 lbs/kg |
| lbs2kg<br>lbs2kgs | convert `line1` from US pounds using the constant of 0.45359237 kg/lbs |
| gram2oz | Convert `line1` from grams into ounces using the constant of 0.035274 ounces / gram |
| oz2gram | Convert `line1` from ounces into grams using the constant of 28.349523125 grams / ounce |
| kg2lb | convert `line1` from kilograms to US pounds using the constant of 2.2046226218 lbs/kg |
| lb2kg | convert `line1` from US pounds using the constant of 0.45359237 kg/lbs |
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>org.fross</groupId>
<artifactId>rpncalc</artifactId>
<version>5.3.1</version>
<version>5.3.2</version>
<packaging>jar</packaging>

<name>rpncalc</name>
Expand Down
2 changes: 1 addition & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: rpncalc
version: '5.3.1'
version: '5.3.2'
summary: The command line Reverse Polish Notation (RPN) calculator
description: |
RPNCalc is an easy to use command line based Reverse Polish
Expand Down
12 changes: 4 additions & 8 deletions src/main/java/org/fross/rpncalc/CommandParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -252,26 +252,22 @@ public static void Parse(StackObj calcStack, StackObj calcStack2, String cmdInpu

// Convert grams to ounces
case "gram2oz":
case "grams2oz":
StackConversions.cmdGram2Oz(calcStack);
break;

// Convert ounces to grams
case "oz2gram":
case "oz2grams":
StackConversions.cmdOz2Gram(calcStack);
break;

// Convert Kilograms to US Pounds
case "kg2lbs":
case "kgs2lbs":
StackConversions.cmdKg2Lbs(calcStack);
case "kg2lb":
StackConversions.cmdKg2Lb(calcStack);
break;

// Convert US Pounds to Kilograms
case "lbs2kg":
case "lbs2kgs":
StackConversions.cmdLbs2Kg(calcStack);
case "lb2kg":
StackConversions.cmdLb2Kg(calcStack);
break;

/*------------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/fross/rpncalc/Help.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ public static void Display() {
Output.printColorln(Ansi.Color.WHITE, " ft2in Convert line1 from feet to inches");
Output.printColorln(Ansi.Color.WHITE, " gram2oz Convert line1 from grams to US ounces");
Output.printColorln(Ansi.Color.WHITE, " oz2gram Convert line1 from US ounces to grams");
Output.printColorln(Ansi.Color.WHITE, " kg2lbs Convert line1 from kilograms to US pounds");
Output.printColorln(Ansi.Color.WHITE, " lbs2kg Convert line1 from US pounds to kilograms");
Output.printColorln(Ansi.Color.WHITE, " kg2lb Convert line1 from kilograms to US pounds");
Output.printColorln(Ansi.Color.WHITE, " lb2kg Convert line1 from US pounds to kilograms");

Output.printColorln(Ansi.Color.YELLOW, "\nTrigonometry Functions:");
Output.printColorln(Ansi.Color.WHITE, " sin|cos|tan [rad] Trig Functions: Angle is in degrees unless rad is provided");
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/fross/rpncalc/StackConversions.java
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public static void cmdOz2Gram(StackObj calcStack) {
*
* @param calcStack Primary Stack
*/
public static void cmdKg2Lbs(StackObj calcStack) {
public static void cmdKg2Lb(StackObj calcStack) {
// Ensure we have something on the stack
if (calcStack.isEmpty()) {
Output.printColorln(Ansi.Color.RED, "ERROR: There are no items on the stack.");
Expand All @@ -340,7 +340,7 @@ public static void cmdKg2Lbs(StackObj calcStack) {
*
* @param calcStack Primary Stack
*/
public static void cmdLbs2Kg(StackObj calcStack) {
public static void cmdLb2Kg(StackObj calcStack) {
// Ensure we have something on the stack
if (calcStack.isEmpty()) {
Output.printColorln(Ansi.Color.RED, "ERROR: There are no items on the stack.");
Expand Down
16 changes: 8 additions & 8 deletions src/test/java/org/fross/rpncalc/StackConversionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -455,21 +455,21 @@ void testOz2Gram() {
* Test Kilograms to US pounds conversion
*/
@Test
void testKg2Lbs() {
void testKg2Lb() {
StackObj stk = new StackObj();

stk.push(123.321);
StackConversions.cmdKg2Lbs(stk);
StackConversions.cmdKg2Lb(stk);
StackCommands.cmdRound(stk, "5");
assertEquals(271.87627, stk.pop().doubleValue());

stk.push(-0.369);
StackConversions.cmdKg2Lbs(stk);
StackConversions.cmdKg2Lb(stk);
StackCommands.cmdRound(stk, "5");
assertEquals(-0.81351, stk.pop().doubleValue());

stk.push(4.321e18);
StackConversions.cmdKg2Lbs(stk);
StackConversions.cmdKg2Lb(stk);
StackCommands.cmdRound(stk, "2");
assertEquals("9526174348797800000.00", stk.pop().toEngineeringString());

Expand All @@ -479,21 +479,21 @@ void testKg2Lbs() {
* Test US Pounds to Kilograms conversion
*/
@Test
void testLbs2Kg() {
void testLb2Kg() {
StackObj stk = new StackObj();

stk.push(456.654);
StackConversions.cmdLbs2Kg(stk);
StackConversions.cmdLb2Kg(stk);
StackCommands.cmdRound(stk, "5");
assertEquals(207.13477, stk.pop().doubleValue());

stk.push(-0.987654);
StackConversions.cmdLbs2Kg(stk);
StackConversions.cmdLb2Kg(stk);
StackCommands.cmdRound(stk, "5");
assertEquals(-0.44799, stk.pop().doubleValue());

stk.push(4.321e18);
StackConversions.cmdLbs2Kg(stk);
StackConversions.cmdLb2Kg(stk);
StackCommands.cmdRound(stk, "2");
assertEquals("1959972630770000000.00", stk.pop().toEngineeringString());
}
Expand Down

0 comments on commit 8ec1da0

Please sign in to comment.