i dont like it

This commit is contained in:
2024-06-06 17:41:33 +02:00
parent 38287f8c0b
commit 41743095bd
9 changed files with 51 additions and 5 deletions

View File

@@ -0,0 +1,41 @@
package uebung07.quantities.plain;
import static uebung07.quantities.plain.LengthUnit.METER;
public class Time extends Quantity{
private final TimeUnit unit;
public Time(double value, TimeUnit unit) {
super(value, unit);
this.unit = unit;
}
public Time plus(Time other) {
return new Time( value + other.getBaseValue() / unit.baseFactor, unit);
}
public Time minus(Time other) {
return new Time( value - other.getBaseValue() / unit.baseFactor, unit);
}
public Time mult(double f) {
return new Time( value * f, unit);
}
public Time div(double f) {
return new Time( value / f, unit);
}
public Time to(TimeUnit unit) {
return new Time(getBaseValue() / unit.baseFactor, unit)
}
public double div(Time other) {
return getBaseValue() / other.getBaseValue();
}
public Length mult(Velocity v) {
return new Length(this.value(METER), METER);
}
}