Compare commits
13 Commits
440eed0e9d
...
main
Author | SHA1 | Date | |
---|---|---|---|
5f15f03d92 | |||
9908656813 | |||
b439030fee | |||
7fea13b9b3 | |||
639da57def | |||
0c95c28bc4 | |||
ac1cc19a88 | |||
62da4a9ea5 | |||
dad5a33695 | |||
93fb940a8c | |||
55e6561e02 | |||
7972c9088c | |||
e59cbb88f1 |
BIN
bin/test/uebung/uebung05/logistics/ManagerTest.class
Normal file
BIN
bin/test/uebung/uebung05/logistics/ManagerTest.class
Normal file
Binary file not shown.
BIN
bin/test/uebung/uebung05/logistics/storage/IntStorageTest.class
Normal file
BIN
bin/test/uebung/uebung05/logistics/storage/IntStorageTest.class
Normal file
Binary file not shown.
BIN
bin/test/uebung/uebung09/collection/SetTest.class
Normal file
BIN
bin/test/uebung/uebung09/collection/SetTest.class
Normal file
Binary file not shown.
BIN
bin/test/uebung/uebung09/iterator/Array2dIteratorTest.class
Normal file
BIN
bin/test/uebung/uebung09/iterator/Array2dIteratorTest.class
Normal file
Binary file not shown.
BIN
bin/test/uebung/uebung09/iterator/SkipNullIteratorTest$1.class
Normal file
BIN
bin/test/uebung/uebung09/iterator/SkipNullIteratorTest$1.class
Normal file
Binary file not shown.
BIN
bin/test/uebung/uebung09/iterator/SkipNullIteratorTest$2.class
Normal file
BIN
bin/test/uebung/uebung09/iterator/SkipNullIteratorTest$2.class
Normal file
Binary file not shown.
BIN
bin/test/uebung/uebung09/iterator/SkipNullIteratorTest$3.class
Normal file
BIN
bin/test/uebung/uebung09/iterator/SkipNullIteratorTest$3.class
Normal file
Binary file not shown.
BIN
bin/test/uebung/uebung09/iterator/SkipNullIteratorTest.class
Normal file
BIN
bin/test/uebung/uebung09/iterator/SkipNullIteratorTest.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.
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/uebung09/collection/BigSet$1.class
Normal file
BIN
bin/uebung09/collection/BigSet$1.class
Normal file
Binary file not shown.
BIN
bin/uebung09/collection/BigSet.class
Normal file
BIN
bin/uebung09/collection/BigSet.class
Normal file
Binary file not shown.
BIN
bin/uebung09/collection/EmptySet$1.class
Normal file
BIN
bin/uebung09/collection/EmptySet$1.class
Normal file
Binary file not shown.
BIN
bin/uebung09/collection/EmptySet.class
Normal file
BIN
bin/uebung09/collection/EmptySet.class
Normal file
Binary file not shown.
Binary file not shown.
BIN
bin/uebung09/collection/SingeltonSet$1.class
Normal file
BIN
bin/uebung09/collection/SingeltonSet$1.class
Normal file
Binary file not shown.
BIN
bin/uebung09/collection/SingeltonSet.class
Normal file
BIN
bin/uebung09/collection/SingeltonSet.class
Normal file
Binary file not shown.
Binary file not shown.
BIN
bin/uebung09/iterator/SkipNullIterator.class
Normal file
BIN
bin/uebung09/iterator/SkipNullIterator.class
Normal file
Binary file not shown.
BIN
bin/uebung10/logo/BlackForest.class
Normal file
BIN
bin/uebung10/logo/BlackForest.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
bin/uebung10/logo/Go.class
Normal file
BIN
bin/uebung10/logo/Go.class
Normal file
Binary file not shown.
BIN
bin/uebung10/logo/HanselGretelFrame$1.class
Normal file
BIN
bin/uebung10/logo/HanselGretelFrame$1.class
Normal file
Binary file not shown.
Binary file not shown.
BIN
bin/uebung10/logo/HanselGretelTest.class
Normal file
BIN
bin/uebung10/logo/HanselGretelTest.class
Normal file
Binary file not shown.
BIN
bin/uebung10/logo/HanselGretelVisitor$1.class
Normal file
BIN
bin/uebung10/logo/HanselGretelVisitor$1.class
Normal file
Binary file not shown.
BIN
bin/uebung10/logo/HanselGretelVisitor$2.class
Normal file
BIN
bin/uebung10/logo/HanselGretelVisitor$2.class
Normal file
Binary file not shown.
BIN
bin/uebung10/logo/HanselGretelVisitor$3.class
Normal file
BIN
bin/uebung10/logo/HanselGretelVisitor$3.class
Normal file
Binary file not shown.
BIN
bin/uebung10/logo/HanselGretelVisitor$State.class
Normal file
BIN
bin/uebung10/logo/HanselGretelVisitor$State.class
Normal file
Binary file not shown.
BIN
bin/uebung10/logo/HanselGretelVisitor.class
Normal file
BIN
bin/uebung10/logo/HanselGretelVisitor.class
Normal file
Binary file not shown.
BIN
bin/uebung10/logo/PenDown.class
Normal file
BIN
bin/uebung10/logo/PenDown.class
Normal file
Binary file not shown.
BIN
bin/uebung10/logo/PenUp.class
Normal file
BIN
bin/uebung10/logo/PenUp.class
Normal file
Binary file not shown.
BIN
bin/uebung10/logo/Sequence.class
Normal file
BIN
bin/uebung10/logo/Sequence.class
Normal file
Binary file not shown.
BIN
bin/uebung10/logo/Stmt.class
Normal file
BIN
bin/uebung10/logo/Stmt.class
Normal file
Binary file not shown.
BIN
bin/uebung10/logo/Turn.class
Normal file
BIN
bin/uebung10/logo/Turn.class
Normal file
Binary file not shown.
Binary file not shown.
BIN
bin/uebung10/logo/Visitor.class
Normal file
BIN
bin/uebung10/logo/Visitor.class
Normal file
Binary file not shown.
BIN
lib/junit-platform-console-standalone-1.11.0-M2.jar
Normal file
BIN
lib/junit-platform-console-standalone-1.11.0-M2.jar
Normal file
Binary file not shown.
@@ -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;
|
||||||
|
|
@@ -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;
|
||||||
|
|
76
src/test/uebung/uebung09/collection/SetTest.java
Normal file
76
src/test/uebung/uebung09/collection/SetTest.java
Normal 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());
|
||||||
|
}
|
||||||
|
}
|
@@ -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;
|
@@ -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;
|
@@ -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'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -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();
|
||||||
|
@@ -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.
|
||||||
|
@@ -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);
|
||||||
|
@@ -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;
|
||||||
|
@@ -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.
|
||||||
|
@@ -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.
|
||||||
|
@@ -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.
|
||||||
|
@@ -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() {}
|
||||||
|
|
||||||
|
@@ -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() {}
|
||||||
|
|
||||||
|
@@ -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() {}
|
||||||
|
|
||||||
|
@@ -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() {}
|
||||||
|
|
||||||
|
@@ -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() {}
|
||||||
|
|
||||||
|
@@ -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() {}
|
||||||
|
|
||||||
|
@@ -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() {}
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
package logistics.quantities;
|
package uebung05.logistics.quantities;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Nikolaus Köberlein
|
* @author Nikolaus Köberlein
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
package logistics.quantities;
|
package uebung05.logistics.quantities;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Nikolaus Köberlein
|
* @author Nikolaus Köberlein
|
||||||
|
@@ -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;
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
package logistics.quantities;
|
package uebung05.logistics.quantities;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Nikolaus Köberlein
|
* @author Nikolaus Köberlein
|
||||||
|
@@ -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.
|
||||||
|
@@ -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.
|
||||||
|
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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);
|
|
||||||
}
|
|
@@ -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)));
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,5 +0,0 @@
|
|||||||
package uebung07.quantities.plain;
|
|
||||||
|
|
||||||
public class TimeUnit extends Unit{
|
|
||||||
|
|
||||||
}
|
|
@@ -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
Reference in New Issue
Block a user