From 26291e672b0e683edc9d57710a9a9d96ca199c45 Mon Sep 17 00:00:00 2001 From: Adrien Hopkins Date: Sun, 24 Mar 2024 13:14:11 -0500 Subject: Format source code & set explicit UTF-8 --- src/main/java/sevenUnits/unit/MultiUnit.java | 30 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src/main/java/sevenUnits/unit/MultiUnit.java') diff --git a/src/main/java/sevenUnits/unit/MultiUnit.java b/src/main/java/sevenUnits/unit/MultiUnit.java index bc240e3..950c547 100644 --- a/src/main/java/sevenUnits/unit/MultiUnit.java +++ b/src/main/java/sevenUnits/unit/MultiUnit.java @@ -39,7 +39,7 @@ public final class MultiUnit extends Unitlike> { public static final MultiUnit of(LinearUnit... units) { return of(Arrays.asList(units)); } - + /** * Creates a {@code MultiUnit} from its units. It will not have a name or * symbol. @@ -57,12 +57,12 @@ public final class MultiUnit extends Unitlike> { } return new MultiUnit(new ArrayList<>(units), unitBase, NameSymbol.EMPTY); } - + /** * The units that make up this value. */ private final List units; - + /** * Creates a {@code MultiUnit}. * @@ -73,24 +73,24 @@ public final class MultiUnit extends Unitlike> { super(unitBase, ns); this.units = units; } - + @Override protected List convertFromBase(double value) { final List values = new ArrayList<>(this.units.size()); double temp = value; - + for (final LinearUnit unit : this.units.subList(0, this.units.size() - 1)) { values.add(Math.floor(temp / unit.getConversionFactor())); temp %= unit.getConversionFactor(); } - + values.add(this.units.size() - 1, this.units.get(this.units.size() - 1).convertFromBase(temp)); - + return values; } - + /** * Converts a value expressed in this unitlike form to a value expressed in * {@code other}. @@ -99,7 +99,7 @@ public final class MultiUnit extends Unitlike> { * {@code other.convertFromBase(this.convertToBase(value))}. * Therefore, overriding either of those methods will change the * output of this method. - * + * * @param other unit to convert to * @param value value to convert * @return converted value @@ -115,10 +115,10 @@ public final class MultiUnit extends Unitlike> { for (final double d : values) { valueList.add(d); } - + return this.convertTo(other, valueList); } - + /** * Converts a value expressed in this unitlike form to a value expressed in * {@code other}. @@ -127,7 +127,7 @@ public final class MultiUnit extends Unitlike> { * {@code other.convertFromBase(this.convertToBase(value))}. * Therefore, overriding either of those methods will change the * output of this method. - * + * * @param other unit to convert to * @param value value to convert * @return converted value @@ -142,16 +142,16 @@ public final class MultiUnit extends Unitlike> { for (final double d : values) { valueList.add(d); } - + return this.convertTo(other, valueList); } - + @Override protected double convertToBase(List value) { if (value.size() != this.units.size()) throw new IllegalArgumentException("Wrong number of values for " + this.units.size() + "-unit MultiUnit."); - + double baseValue = 0; for (int i = 0; i < this.units.size(); i++) { baseValue += value.get(i) * this.units.get(i).getConversionFactor(); -- cgit v1.2.3