diff --git a/bin/uebung07/quantities/plain/Length.class b/bin/uebung07/quantities/plain/Length.class index d013456..028c707 100644 Binary files a/bin/uebung07/quantities/plain/Length.class and b/bin/uebung07/quantities/plain/Length.class differ diff --git a/bin/uebung07/quantities/plain/LengthUnit.class b/bin/uebung07/quantities/plain/LengthUnit.class index 7d5f60f..f51a92f 100644 Binary files a/bin/uebung07/quantities/plain/LengthUnit.class and b/bin/uebung07/quantities/plain/LengthUnit.class differ diff --git a/bin/uebung07/quantities/plain/PlainQuantitiesDemo.class b/bin/uebung07/quantities/plain/PlainQuantitiesDemo.class index 3df06d1..df63b4d 100644 Binary files a/bin/uebung07/quantities/plain/PlainQuantitiesDemo.class and b/bin/uebung07/quantities/plain/PlainQuantitiesDemo.class differ diff --git a/bin/uebung07/quantities/plain/Time.class b/bin/uebung07/quantities/plain/Time.class new file mode 100644 index 0000000..f266978 Binary files /dev/null and b/bin/uebung07/quantities/plain/Time.class differ diff --git a/bin/uebung07/quantities/plain/TimeUnit.class b/bin/uebung07/quantities/plain/TimeUnit.class new file mode 100644 index 0000000..abc9576 Binary files /dev/null and b/bin/uebung07/quantities/plain/TimeUnit.class differ diff --git a/src/uebung07/quantities/plain/Length.java b/src/uebung07/quantities/plain/Length.java index b8a2b23..5efacf3 100644 --- a/src/uebung07/quantities/plain/Length.java +++ b/src/uebung07/quantities/plain/Length.java @@ -1,8 +1,8 @@ -package quantities.plain; +package uebung07.quantities.plain; -import static quantities.plain.LengthUnit.METER; -import static quantities.plain.TimeUnit.SECOND; -import static quantities.plain.VelocityUnit.METER_PER_SECOND; +import static uebung07.quantities.plain.LengthUnit.METER; +import static uebung07.quantities.plain.TimeUnit.SECOND; +import static uebung07.quantities.plain.VelocityUnit.METER_PER_SECOND; public class Length extends Quantity { private final LengthUnit unit; diff --git a/src/uebung07/quantities/plain/LengthUnit.java b/src/uebung07/quantities/plain/LengthUnit.java index c5a8e04..c98102b 100644 --- a/src/uebung07/quantities/plain/LengthUnit.java +++ b/src/uebung07/quantities/plain/LengthUnit.java @@ -1,4 +1,4 @@ -package quantities.plain; +package uebung07.quantities.plain; public class LengthUnit extends Unit { public LengthUnit(String name, double baseFactor) { diff --git a/src/uebung07/quantities/plain/Time.java b/src/uebung07/quantities/plain/Time.java new file mode 100644 index 0000000..99c2044 --- /dev/null +++ b/src/uebung07/quantities/plain/Time.java @@ -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); + } + +} diff --git a/src/uebung07/quantities/plain/TimeUnit.java b/src/uebung07/quantities/plain/TimeUnit.java new file mode 100644 index 0000000..9e4523b --- /dev/null +++ b/src/uebung07/quantities/plain/TimeUnit.java @@ -0,0 +1,5 @@ +package uebung07.quantities.plain; + +public class TimeUnit extends Unit{ + +}