added uebung07 angabe

This commit is contained in:
2025-05-23 20:54:12 +02:00
parent 6efe637f23
commit 8942229d87
19 changed files with 733 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
package quantities.plain;
public abstract class Quantity {
public final double value;
public final Unit unit;
protected Quantity(double value, Unit unit) {
this.value = value;
this.unit = unit;
}
public double getBaseValue() {
return value * unit.baseFactor;
}
public double value(Unit unit) {
return getBaseValue() / unit.baseFactor;
}
@Override
public String toString() {
return value + " " + unit;
}
public String format(String fmt, Unit unit) {
return String.format(fmt, value(unit), unit);
}
}