i dont like it
This commit is contained in:
41
src/uebung07/quantities/plain/Time.java
Normal file
41
src/uebung07/quantities/plain/Time.java
Normal 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);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user