i dont like it

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

Binary file not shown.

Binary file not shown.

View File

@ -1,8 +1,8 @@
package quantities.plain; package uebung07.quantities.plain;
import static quantities.plain.LengthUnit.METER; import static uebung07.quantities.plain.LengthUnit.METER;
import static quantities.plain.TimeUnit.SECOND; import static uebung07.quantities.plain.TimeUnit.SECOND;
import static quantities.plain.VelocityUnit.METER_PER_SECOND; import static uebung07.quantities.plain.VelocityUnit.METER_PER_SECOND;
public class Length extends Quantity { public class Length extends Quantity {
private final LengthUnit unit; private final LengthUnit unit;

View File

@ -1,4 +1,4 @@
package quantities.plain; package uebung07.quantities.plain;
public class LengthUnit extends Unit { public class LengthUnit extends Unit {
public LengthUnit(String name, double baseFactor) { public LengthUnit(String name, double baseFactor) {

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);
}
}

View File

@ -0,0 +1,5 @@
package uebung07.quantities.plain;
public class TimeUnit extends Unit{
}