Compare commits

...

13 Commits

Author SHA1 Message Date
5f15f03d92 small change 2024-09-14 17:41:40 +00:00
9908656813 finished uebung10 2024-06-18 13:17:01 +00:00
b439030fee Ich hasse Minas 2024-06-18 12:55:21 +00:00
7fea13b9b3 MINAS??? 2024-06-17 22:33:20 +02:00
639da57def MINAS 2024-06-17 22:33:01 +02:00
0c95c28bc4 testing 2024-06-15 23:30:02 +02:00
ac1cc19a88 finished uebung09 2024-06-15 16:20:39 +02:00
62da4a9ea5 ahhhhhhhhh 2024-06-14 12:01:59 +02:00
dad5a33695 implemented hasnext 2024-06-14 08:08:10 +00:00
93fb940a8c refactor 2024-06-14 01:13:30 +02:00
55e6561e02 ich komm nicht mehr weiter 2024-06-14 01:12:27 +02:00
7972c9088c refactor 2024-06-14 01:03:45 +02:00
e59cbb88f1 refactored testing 2024-06-14 00:33:41 +02:00
131 changed files with 812 additions and 5151 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
bin/uebung10/logo/Go.class Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,13 +1,18 @@
package logistics; package test.uebung.uebung05.logistics;
import uebung05.logistics.Helicopter;
import uebung05.logistics.Manager;
import uebung05.logistics.Tank;
import uebung05.logistics.material.BulletBelts;
import uebung05.logistics.material.Grease;
import uebung05.logistics.material.LiterDiesel;
import uebung05.logistics.material.MetGallonsKerosene;
import uebung05.logistics.material.Oil;
import uebung05.logistics.material.RocketPods;
import uebung05.logistics.material.ShellBatches;
import uebung05.logistics.quantities.NeedCollector;
import logistics.material.BulletBelts;
import logistics.material.Grease;
import logistics.material.LiterDiesel;
import logistics.material.MetGallonsKerosene;
import logistics.material.Oil;
import logistics.material.RocketPods;
import logistics.material.ShellBatches;
import logistics.quantities.NeedCollector;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;

View File

@@ -1,6 +1,8 @@
package logistics.storage; package test.uebung.uebung05.logistics.storage;
import uebung05.logistics.material.Oil;
import uebung05.logistics.storage.IntStorage;
import logistics.material.Oil;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;

View File

@@ -0,0 +1,76 @@
package test.uebung.uebung09.collection;
import java.util.Iterator;
import uebung09.collection.Set;
import uebung09.collection.SetFactory;
import java.util.NoSuchElementException;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class SetTest {
static String a = "test";
static String b = "test2";
static String c = "test3";
public static void main(String[] args) {
}
@Test
public void EmptySetTest(){
Set<String> test = SetFactory.create();
Iterator<String> i = test.iterator();
assertFalse(i.hasNext());
assertThrows(NoSuchElementException.class, i::next);
assertFalse(test.contains(a));
assertEquals(0,test.size());
assertTrue(test.isEmpty());
}
@Test
public void SingeltonSetTest(){
Set<String> test = SetFactory.create(a);
Iterator<String> i = test.iterator();
assertTrue(i.hasNext());
assertTrue(a == i.next());
assertFalse(i.hasNext());
assertThrows(NoSuchElementException.class, i::next);
assertTrue(test.contains(a));
assertEquals(1,test.size());
assertFalse(test.isEmpty());
}
@Test
public void BigSetTest() {
Set<String> test = SetFactory.create(a,b,c);
Iterator<String> i = test.iterator();
assertTrue(i.hasNext());
assertTrue(a == i.next());
assertTrue(i.hasNext());
assertTrue(a == i.next());
assertTrue(i.hasNext());
assertTrue(a == i.next());
assertFalse(i.hasNext());
assertThrows(NoSuchElementException.class, i::next);
assertTrue(test.contains(a));
assertEquals(1,test.size());
assertFalse(test.isEmpty());
}
}

View File

@@ -1,9 +1,10 @@
package iterator; package test.uebung.uebung09.iterator;
import org.junit.Test; import org.junit.Test;
import java.util.Iterator; import java.util.Iterator;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import uebung09.iterator.Array2dIterator;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;

View File

@@ -1,10 +1,12 @@
package iterator; package test.uebung.uebung09.iterator;
import org.junit.Test; import org.junit.Test;
import java.util.Iterator; import java.util.Iterator;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import uebung09.iterator.*;
import static java.util.Arrays.asList; import static java.util.Arrays.asList;
import static java.util.Collections.emptyList; import static java.util.Collections.emptyList;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;

View File

@@ -1,20 +1,26 @@
package uebung04; package uebung04;
import java.util.ArrayList;
public class ByeGame extends Game{ public class ByeGame extends Game{
private String player1; private String player1;
private String player2;
public ByeGame(String player1, Game player2){ public ByeGame(String player1, String player2){
this.player1 = player1; this.player1 = player1;
this.player2 = player2; this.player2 = player2;
} }
public String getPlayer1(){return player1;} public String getPlayer1(){return player1;}
public String getPlayer2(){return player2;}
public ??? getPlayer2(){ @Override
return player2.getAllPlayers(); public ArrayList<String> getAllPlayers() {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'getAllPlayers'");
} }

View File

@@ -7,7 +7,7 @@ public class OrdinaryGame extends Game{
private final int id; private final int id;
public OrdinaryGame(Game player1, Game player2){ public OrdinaryGame(String player1, String player2){
this.player1 = player1; this.player1 = player1;
this.player2 = player2; this.player2 = player2;
@@ -15,18 +15,16 @@ public class OrdinaryGame extends Game{
counter++; counter++;
} }
public ArrayList<String> getPlayer1(){ public String getPlayer1(){
return player1.getAllPlayers(); return null;
} }
public ArrayList<String> getPlayer2(){ public String getPlayer2(){
return player2.getAllPlayers(); return null;
} }
public ArrayList<String> getAllPlayers(){ public ArrayList<String> getAllPlayers(){
ArrayList<String> rtn = player1.getAllPlayers(); return null;
rtn.addAll(player2.getAllPlayers());
return rtn;
} }
} }

View File

@@ -1,10 +1,10 @@
package logistics; package uebung05.logistics;
import logistics.material.BulletBelts; import uebung05.logistics.material.BulletBelts;
import logistics.material.LiterDiesel; import uebung05.logistics.material.LiterDiesel;
import logistics.material.RocketPods; import uebung05.logistics.material.RocketPods;
class demo { class Demo {
public static void main(String[] args) { public static void main(String[] args) {
Manager ceo = new Manager(); Manager ceo = new Manager();

View File

@@ -1,13 +1,13 @@
package logistics; package uebung05.logistics;
import logistics.material.BulletBelts; import uebung05.logistics.material.BulletBelts;
import logistics.material.MetGallonsKerosene; import uebung05.logistics.material.MetGallonsKerosene;
import logistics.material.RocketPods; import uebung05.logistics.material.RocketPods;
import logistics.quantities.FloatUnit; import uebung05.logistics.quantities.FloatUnit;
import logistics.quantities.IntUnit; import uebung05.logistics.quantities.IntUnit;
import logistics.quantities.NeedCollector; import uebung05.logistics.quantities.NeedCollector;
import logistics.storage.FloatStorage; import uebung05.logistics.storage.FloatStorage;
import logistics.storage.IntStorage; import uebung05.logistics.storage.IntStorage;
/** /**
* The Helicopter class represents a helicopter in the logistics system. * The Helicopter class represents a helicopter in the logistics system.

View File

@@ -1,9 +1,9 @@
package logistics; package uebung05.logistics;
import logistics.quantities.FloatUnit; import uebung05.logistics.quantities.FloatUnit;
import logistics.quantities.IntUnit; import uebung05.logistics.quantities.IntUnit;
import logistics.quantities.NeedCollector; import uebung05.logistics.quantities.NeedCollector;
import logistics.quantities.Unit; import uebung05.logistics.quantities.Unit;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -63,7 +63,7 @@ public class Manager {
* *
* @return The NeedCollector object containing the needs of all the vehicles * @return The NeedCollector object containing the needs of all the vehicles
*/ */
NeedCollector collectNeeds() { public NeedCollector collectNeeds() {
NeedCollector collector = new NeedCollector(); NeedCollector collector = new NeedCollector();
for (Vehicle vehicle : vehicles) { for (Vehicle vehicle : vehicles) {
vehicle.reportNeeds(collector); vehicle.reportNeeds(collector);

View File

@@ -1,7 +1,7 @@
package logistics; package uebung05.logistics;
import logistics.quantities.FloatUnit; import uebung05.logistics.quantities.FloatUnit;
import logistics.quantities.IntUnit; import uebung05.logistics.quantities.IntUnit;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;

View File

@@ -1,13 +1,13 @@
package logistics; package uebung05.logistics;
import logistics.material.BulletBelts; import uebung05.logistics.material.BulletBelts;
import logistics.material.LiterDiesel; import uebung05.logistics.material.LiterDiesel;
import logistics.material.ShellBatches; import uebung05.logistics.material.ShellBatches;
import logistics.quantities.FloatUnit; import uebung05.logistics.quantities.FloatUnit;
import logistics.quantities.IntUnit; import uebung05.logistics.quantities.IntUnit;
import logistics.quantities.NeedCollector; import uebung05.logistics.quantities.NeedCollector;
import logistics.storage.FloatStorage; import uebung05.logistics.storage.FloatStorage;
import logistics.storage.IntStorage; import uebung05.logistics.storage.IntStorage;
/** /**
* The Tank class represents a tank in the logistics system. * The Tank class represents a tank in the logistics system.

View File

@@ -1,12 +1,12 @@
package logistics; package uebung05.logistics;
import logistics.material.BulletBelts; import uebung05.logistics.material.BulletBelts;
import logistics.material.LiterDiesel; import uebung05.logistics.material.LiterDiesel;
import logistics.quantities.FloatUnit; import uebung05.logistics.quantities.FloatUnit;
import logistics.quantities.IntUnit; import uebung05.logistics.quantities.IntUnit;
import logistics.quantities.NeedCollector; import uebung05.logistics.quantities.NeedCollector;
import logistics.storage.FloatStorage; import uebung05.logistics.storage.FloatStorage;
import logistics.storage.IntStorage; import uebung05.logistics.storage.IntStorage;
/** /**
* The Truck class represents a truck in the logistics system. * The Truck class represents a truck in the logistics system.

View File

@@ -1,11 +1,11 @@
package logistics; package uebung05.logistics;
import logistics.material.Grease; import uebung05.logistics.material.Grease;
import logistics.material.Oil; import uebung05.logistics.material.Oil;
import logistics.quantities.FloatUnit; import uebung05.logistics.quantities.FloatUnit;
import logistics.quantities.IntUnit; import uebung05.logistics.quantities.IntUnit;
import logistics.quantities.NeedCollector; import uebung05.logistics.quantities.NeedCollector;
import logistics.storage.IntStorage; import uebung05.logistics.storage.IntStorage;
/** /**
* The Vehicle abstract class represents a vehicle in the logistics system. * The Vehicle abstract class represents a vehicle in the logistics system.

View File

@@ -1,6 +1,6 @@
package logistics.material; package uebung05.logistics.material;
import logistics.quantities.IntUnit; import uebung05.logistics.quantities.IntUnit;
/** /**
* The BulletBelts class represents a unit of measurement for 7.62 bullets. * The BulletBelts class represents a unit of measurement for 7.62 bullets.
@@ -11,7 +11,7 @@ import logistics.quantities.IntUnit;
*/ */
public class BulletBelts implements IntUnit { public class BulletBelts implements IntUnit {
private static BulletBelts INSTANCE; public static BulletBelts INSTANCE;
private BulletBelts() {} private BulletBelts() {}

View File

@@ -1,6 +1,6 @@
package logistics.material; package uebung05.logistics.material;
import logistics.quantities.IntUnit; import uebung05.logistics.quantities.IntUnit;
/** /**
* The Grease class represents a unit of measurement for grease. * The Grease class represents a unit of measurement for grease.
@@ -11,7 +11,7 @@ import logistics.quantities.IntUnit;
*/ */
public class Grease implements IntUnit { public class Grease implements IntUnit {
private static Grease INSTANCE; public static Grease INSTANCE;
private Grease() {} private Grease() {}

View File

@@ -1,6 +1,6 @@
package logistics.material; package uebung05.logistics.material;
import logistics.quantities.FloatUnit; import uebung05.logistics.quantities.FloatUnit;
/** /**
* The LiterDiesel class represents a unit of measurement for diesel fuel. * The LiterDiesel class represents a unit of measurement for diesel fuel.
@@ -11,7 +11,7 @@ import logistics.quantities.FloatUnit;
*/ */
public class LiterDiesel implements FloatUnit { public class LiterDiesel implements FloatUnit {
private static LiterDiesel INSTANCE; public static LiterDiesel INSTANCE;
private LiterDiesel() {} private LiterDiesel() {}

View File

@@ -1,6 +1,6 @@
package logistics.material; package uebung05.logistics.material;
import logistics.quantities.FloatUnit; import uebung05.logistics.quantities.FloatUnit;
/** /**
* The MetGallonsKerosene class represents a unit of measurement for kerosene. * The MetGallonsKerosene class represents a unit of measurement for kerosene.
@@ -11,7 +11,7 @@ import logistics.quantities.FloatUnit;
*/ */
public class MetGallonsKerosene implements FloatUnit { public class MetGallonsKerosene implements FloatUnit {
private static MetGallonsKerosene INSTANCE; public static MetGallonsKerosene INSTANCE;
private MetGallonsKerosene() {} private MetGallonsKerosene() {}

View File

@@ -1,6 +1,6 @@
package logistics.material; package uebung05.logistics.material;
import logistics.quantities.IntUnit; import uebung05.logistics.quantities.IntUnit;
/** /**
* The Oil class represents a unit of measurement for oil. * The Oil class represents a unit of measurement for oil.
@@ -11,7 +11,7 @@ import logistics.quantities.IntUnit;
*/ */
public class Oil implements IntUnit { public class Oil implements IntUnit {
private static Oil INSTANCE; public static Oil INSTANCE;
private Oil() {} private Oil() {}

View File

@@ -1,6 +1,6 @@
package logistics.material; package uebung05.logistics.material;
import logistics.quantities.IntUnit; import uebung05.logistics.quantities.IntUnit;
/** /**
* The RocketPods class represents a unit of measurement for 70mm rocket pods. * The RocketPods class represents a unit of measurement for 70mm rocket pods.
@@ -11,7 +11,7 @@ import logistics.quantities.IntUnit;
*/ */
public class RocketPods implements IntUnit { public class RocketPods implements IntUnit {
private static RocketPods INSTANCE; public static RocketPods INSTANCE;
private RocketPods() {} private RocketPods() {}

View File

@@ -1,6 +1,6 @@
package logistics.material; package uebung05.logistics.material;
import logistics.quantities.IntUnit; import uebung05.logistics.quantities.IntUnit;
/** /**
* The ShellBatches class represents a unit of measurement for 120mm shell batches. * The ShellBatches class represents a unit of measurement for 120mm shell batches.
@@ -11,7 +11,7 @@ import logistics.quantities.IntUnit;
*/ */
public class ShellBatches implements IntUnit { public class ShellBatches implements IntUnit {
private static ShellBatches INSTANCE; public static ShellBatches INSTANCE;
private ShellBatches() {} private ShellBatches() {}

View File

@@ -1,4 +1,4 @@
package logistics.quantities; package uebung05.logistics.quantities;
/** /**
* @author Nikolaus Köberlein * @author Nikolaus Köberlein

View File

@@ -1,4 +1,4 @@
package logistics.quantities; package uebung05.logistics.quantities;
/** /**
* @author Nikolaus Köberlein * @author Nikolaus Köberlein

View File

@@ -1,12 +1,12 @@
package logistics.quantities; package uebung05.logistics.quantities;
import logistics.material.BulletBelts; import uebung05.logistics.material.BulletBelts;
import logistics.material.Grease; import uebung05.logistics.material.Grease;
import logistics.material.LiterDiesel; import uebung05.logistics.material.LiterDiesel;
import logistics.material.MetGallonsKerosene; import uebung05.logistics.material.MetGallonsKerosene;
import logistics.material.Oil; import uebung05.logistics.material.Oil;
import logistics.material.RocketPods; import uebung05.logistics.material.RocketPods;
import logistics.material.ShellBatches; import uebung05.logistics.material.ShellBatches;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;

View File

@@ -1,4 +1,4 @@
package logistics.quantities; package uebung05.logistics.quantities;
/** /**
* @author Nikolaus Köberlein * @author Nikolaus Köberlein

View File

@@ -1,7 +1,7 @@
package logistics.storage; package uebung05.logistics.storage;
import logistics.quantities.FloatUnit; import uebung05.logistics.quantities.FloatUnit;
import logistics.quantities.NeedCollector; import uebung05.logistics.quantities.NeedCollector;
/** /**
* The FloatStorage class represents a floating-point storage for a specific FloatUnit object. * The FloatStorage class represents a floating-point storage for a specific FloatUnit object.

View File

@@ -1,7 +1,7 @@
package logistics.storage; package uebung05.logistics.storage;
import logistics.quantities.IntUnit; import uebung05.logistics.quantities.IntUnit;
import logistics.quantities.NeedCollector; import uebung05.logistics.quantities.NeedCollector;
/** /**
* The IntStorage class represents an integer storage for a specific IntUnit object. * The IntStorage class represents an integer storage for a specific IntUnit object.

View File

@@ -1,46 +0,0 @@
package uebung07.quantities.plain;
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;
public Length(double value, LengthUnit unit) {
super(value, unit);
this.unit = unit;
}
public Length plus(Length other) {
return new Length(value + other.getBaseValue() / unit.baseFactor, unit);
}
public Length minus(Length other) {
return new Length(value - other.getBaseValue() / unit.baseFactor, unit);
}
public Length mult(double f) {
return new Length(value * f, unit);
}
public Length div(double f) {
return new Length(value / f, unit);
}
public Length to(LengthUnit unit) {
return new Length(getBaseValue() / unit.baseFactor, unit);
}
public double div(Length other) {
return getBaseValue() / other.getBaseValue();
}
public Velocity div(Time t) {
return new Velocity(this.value(METER) / t.value(SECOND), METER_PER_SECOND);
}
public Time div(Velocity v) {
return new Time(this.value(METER) / v.value(METER_PER_SECOND), SECOND);
}
}

View File

@@ -1,14 +0,0 @@
package uebung07.quantities.plain;
public class LengthUnit extends Unit {
public LengthUnit(String name, double baseFactor) {
super(name, baseFactor);
}
public static final LengthUnit METER = new LengthUnit("m", 1);
public static final LengthUnit MILLIMETER = new LengthUnit("mm", 0.001);
public static final LengthUnit KILOMETER = new LengthUnit("km", 1000);
public static final LengthUnit MILE = new LengthUnit("mi", 1609.344);
public static final LengthUnit LIGHTYEAR = new LengthUnit("ly", 9460730472580800.0);
public static final LengthUnit PARSEC = new LengthUnit("pc", 3.0856776e16);
}

View File

@@ -1,60 +0,0 @@
package uebung07.quantities.plain;
import static uebung07.quantities.plain.LengthUnit.KILOMETER;
import static uebung07.quantities.plain.LengthUnit.MILE;
import static uebung07.quantities.plain.LengthUnit.MILLIMETER;
import static uebung07.quantities.plain.LengthUnit.PARSEC;
import static uebung07.quantities.plain.TimeUnit.HOUR;
import static uebung07.quantities.plain.TimeUnit.MINUTE;
import static uebung07.quantities.plain.TimeUnit.SECOND;
import static uebung07.quantities.plain.VelocityUnit.KMH;
import static uebung07.quantities.plain.VelocityUnit.METER_PER_SECOND;
import static uebung07.quantities.plain.VelocityUnit.MPH;
public class PlainQuantitiesDemo {
public static void main(String[] args) {
final Length l1 = new Length(1, KILOMETER);
final Length l2 = new Length(1200, MILLIMETER);
final Length l3 = new Length(1, MILE);
System.out.println(l1);
System.out.println(l2);
System.out.println(l1 + " + " + l2 + " = " + l1.plus(l2));
System.out.println(l1 + " + " + l2 + " (in mm) = " + l1.plus(l2).to(MILLIMETER));
System.out.println(l3 + " / " + l1 + " = " + l3.div(l1));
final Time t1 = new Time(100, SECOND);
final Time t2 = new Time(5, HOUR);
System.out.println(t1);
System.out.println(t2);
System.out.println(t1.plus(t2));
System.out.println(t1.plus(t2).to(MINUTE));
final Velocity v1 = new Velocity(12, KMH);
final Velocity v2 = new Velocity(100, METER_PER_SECOND);
System.out.println(v1);
System.out.println(v2);
System.out.println(v2.to(KMH));
System.out.println(v1.plus(v2));
final Length l4 = new Length(300, KILOMETER).to(PARSEC);
final Time t3 = new Time(2, HOUR);
final Velocity v3 = l4.div(t3);
System.out.println(l4 + " / " + l3 + " = " + v3);
System.out.println(v1 + " * " + t1 + " = " + v1.mult(t1).to(KILOMETER));
final Length l5 = v3.mult(t1.to(HOUR));
System.out.println(v3 + " * " + t1 + " = " + l5);
final Time t5 = l4.div(v2);
System.out.println(l4 + " / " + v2 + " = " + t5.to(MINUTE));
Velocity v5 = new Velocity(55, MPH);
System.out.println(v5 + " = " + v5.format("%4.1f %s", KMH));
System.out.println((v5.mult(new Time(30, MINUTE)).to(MILE)));
}
}

View File

@@ -1,28 +0,0 @@
package uebung07.quantities.plain;
public abstract class Quantity {
public final double value;
public final Unit unit;
protected Quantity(double value, Unit unit) {
this.value = value;
this.unit = unit;
}
public double getBaseValue() {
return value * unit.baseFactor;
}
public double value(Unit unit) {
return getBaseValue() / unit.baseFactor;
}
@Override
public String toString() {
return value + " " + unit;
}
public String format(String fmt, Unit unit) {
return String.format(fmt, value(unit), unit);
}
}

View File

@@ -1,41 +0,0 @@
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

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

View File

@@ -1,16 +0,0 @@
package uebung07.quantities.plain;
public abstract class Unit {
public final String name;
public final double baseFactor;
public Unit(String name, double baseFactor) {
this.name = name;
this.baseFactor = baseFactor;
}
@Override
public String toString() {
return name;
}
}

Some files were not shown because too many files have changed in this diff Show More