i dont like it
This commit is contained in:
parent
38287f8c0b
commit
41743095bd
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
bin/uebung07/quantities/plain/Time.class
Normal file
BIN
bin/uebung07/quantities/plain/Time.class
Normal file
Binary file not shown.
BIN
bin/uebung07/quantities/plain/TimeUnit.class
Normal file
BIN
bin/uebung07/quantities/plain/TimeUnit.class
Normal file
Binary file not shown.
@ -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;
|
||||||
|
@ -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) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
5
src/uebung07/quantities/plain/TimeUnit.java
Normal file
5
src/uebung07/quantities/plain/TimeUnit.java
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package uebung07.quantities.plain;
|
||||||
|
|
||||||
|
public class TimeUnit extends Unit{
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user