Compare commits
31 Commits
2a8bb9262f
...
main
Author | SHA1 | Date | |
---|---|---|---|
5f15f03d92 | |||
9908656813 | |||
b439030fee | |||
7fea13b9b3 | |||
639da57def | |||
0c95c28bc4 | |||
ac1cc19a88 | |||
62da4a9ea5 | |||
dad5a33695 | |||
93fb940a8c | |||
55e6561e02 | |||
7972c9088c | |||
e59cbb88f1 | |||
440eed0e9d | |||
49262c4954 | |||
fa85372c13 | |||
8c224faa0e | |||
85e8396ce9 | |||
81ea768dca | |||
dcf2a95b4f | |||
e518460e81 | |||
753d5e2780 | |||
41743095bd | |||
38287f8c0b | |||
d9eaae7b7a | |||
b90d94bf41 | |||
096a49e0a8 | |||
a84a407c31 | |||
c60c85ade0 | |||
a021a64624 | |||
65da2599bd |
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.
BIN
bin/uebung05/logistics/Demo.class
Normal file
BIN
bin/uebung05/logistics/Demo.class
Normal file
Binary file not shown.
BIN
bin/uebung05/logistics/Helicopter.class
Normal file
BIN
bin/uebung05/logistics/Helicopter.class
Normal file
Binary file not shown.
BIN
bin/uebung05/logistics/Manager.class
Normal file
BIN
bin/uebung05/logistics/Manager.class
Normal file
Binary file not shown.
BIN
bin/uebung05/logistics/NeedCollector.class
Normal file
BIN
bin/uebung05/logistics/NeedCollector.class
Normal file
Binary file not shown.
BIN
bin/uebung05/logistics/Tank.class
Normal file
BIN
bin/uebung05/logistics/Tank.class
Normal file
Binary file not shown.
BIN
bin/uebung05/logistics/Truck.class
Normal file
BIN
bin/uebung05/logistics/Truck.class
Normal file
Binary file not shown.
BIN
bin/uebung05/logistics/Vehicle.class
Normal file
BIN
bin/uebung05/logistics/Vehicle.class
Normal file
Binary file not shown.
BIN
bin/uebung05/logistics/material/BulletBelts.class
Normal file
BIN
bin/uebung05/logistics/material/BulletBelts.class
Normal file
Binary file not shown.
BIN
bin/uebung05/logistics/material/Grease.class
Normal file
BIN
bin/uebung05/logistics/material/Grease.class
Normal file
Binary file not shown.
BIN
bin/uebung05/logistics/material/LiterDiesel.class
Normal file
BIN
bin/uebung05/logistics/material/LiterDiesel.class
Normal file
Binary file not shown.
BIN
bin/uebung05/logistics/material/MetGallonsKerosene.class
Normal file
BIN
bin/uebung05/logistics/material/MetGallonsKerosene.class
Normal file
Binary file not shown.
BIN
bin/uebung05/logistics/material/Oil.class
Normal file
BIN
bin/uebung05/logistics/material/Oil.class
Normal file
Binary file not shown.
BIN
bin/uebung05/logistics/material/RocketPods.class
Normal file
BIN
bin/uebung05/logistics/material/RocketPods.class
Normal file
Binary file not shown.
BIN
bin/uebung05/logistics/material/ShellBatches.class
Normal file
BIN
bin/uebung05/logistics/material/ShellBatches.class
Normal file
Binary file not shown.
BIN
bin/uebung05/logistics/quantities/FloatUnit.class
Normal file
BIN
bin/uebung05/logistics/quantities/FloatUnit.class
Normal file
Binary file not shown.
BIN
bin/uebung05/logistics/quantities/IntUnit.class
Normal file
BIN
bin/uebung05/logistics/quantities/IntUnit.class
Normal file
Binary file not shown.
BIN
bin/uebung05/logistics/quantities/NeedCollector.class
Normal file
BIN
bin/uebung05/logistics/quantities/NeedCollector.class
Normal file
Binary file not shown.
BIN
bin/uebung05/logistics/quantities/Unit.class
Normal file
BIN
bin/uebung05/logistics/quantities/Unit.class
Normal file
Binary file not shown.
BIN
bin/uebung05/logistics/storage/FloatStorage.class
Normal file
BIN
bin/uebung05/logistics/storage/FloatStorage.class
Normal file
Binary file not shown.
BIN
bin/uebung05/logistics/storage/IntStorage.class
Normal file
BIN
bin/uebung05/logistics/storage/IntStorage.class
Normal file
Binary file not shown.
BIN
bin/uebung06/Field.class
Normal file
BIN
bin/uebung06/Field.class
Normal file
Binary file not shown.
BIN
bin/uebung06/Sudoku.class
Normal file
BIN
bin/uebung06/Sudoku.class
Normal file
Binary file not shown.
BIN
bin/uebung06/SudokuApp.class
Normal file
BIN
bin/uebung06/SudokuApp.class
Normal file
Binary file not shown.
BIN
bin/uebung06/VALUE.class
Normal file
BIN
bin/uebung06/VALUE.class
Normal file
Binary file not shown.
BIN
bin/uebung08/doc/Book.class
Normal file
BIN
bin/uebung08/doc/Book.class
Normal file
Binary file not shown.
BIN
bin/uebung08/doc/BookDemo.class
Normal file
BIN
bin/uebung08/doc/BookDemo.class
Normal file
Binary file not shown.
BIN
bin/uebung08/doc/CountWordsVisitor.class
Normal file
BIN
bin/uebung08/doc/CountWordsVisitor.class
Normal file
Binary file not shown.
BIN
bin/uebung08/doc/Image.class
Normal file
BIN
bin/uebung08/doc/Image.class
Normal file
Binary file not shown.
BIN
bin/uebung08/doc/Paragraph.class
Normal file
BIN
bin/uebung08/doc/Paragraph.class
Normal file
Binary file not shown.
BIN
bin/uebung08/doc/Section.class
Normal file
BIN
bin/uebung08/doc/Section.class
Normal file
Binary file not shown.
BIN
bin/uebung08/doc/TableOfContentsVisitor.class
Normal file
BIN
bin/uebung08/doc/TableOfContentsVisitor.class
Normal file
Binary file not shown.
BIN
bin/uebung08/doc/TextComponent.class
Normal file
BIN
bin/uebung08/doc/TextComponent.class
Normal file
Binary file not shown.
BIN
bin/uebung08/doc/ToTextVisitor.class
Normal file
BIN
bin/uebung08/doc/ToTextVisitor.class
Normal file
Binary file not shown.
BIN
bin/uebung08/doc/Visitor.class
Normal file
BIN
bin/uebung08/doc/Visitor.class
Normal file
Binary file not shown.
BIN
bin/uebung09/chess/Board.class
Normal file
BIN
bin/uebung09/chess/Board.class
Normal file
Binary file not shown.
BIN
bin/uebung09/chess/ChessApp.class
Normal file
BIN
bin/uebung09/chess/ChessApp.class
Normal file
Binary file not shown.
BIN
bin/uebung09/chess/Color.class
Normal file
BIN
bin/uebung09/chess/Color.class
Normal file
Binary file not shown.
BIN
bin/uebung09/chess/Knight.class
Normal file
BIN
bin/uebung09/chess/Knight.class
Normal file
Binary file not shown.
BIN
bin/uebung09/chess/Piece.class
Normal file
BIN
bin/uebung09/chess/Piece.class
Normal file
Binary file not shown.
BIN
bin/uebung09/chess/Queen.class
Normal file
BIN
bin/uebung09/chess/Queen.class
Normal file
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.
BIN
bin/uebung09/collection/Set.class
Normal file
BIN
bin/uebung09/collection/Set.class
Normal file
Binary file not shown.
BIN
bin/uebung09/collection/SetFactory.class
Normal file
BIN
bin/uebung09/collection/SetFactory.class
Normal file
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.
BIN
bin/uebung09/iterator/Array2dIterator.class
Normal file
BIN
bin/uebung09/iterator/Array2dIterator.class
Normal file
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.
BIN
bin/uebung10/logo/DarkForest.class
Normal file
BIN
bin/uebung10/logo/DarkForest.class
Normal file
Binary file not shown.
BIN
bin/uebung10/logo/Demo.class
Normal file
BIN
bin/uebung10/logo/Demo.class
Normal file
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.
BIN
bin/uebung10/logo/HanselGretelFrame.class
Normal file
BIN
bin/uebung10/logo/HanselGretelFrame.class
Normal file
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.
BIN
bin/uebung10/logo/Turtle.class
Normal file
BIN
bin/uebung10/logo/Turtle.class
Normal file
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.
72
src/test/uebung/uebung05/logistics/ManagerTest.java
Normal file
72
src/test/uebung/uebung05/logistics/ManagerTest.java
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
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 org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
public class ManagerTest {
|
||||||
|
private static final float EPS = 1e-5f;
|
||||||
|
private Manager manager;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setup() {
|
||||||
|
manager = new Manager();
|
||||||
|
manager.addVehicle(new Tank("Leo1"));
|
||||||
|
manager.addVehicle(new Tank("Leo2"));
|
||||||
|
manager.addVehicle(new Helicopter("Tiger1"));
|
||||||
|
manager.addVehicle(new Helicopter("Tiger2"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInitialNeed() {
|
||||||
|
final NeedCollector collector = manager.collectNeeds();
|
||||||
|
assertEquals(4, collector.getNeed(RocketPods.INSTANCE));
|
||||||
|
assertEquals(12, collector.getNeed(Oil.INSTANCE));
|
||||||
|
assertEquals(24, collector.getNeed(BulletBelts.INSTANCE));
|
||||||
|
assertEquals(20, collector.getNeed(ShellBatches.INSTANCE));
|
||||||
|
assertEquals(12, collector.getNeed(Grease.INSTANCE));
|
||||||
|
assertEquals(1000f, collector.getNeed(MetGallonsKerosene.INSTANCE), EPS);
|
||||||
|
assertEquals(2400f, collector.getNeed(LiterDiesel.INSTANCE), EPS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNeedAfterFillUp() {
|
||||||
|
manager.fillUpVehicles();
|
||||||
|
final NeedCollector collector = manager.collectNeeds();
|
||||||
|
assertEquals(0, collector.getNeed(RocketPods.INSTANCE));
|
||||||
|
assertEquals(0, collector.getNeed(Oil.INSTANCE));
|
||||||
|
assertEquals(0, collector.getNeed(BulletBelts.INSTANCE));
|
||||||
|
assertEquals(0, collector.getNeed(ShellBatches.INSTANCE));
|
||||||
|
assertEquals(0, collector.getNeed(Grease.INSTANCE));
|
||||||
|
assertEquals(0f, collector.getNeed(MetGallonsKerosene.INSTANCE), EPS);
|
||||||
|
assertEquals(0f, collector.getNeed(LiterDiesel.INSTANCE), EPS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNeedAfterLogTick() {
|
||||||
|
manager.fillUpVehicles();
|
||||||
|
manager.logTick(1);
|
||||||
|
final NeedCollector collector = manager.collectNeeds();
|
||||||
|
assertEquals(2, collector.getNeed(RocketPods.INSTANCE));
|
||||||
|
assertEquals(4, collector.getNeed(Oil.INSTANCE));
|
||||||
|
assertEquals(6, collector.getNeed(BulletBelts.INSTANCE));
|
||||||
|
assertEquals(4, collector.getNeed(ShellBatches.INSTANCE));
|
||||||
|
assertEquals(4, collector.getNeed(Grease.INSTANCE));
|
||||||
|
assertEquals(100f, collector.getNeed(MetGallonsKerosene.INSTANCE), EPS);
|
||||||
|
assertEquals(360f, collector.getNeed(LiterDiesel.INSTANCE), EPS);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,82 @@
|
|||||||
|
package test.uebung.uebung05.logistics.storage;
|
||||||
|
|
||||||
|
import uebung05.logistics.material.Oil;
|
||||||
|
import uebung05.logistics.storage.IntStorage;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
public class IntStorageTest {
|
||||||
|
private static final int MAX = 3;
|
||||||
|
|
||||||
|
private IntStorage intStorage;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setup() {
|
||||||
|
intStorage = new IntStorage(0, Oil.INSTANCE, MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEmptyStorage() {
|
||||||
|
assertEquals(0, intStorage.getStored());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetStorage() {
|
||||||
|
intStorage.fill(1);
|
||||||
|
assertEquals(1, intStorage.getStored());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetMax() {
|
||||||
|
assertEquals(MAX, intStorage.getMax());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFillUp() {
|
||||||
|
intStorage.fillUp();
|
||||||
|
assertEquals(MAX, intStorage.getStored());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpperBound() {
|
||||||
|
intStorage.fill(MAX + 1);
|
||||||
|
assertEquals(MAX, intStorage.getStored());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConsume() {
|
||||||
|
intStorage.fillUp();
|
||||||
|
assertEquals(MAX, intStorage.getStored());
|
||||||
|
assertEquals(MAX, intStorage.consume(MAX));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLowerBound() {
|
||||||
|
intStorage.consume(1);
|
||||||
|
assertEquals(0, intStorage.getStored());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
public void testIllegalFill() {
|
||||||
|
intStorage.fill(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
public void testIllegalConsume() {
|
||||||
|
intStorage.consume(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
public void testIllegalLowerBoundConstructor() {
|
||||||
|
new IntStorage(-1, Oil.INSTANCE, MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpperBoundConstructor() {
|
||||||
|
final IntStorage storage = new IntStorage(MAX + 1, Oil.INSTANCE, MAX);
|
||||||
|
assertEquals(MAX, storage.getStored());
|
||||||
|
}
|
||||||
|
}
|
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());
|
||||||
|
}
|
||||||
|
}
|
44
src/test/uebung/uebung09/iterator/Array2dIteratorTest.java
Normal file
44
src/test/uebung/uebung09/iterator/Array2dIteratorTest.java
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
package test.uebung.uebung09.iterator;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
|
import uebung09.iterator.Array2dIterator;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertThrows;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
public class Array2dIteratorTest {
|
||||||
|
@Test
|
||||||
|
public void testArray2dIterator() {
|
||||||
|
final String[][] array = {{}, {"foo", "bar"}, {"baz"}, {}};
|
||||||
|
final Iterator<String> it = new Array2dIterator<>(array);
|
||||||
|
assertTrue(it.hasNext());
|
||||||
|
assertEquals("foo", it.next());
|
||||||
|
assertTrue(it.hasNext());
|
||||||
|
assertEquals("bar", it.next());
|
||||||
|
assertTrue(it.hasNext());
|
||||||
|
assertEquals("baz", it.next());
|
||||||
|
assertFalse(it.hasNext());
|
||||||
|
assertThrows(NoSuchElementException.class, it::next);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testArray2dIteratorOnlyEmpty() {
|
||||||
|
final String[][] array = {{}, {}, {}};
|
||||||
|
final Iterator<String> it = new Array2dIterator<>(array);
|
||||||
|
assertFalse(it.hasNext());
|
||||||
|
assertThrows(NoSuchElementException.class, it::next);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testArray2dIteratorEmpty() {
|
||||||
|
final String[][] array = {};
|
||||||
|
final Iterator<String> it = new Array2dIterator<>(array);
|
||||||
|
assertFalse(it.hasNext());
|
||||||
|
assertThrows(NoSuchElementException.class, it::next);
|
||||||
|
}
|
||||||
|
}
|
124
src/test/uebung/uebung09/iterator/SkipNullIteratorTest.java
Normal file
124
src/test/uebung/uebung09/iterator/SkipNullIteratorTest.java
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
package test.uebung.uebung09.iterator;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
|
import uebung09.iterator.*;
|
||||||
|
|
||||||
|
import static java.util.Arrays.asList;
|
||||||
|
import static java.util.Collections.emptyList;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertThrows;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
public class SkipNullIteratorTest {
|
||||||
|
@Test
|
||||||
|
public void testEmpty() {
|
||||||
|
final Iterator<Object> it = new SkipNullIterator<>(emptyList().iterator());
|
||||||
|
assertFalse(it.hasNext());
|
||||||
|
assertThrows(NoSuchElementException.class, it::next);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNull() {
|
||||||
|
final Iterator<Object> it = new SkipNullIterator<>(asList(null, null).iterator());
|
||||||
|
assertFalse(it.hasNext());
|
||||||
|
assertThrows(NoSuchElementException.class, it::next);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNonNull() {
|
||||||
|
final Iterator<String> it = new SkipNullIterator<>(asList("foo").iterator());
|
||||||
|
assertTrue(it.hasNext());
|
||||||
|
assertEquals("foo", it.next());
|
||||||
|
assertFalse(it.hasNext());
|
||||||
|
assertThrows(NoSuchElementException.class, it::next);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMixed() {
|
||||||
|
final Iterator<String> it = new SkipNullIterator<>(asList(null, "foo", null).iterator());
|
||||||
|
assertTrue(it.hasNext());
|
||||||
|
assertEquals("foo", it.next());
|
||||||
|
assertFalse(it.hasNext());
|
||||||
|
assertThrows(NoSuchElementException.class, it::next);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMixed2() {
|
||||||
|
final Iterator<String> oriIt = asList("a", "b", null, "c").iterator();
|
||||||
|
Iterator<String> it = new SkipNullIterator<>(oriIt);
|
||||||
|
assertTrue(it.hasNext());
|
||||||
|
assertEquals("a", it.next());
|
||||||
|
assertTrue(it.hasNext());
|
||||||
|
assertEquals("b", it.next());
|
||||||
|
assertTrue(it.hasNext());
|
||||||
|
assertEquals("c", it.next());
|
||||||
|
assertFalse(it.hasNext());
|
||||||
|
assertThrows(NoSuchElementException.class, it::next);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDontCallInCtor() {
|
||||||
|
final Iterator<String> dontCallNext = new Iterator<>() {
|
||||||
|
@Override
|
||||||
|
public boolean hasNext() {
|
||||||
|
throw new RuntimeException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String next() {
|
||||||
|
throw new RuntimeException();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
new SkipNullIterator<>(dontCallNext);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSkipNullIteratorInfinity() {
|
||||||
|
final Iterator<String> oriIt = new Iterator<>() {
|
||||||
|
@Override
|
||||||
|
public boolean hasNext() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String next() {
|
||||||
|
return "infinity";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
final Iterator<String> it = new SkipNullIterator<>(oriIt);
|
||||||
|
for (int i = 0; i < 1000; i++) {
|
||||||
|
assertTrue(it.hasNext());
|
||||||
|
assertEquals("infinity", it.next());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPathological() {
|
||||||
|
final Iterator<String> oriIt = new Iterator<>() {
|
||||||
|
private int ctr;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasNext() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String next() {
|
||||||
|
return ctr++ > 100000 ? "infinity" : null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
final Iterator<String> it = new SkipNullIterator<>(oriIt);
|
||||||
|
for (int i = 0; i < 1000; i++) {
|
||||||
|
assertTrue(it.hasNext());
|
||||||
|
assertEquals("infinity", it.next());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
38
src/uebung05/logistics/Demo.java
Executable file
38
src/uebung05/logistics/Demo.java
Executable file
@@ -0,0 +1,38 @@
|
|||||||
|
package uebung05.logistics;
|
||||||
|
|
||||||
|
import uebung05.logistics.material.BulletBelts;
|
||||||
|
import uebung05.logistics.material.LiterDiesel;
|
||||||
|
import uebung05.logistics.material.RocketPods;
|
||||||
|
|
||||||
|
class Demo {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Manager ceo = new Manager();
|
||||||
|
|
||||||
|
Vehicle panther = new Tank("Panther");
|
||||||
|
Vehicle leo = new Tank("Leopard 2A7");
|
||||||
|
Vehicle tiger = new Helicopter("Tiger");
|
||||||
|
Vehicle h125m = new Helicopter("H145M");
|
||||||
|
Vehicle husky = new Truck("BV206-S Hägglunds");
|
||||||
|
Vehicle zwoTonner = new Truck("Unimog2000");
|
||||||
|
|
||||||
|
ceo.addVehicle(panther);
|
||||||
|
ceo.addVehicle(leo);
|
||||||
|
ceo.addVehicle(tiger);
|
||||||
|
ceo.addVehicle(h125m);
|
||||||
|
ceo.addVehicle(husky);
|
||||||
|
ceo.addVehicle(zwoTonner);
|
||||||
|
|
||||||
|
ceo.showOverallNeed();
|
||||||
|
ceo.showNeed(LiterDiesel.getINSTANCE());
|
||||||
|
ceo.fillUpVehicles();
|
||||||
|
ceo.showOverallNeed();
|
||||||
|
ceo.logTick(2);
|
||||||
|
ceo.showOverallNeed();
|
||||||
|
ceo.showNeed(RocketPods.getINSTANCE());
|
||||||
|
ceo.fillUpVehicles();
|
||||||
|
ceo.logTick(1);
|
||||||
|
ceo.showOverallNeed();
|
||||||
|
ceo.showNeed(BulletBelts.getINSTANCE());
|
||||||
|
}
|
||||||
|
}
|
114
src/uebung05/logistics/Helicopter.java
Executable file
114
src/uebung05/logistics/Helicopter.java
Executable file
@@ -0,0 +1,114 @@
|
|||||||
|
package uebung05.logistics;
|
||||||
|
|
||||||
|
import uebung05.logistics.material.BulletBelts;
|
||||||
|
import uebung05.logistics.material.MetGallonsKerosene;
|
||||||
|
import uebung05.logistics.material.RocketPods;
|
||||||
|
import uebung05.logistics.quantities.FloatUnit;
|
||||||
|
import uebung05.logistics.quantities.IntUnit;
|
||||||
|
import uebung05.logistics.quantities.NeedCollector;
|
||||||
|
import uebung05.logistics.storage.FloatStorage;
|
||||||
|
import uebung05.logistics.storage.IntStorage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Helicopter class represents a helicopter in the logistics system.
|
||||||
|
* It extends the Vehicle abstract class and includes a tank for kerosene,
|
||||||
|
* a storage for bullet belts, and a storage for rocket pods, and the necessary methods
|
||||||
|
* for reporting needs, filling up, and consuming supplies.
|
||||||
|
*
|
||||||
|
* @author Nikolaus Köberlein
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public class Helicopter extends Vehicle {
|
||||||
|
|
||||||
|
FloatStorage tank;
|
||||||
|
IntStorage bullets;
|
||||||
|
IntStorage rockets;
|
||||||
|
|
||||||
|
private final static int maxAmmunition = 2;
|
||||||
|
private final static int maxFuel = 500;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a Helicopter object with a name, kerosene amount, bullet belts amount, and rocket pods amount
|
||||||
|
*
|
||||||
|
* @param name The name of the helicopter
|
||||||
|
* @param kerosine The initial amount of kerosene for the helicopter
|
||||||
|
* @param bulletsBelts The initial amount of bullet belts for the helicopter
|
||||||
|
* @param rocketPods The initial amount of rocket pods for the helicopter
|
||||||
|
*/
|
||||||
|
public Helicopter(String name, float kerosine, int bulletsBelts, int rocketPods) {
|
||||||
|
super(name, 3, 3);
|
||||||
|
|
||||||
|
this.bullets = new IntStorage(bulletsBelts, BulletBelts.getINSTANCE(), maxAmmunition);
|
||||||
|
this.rockets = new IntStorage(rocketPods, RocketPods.getINSTANCE(), maxAmmunition);
|
||||||
|
this.tank = new FloatStorage(kerosine, MetGallonsKerosene.getINSTANCE(), maxFuel);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a Helicopter object with a name, kerosene amount, bullet belts amount, and rocket pods amount
|
||||||
|
*
|
||||||
|
* @param name The name of the helicopter
|
||||||
|
*/
|
||||||
|
public Helicopter(String name) {
|
||||||
|
this(name, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Report the needs of the helicopter to a NeedCollector object
|
||||||
|
*
|
||||||
|
* @param collector The NeedCollector object to which to report the needs
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void reportNeeds(NeedCollector collector) {
|
||||||
|
tank.reportNeed(collector);
|
||||||
|
bullets.reportNeed(collector);
|
||||||
|
rockets.reportNeed(collector);
|
||||||
|
super.reportBasicNeeds(collector);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fill up all the supplies for the helicopter
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void fillUpAll() {
|
||||||
|
tank.fillUp();
|
||||||
|
bullets.fillUp();
|
||||||
|
rockets.fillUp();
|
||||||
|
super.fillUpBasic();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Consume the helicopter's supplies based on the intensity rate
|
||||||
|
*
|
||||||
|
* @param intensityRate The intensity rate for the consumption
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void consumeAll(int intensityRate) {
|
||||||
|
tank.consume(intensityRate*200);
|
||||||
|
bullets.consume(intensityRate);
|
||||||
|
rockets.consume(intensityRate);
|
||||||
|
super.consumeBasic();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the helicopter needs a specific IntUnit object
|
||||||
|
*
|
||||||
|
* @param unit The IntUnit object for which to check the need
|
||||||
|
* @return True if the helicopter needs the IntUnit object, false otherwise
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean need(IntUnit unit) {
|
||||||
|
return unit == bullets.getUnit() || unit == rockets.getUnit() || unit == oil.getUnit() || unit == grease.getUnit();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the helicopter needs a specific FloatUnit object
|
||||||
|
*
|
||||||
|
* @param unit The FloatUnit object for which to check the need
|
||||||
|
* @return True if the helicopter needs the FloatUnit object, false otherwise
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean need(FloatUnit unit) {
|
||||||
|
return unit == tank.getUnit();
|
||||||
|
}
|
||||||
|
}
|
120
src/uebung05/logistics/Manager.java
Executable file
120
src/uebung05/logistics/Manager.java
Executable file
@@ -0,0 +1,120 @@
|
|||||||
|
package uebung05.logistics;
|
||||||
|
|
||||||
|
import uebung05.logistics.quantities.FloatUnit;
|
||||||
|
import uebung05.logistics.quantities.IntUnit;
|
||||||
|
import uebung05.logistics.quantities.NeedCollector;
|
||||||
|
import uebung05.logistics.quantities.Unit;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Manager class manages a list of Vehicle objects and provides methods for adding, filling up, and logging ticks for the vehicles.
|
||||||
|
* It also includes methods for collecting and displaying the overall needs of the vehicles and the needs for specific IntUnit or FloatUnit objects.
|
||||||
|
*
|
||||||
|
* @author Nikolaus Köberlein
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public class Manager {
|
||||||
|
|
||||||
|
private List<Vehicle> vehicles;
|
||||||
|
|
||||||
|
public Manager() {
|
||||||
|
this.vehicles = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a Vehicle object to the list of vehicles
|
||||||
|
*
|
||||||
|
* @param vehicle The Vehicle object to be added
|
||||||
|
*/
|
||||||
|
public void addVehicle(Vehicle vehicle) {
|
||||||
|
vehicles.add(vehicle);
|
||||||
|
System.out.println("Boris bought a new " + vehicle.getClass().getSimpleName() + " " + vehicle + ".");
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fill up all the vehicles in the list
|
||||||
|
*/
|
||||||
|
public void fillUpVehicles() {
|
||||||
|
for (Vehicle vehicle : vehicles) {
|
||||||
|
vehicle.fillUpAll();
|
||||||
|
}
|
||||||
|
System.out.println("All vehicles filled and ready for combat.");
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a tick for all the vehicles in the list, consuming their supplies based on the intensity rate
|
||||||
|
*
|
||||||
|
* @param intensityRate The intensity rate for the tick
|
||||||
|
*/
|
||||||
|
public void logTick(int intensityRate) {
|
||||||
|
for (Vehicle vehicle : vehicles) {
|
||||||
|
vehicle.consumeAll(intensityRate);
|
||||||
|
}
|
||||||
|
System.out.println("All vehicles consumed because of " + intensityRate + " battle(s).");
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collect the needs of all the vehicles in the list and return a NeedCollector object
|
||||||
|
*
|
||||||
|
* @return The NeedCollector object containing the needs of all the vehicles
|
||||||
|
*/
|
||||||
|
public NeedCollector collectNeeds() {
|
||||||
|
NeedCollector collector = new NeedCollector();
|
||||||
|
for (Vehicle vehicle : vehicles) {
|
||||||
|
vehicle.reportNeeds(collector);
|
||||||
|
}
|
||||||
|
return collector;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the overall needs of all the vehicles in the list
|
||||||
|
*/
|
||||||
|
public void showOverallNeed() {
|
||||||
|
NeedCollector collector = collectNeeds();
|
||||||
|
collector.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the vehicles needing a specific IntUnit object
|
||||||
|
*
|
||||||
|
* @param unit The IntUnit object for which to display the vehicles
|
||||||
|
*/
|
||||||
|
public void showNeed(IntUnit unit) {
|
||||||
|
/*if (unit instanceof IntUnit) {
|
||||||
|
IntUnit intUnit = (IntUnit) unit;
|
||||||
|
} else if (unit instanceof FloatUnit) {
|
||||||
|
FloatUnit floatUnit = (FloatUnit) unit;
|
||||||
|
}*/
|
||||||
|
System.out.println("Vehicles needing " + unit.toString() + ":");
|
||||||
|
for (Vehicle vehicle : vehicles) {
|
||||||
|
if (vehicle.need(unit)) {
|
||||||
|
NeedCollector collector = new NeedCollector();
|
||||||
|
vehicle.reportNeeds(collector);
|
||||||
|
System.out.println("- " + vehicle + " needs " + collector.getNeed(unit) + " " + unit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the vehicles needing a specific FloatUnit object
|
||||||
|
*
|
||||||
|
* @param unit The FloatUnit object for which to display the vehicles
|
||||||
|
*/
|
||||||
|
public void showNeed(FloatUnit unit) {
|
||||||
|
System.out.println("Vehicles needing " + unit.toString() + ":");
|
||||||
|
for (Vehicle vehicle : vehicles) {
|
||||||
|
if (vehicle.need(unit)) {
|
||||||
|
NeedCollector collector = new NeedCollector();
|
||||||
|
vehicle.reportNeeds(collector);
|
||||||
|
System.out.println("- " + vehicle + " needs " + collector.getNeed(unit) + " " + unit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
}
|
38
src/uebung05/logistics/NeedCollector.java
Executable file
38
src/uebung05/logistics/NeedCollector.java
Executable file
@@ -0,0 +1,38 @@
|
|||||||
|
package uebung05.logistics;
|
||||||
|
|
||||||
|
import uebung05.logistics.quantities.FloatUnit;
|
||||||
|
import uebung05.logistics.quantities.IntUnit;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class NeedCollector {
|
||||||
|
|
||||||
|
private Map<IntUnit, Integer> intNeeded;
|
||||||
|
private Map<FloatUnit, Float> floatNeeded;
|
||||||
|
|
||||||
|
public NeedCollector() {
|
||||||
|
intNeeded = new HashMap<>();
|
||||||
|
floatNeeded = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add (int amount, IntUnit unit) {
|
||||||
|
intNeeded.put(unit, amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add (float amount, FloatUnit unit) {
|
||||||
|
floatNeeded.put(unit, amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNeed (IntUnit unit) {
|
||||||
|
return intNeeded.get(unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getNeed (FloatUnit unit) {
|
||||||
|
return floatNeeded.get(unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void show () {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
112
src/uebung05/logistics/Tank.java
Executable file
112
src/uebung05/logistics/Tank.java
Executable file
@@ -0,0 +1,112 @@
|
|||||||
|
package uebung05.logistics;
|
||||||
|
|
||||||
|
import uebung05.logistics.material.BulletBelts;
|
||||||
|
import uebung05.logistics.material.LiterDiesel;
|
||||||
|
import uebung05.logistics.material.ShellBatches;
|
||||||
|
import uebung05.logistics.quantities.FloatUnit;
|
||||||
|
import uebung05.logistics.quantities.IntUnit;
|
||||||
|
import uebung05.logistics.quantities.NeedCollector;
|
||||||
|
import uebung05.logistics.storage.FloatStorage;
|
||||||
|
import uebung05.logistics.storage.IntStorage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Tank class represents a tank in the logistics system.
|
||||||
|
* It extends the Vehicle abstract class and includes a tank for diesel, a storage for bullet belts,
|
||||||
|
* and a storage for shell batches, and the necessary methods for reporting needs, filling up, and consuming supplies.
|
||||||
|
*
|
||||||
|
* @author Nikolaus Köberlein
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public class Tank extends Vehicle {
|
||||||
|
|
||||||
|
FloatStorage tank;
|
||||||
|
IntStorage shell;
|
||||||
|
IntStorage bullets;
|
||||||
|
|
||||||
|
private final static int maxAmmunition = 10;
|
||||||
|
private final static int maxFuel = 1200;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a Tank object with a name, diesel amount, bullet belts amount, and shell batches amount
|
||||||
|
*
|
||||||
|
* @param name The name of the tank
|
||||||
|
* @param diesel The initial amount of diesel for the tank
|
||||||
|
* @param bulletBelts The initial amount of bullet belts for the tank
|
||||||
|
* @param shellBatches The initial amount of shell batches for the tank
|
||||||
|
*/
|
||||||
|
public Tank(String name, float diesel, int bulletBelts, int shellBatches) {
|
||||||
|
super(name, 3, 3);
|
||||||
|
|
||||||
|
this.shell = new IntStorage(shellBatches, ShellBatches.getINSTANCE(), maxAmmunition);
|
||||||
|
this.bullets = new IntStorage(bulletBelts, BulletBelts.getINSTANCE(), maxAmmunition);
|
||||||
|
this.tank = new FloatStorage(diesel, LiterDiesel.getINSTANCE(), maxFuel);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a Tank object with a name
|
||||||
|
*
|
||||||
|
* @param name The name of the tank
|
||||||
|
*/
|
||||||
|
public Tank(String name) {
|
||||||
|
this(name, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Report the needs of the tank to a NeedCollector object
|
||||||
|
*
|
||||||
|
* @param collector The NeedCollector object to which to report the needs
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void reportNeeds(NeedCollector collector) {
|
||||||
|
tank.reportNeed(collector);
|
||||||
|
shell.reportNeed(collector);
|
||||||
|
bullets.reportNeed(collector);
|
||||||
|
super.reportBasicNeeds(collector);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fill up all the supplies for the tank
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void fillUpAll() {
|
||||||
|
tank.fillUp();
|
||||||
|
shell.fillUp();
|
||||||
|
bullets.fillUp();
|
||||||
|
super.fillUpBasic();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Consume the tank's supplies based on the intensity rate
|
||||||
|
*
|
||||||
|
* @param intensityRate The intensity rate for the consumption
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void consumeAll(int intensityRate) {
|
||||||
|
tank.consume(intensityRate*180);
|
||||||
|
bullets.consume(intensityRate*2);
|
||||||
|
shell.consume(intensityRate*2);
|
||||||
|
super.consumeBasic();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the tank needs a specific IntUnit object
|
||||||
|
*
|
||||||
|
* @param unit The IntUnit object for which to check the need
|
||||||
|
* @return True if the tank needs the IntUnit object, false otherwise
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean need(IntUnit unit) {
|
||||||
|
return unit == shell.getUnit() || unit == bullets.getUnit() || unit == oil.getUnit() || unit == grease.getUnit();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the tank needs a specific FloatUnit object
|
||||||
|
*
|
||||||
|
* @param unit The FloatUnit object for which to check the need
|
||||||
|
* @return True if the tank needs the FloatUnit object, false otherwise
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean need(FloatUnit unit) {
|
||||||
|
return unit == tank.getUnit();
|
||||||
|
}
|
||||||
|
}
|
104
src/uebung05/logistics/Truck.java
Executable file
104
src/uebung05/logistics/Truck.java
Executable file
@@ -0,0 +1,104 @@
|
|||||||
|
package uebung05.logistics;
|
||||||
|
|
||||||
|
import uebung05.logistics.material.BulletBelts;
|
||||||
|
import uebung05.logistics.material.LiterDiesel;
|
||||||
|
import uebung05.logistics.quantities.FloatUnit;
|
||||||
|
import uebung05.logistics.quantities.IntUnit;
|
||||||
|
import uebung05.logistics.quantities.NeedCollector;
|
||||||
|
import uebung05.logistics.storage.FloatStorage;
|
||||||
|
import uebung05.logistics.storage.IntStorage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Truck class represents a truck in the logistics system.
|
||||||
|
* It extends the Vehicle abstract class and includes a tank for diesel, a storage for bullet belts, and the necessary methods for reporting needs, filling up, and consuming supplies.
|
||||||
|
*
|
||||||
|
* @author Nikolaus Köberlein
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public class Truck extends Vehicle {
|
||||||
|
|
||||||
|
FloatStorage tank;
|
||||||
|
IntStorage bullets;
|
||||||
|
|
||||||
|
private final static int maxAmmunition = 3;
|
||||||
|
private final static int maxFuel = 180;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a Truck object with a name, diesel amount, and bullet belts amount
|
||||||
|
*
|
||||||
|
* @param name The name of the truck
|
||||||
|
* @param diesel The initial amount of diesel for the truck
|
||||||
|
* @param bulletBelts The initial amount of bullet belts for the truck
|
||||||
|
*/
|
||||||
|
public Truck(String name, float diesel, int bulletBelts) {
|
||||||
|
super(name, 3, 3);
|
||||||
|
|
||||||
|
tank = new FloatStorage(diesel, LiterDiesel.getINSTANCE(), maxFuel);
|
||||||
|
bullets = new IntStorage(bulletBelts, BulletBelts.getINSTANCE(), maxAmmunition);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a Truck object with a name, diesel amount, and bullet belts amount
|
||||||
|
*
|
||||||
|
* @param name The name of the truck
|
||||||
|
*/
|
||||||
|
public Truck(String name) {
|
||||||
|
this(name, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Report the needs of the truck to a NeedCollector object
|
||||||
|
*
|
||||||
|
* @param collector The NeedCollector object to which to report the needs
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void reportNeeds(NeedCollector collector) {
|
||||||
|
tank.reportNeed(collector);
|
||||||
|
bullets.reportNeed(collector);
|
||||||
|
super.reportBasicNeeds(collector);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fill up all the supplies for the truck
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void fillUpAll() {
|
||||||
|
tank.fillUp();
|
||||||
|
bullets.fillUp();
|
||||||
|
super.fillUpBasic();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Consume the truck's supplies based on the intensity rate
|
||||||
|
*
|
||||||
|
* @param intensityRate The intensity rate for the consumption
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void consumeAll(int intensityRate) {
|
||||||
|
tank.consume(intensityRate*25);
|
||||||
|
bullets.consume(intensityRate*2);
|
||||||
|
super.consumeBasic();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the truck needs a specific IntUnit object
|
||||||
|
*
|
||||||
|
* @param unit The IntUnit object for which to check the need
|
||||||
|
* @return True if the truck needs the IntUnit object, false otherwise
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean need(IntUnit unit) {
|
||||||
|
return unit == bullets.getUnit() || unit == oil.getUnit() || unit == grease.getUnit();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the truck needs a specific FloatUnit object
|
||||||
|
*
|
||||||
|
* @param unit The FloatUnit object for which to check the need
|
||||||
|
* @return True if the truck needs the FloatUnit object, false otherwise
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean need(FloatUnit unit) {
|
||||||
|
return unit == tank.getUnit();
|
||||||
|
}
|
||||||
|
}
|
105
src/uebung05/logistics/Vehicle.java
Executable file
105
src/uebung05/logistics/Vehicle.java
Executable file
@@ -0,0 +1,105 @@
|
|||||||
|
package uebung05.logistics;
|
||||||
|
|
||||||
|
import uebung05.logistics.material.Grease;
|
||||||
|
import uebung05.logistics.material.Oil;
|
||||||
|
import uebung05.logistics.quantities.FloatUnit;
|
||||||
|
import uebung05.logistics.quantities.IntUnit;
|
||||||
|
import uebung05.logistics.quantities.NeedCollector;
|
||||||
|
import uebung05.logistics.storage.IntStorage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Vehicle abstract class represents a vehicle in the logistics system.
|
||||||
|
* It includes an abstract reportNeeds method for reporting the needs of the vehicle,
|
||||||
|
* an abstract fillUpAll method for filling up the vehicle, an abstract consumeAll method for
|
||||||
|
* consuming the vehicle's supplies, and abstract need methods for checking if the vehicle needs
|
||||||
|
* a specific IntUnit or FloatUnit object.
|
||||||
|
*
|
||||||
|
* @author Nikolaus Köberlein
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public abstract class Vehicle {
|
||||||
|
|
||||||
|
String name;
|
||||||
|
IntStorage oil;
|
||||||
|
IntStorage grease;
|
||||||
|
|
||||||
|
private final static int maxOil = 3;
|
||||||
|
private final static int maxGrease = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a Vehicle object with a name, oil storage, and grease storage
|
||||||
|
*
|
||||||
|
* @param name The name of the vehicle
|
||||||
|
* @param oil The initial amount of oil for the vehicle
|
||||||
|
* @param grease The initial amount of grease for the vehicle
|
||||||
|
*/
|
||||||
|
protected Vehicle(String name, int oil, int grease) {
|
||||||
|
this.name = name;
|
||||||
|
this.oil = new IntStorage(oil, Oil.getINSTANCE(), maxOil);
|
||||||
|
this.grease = new IntStorage(grease, Grease.getINSTANCE(), maxGrease);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fill up oil and grease.
|
||||||
|
*/
|
||||||
|
public void fillUpBasic () {
|
||||||
|
oil.fillUp();
|
||||||
|
grease.fillUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Consume oil and grease.
|
||||||
|
*/
|
||||||
|
public void consumeBasic () {
|
||||||
|
oil.consume(1);
|
||||||
|
grease.consume(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Report needs of oil and grease.
|
||||||
|
*/
|
||||||
|
public void reportBasicNeeds (NeedCollector collector) {
|
||||||
|
oil.reportNeed(collector);
|
||||||
|
grease.reportNeed(collector);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Report the needs of the vehicle to a NeedCollector object
|
||||||
|
*
|
||||||
|
* @param collector The NeedCollector object to which to report the needs
|
||||||
|
*/
|
||||||
|
public abstract void reportNeeds(NeedCollector collector);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fill up all the supplies for the vehicle
|
||||||
|
*/
|
||||||
|
public abstract void fillUpAll();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Consume the vehicle's supplies based on the intensity rate
|
||||||
|
*
|
||||||
|
* @param intensityRate The intensity rate for the consumption
|
||||||
|
*/
|
||||||
|
public abstract void consumeAll(int intensityRate);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the vehicle needs a specific IntUnit object
|
||||||
|
*
|
||||||
|
* @param unit The IntUnit object for which to check the need
|
||||||
|
* @return True if the vehicle needs the IntUnit object, false otherwise
|
||||||
|
*/
|
||||||
|
public abstract Boolean need(IntUnit unit);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the vehicle needs a specific FloatUnit object
|
||||||
|
*
|
||||||
|
* @param unit The FloatUnit object for which to check the need
|
||||||
|
* @return True if the vehicle needs the FloatUnit object, false otherwise
|
||||||
|
*/
|
||||||
|
public abstract Boolean need(FloatUnit unit);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
39
src/uebung05/logistics/material/BulletBelts.java
Executable file
39
src/uebung05/logistics/material/BulletBelts.java
Executable file
@@ -0,0 +1,39 @@
|
|||||||
|
package uebung05.logistics.material;
|
||||||
|
|
||||||
|
import uebung05.logistics.quantities.IntUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The BulletBelts class represents a unit of measurement for 7.62 bullets.
|
||||||
|
* It is a singleton class, meaning only one instance of the class can exist at a time.
|
||||||
|
*
|
||||||
|
* @author Nikolaus Köberlein
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public class BulletBelts implements IntUnit {
|
||||||
|
|
||||||
|
public static BulletBelts INSTANCE;
|
||||||
|
|
||||||
|
private BulletBelts() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the singleton instance of the BulletBelts class
|
||||||
|
*
|
||||||
|
* @return The singleton instance of the BulletBelts class
|
||||||
|
*/
|
||||||
|
public static BulletBelts getINSTANCE() {
|
||||||
|
if (INSTANCE == null) {
|
||||||
|
INSTANCE = new BulletBelts();
|
||||||
|
}
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a string representation of the BulletBelts object
|
||||||
|
*
|
||||||
|
* @return A string representation of the BulletBelts object
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "belts of 7.62 bullets";
|
||||||
|
}
|
||||||
|
}
|
39
src/uebung05/logistics/material/Grease.java
Executable file
39
src/uebung05/logistics/material/Grease.java
Executable file
@@ -0,0 +1,39 @@
|
|||||||
|
package uebung05.logistics.material;
|
||||||
|
|
||||||
|
import uebung05.logistics.quantities.IntUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Grease class represents a unit of measurement for grease.
|
||||||
|
* It is a singleton class, meaning only one instance of the class can exist at a time.
|
||||||
|
*
|
||||||
|
* @author Nikolaus Köberlein
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public class Grease implements IntUnit {
|
||||||
|
|
||||||
|
public static Grease INSTANCE;
|
||||||
|
|
||||||
|
private Grease() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the singleton instance of the Grease class
|
||||||
|
*
|
||||||
|
* @return The singleton instance of the Grease class
|
||||||
|
*/
|
||||||
|
public static Grease getINSTANCE() {
|
||||||
|
if (INSTANCE == null) {
|
||||||
|
INSTANCE = new Grease();
|
||||||
|
}
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a string representation of the Grease object
|
||||||
|
*
|
||||||
|
* @return A string representation of the Grease object
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "units of grease";
|
||||||
|
}
|
||||||
|
}
|
39
src/uebung05/logistics/material/LiterDiesel.java
Executable file
39
src/uebung05/logistics/material/LiterDiesel.java
Executable file
@@ -0,0 +1,39 @@
|
|||||||
|
package uebung05.logistics.material;
|
||||||
|
|
||||||
|
import uebung05.logistics.quantities.FloatUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The LiterDiesel class represents a unit of measurement for diesel fuel.
|
||||||
|
* It is a singleton class, meaning only one instance of the class can exist at a time.
|
||||||
|
*
|
||||||
|
* @author Nikolaus Köberlein
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public class LiterDiesel implements FloatUnit {
|
||||||
|
|
||||||
|
public static LiterDiesel INSTANCE;
|
||||||
|
|
||||||
|
private LiterDiesel() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the singleton instance of the LiterDiesel class
|
||||||
|
*
|
||||||
|
* @return The singleton instance of the LiterDiesel class
|
||||||
|
*/
|
||||||
|
public static LiterDiesel getINSTANCE() {
|
||||||
|
if (INSTANCE == null) {
|
||||||
|
INSTANCE = new LiterDiesel();
|
||||||
|
}
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a string representation of the LiterDiesel object
|
||||||
|
*
|
||||||
|
* @return A string representation of the LiterDiesel object
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "liters of diesel";
|
||||||
|
}
|
||||||
|
}
|
39
src/uebung05/logistics/material/MetGallonsKerosene.java
Executable file
39
src/uebung05/logistics/material/MetGallonsKerosene.java
Executable file
@@ -0,0 +1,39 @@
|
|||||||
|
package uebung05.logistics.material;
|
||||||
|
|
||||||
|
import uebung05.logistics.quantities.FloatUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The MetGallonsKerosene class represents a unit of measurement for kerosene.
|
||||||
|
* It is a singleton class, meaning only one instance of the class can exist at a time.
|
||||||
|
*
|
||||||
|
* @author Nikolaus Köberlein
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public class MetGallonsKerosene implements FloatUnit {
|
||||||
|
|
||||||
|
public static MetGallonsKerosene INSTANCE;
|
||||||
|
|
||||||
|
private MetGallonsKerosene() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the singleton instance of the MetGallonsKerosene class
|
||||||
|
*
|
||||||
|
* @return The singleton instance of the MetGallonsKerosene class
|
||||||
|
*/
|
||||||
|
public static MetGallonsKerosene getINSTANCE() {
|
||||||
|
if (INSTANCE == null) {
|
||||||
|
INSTANCE = new MetGallonsKerosene();
|
||||||
|
}
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a string representation of the MetGallonsKerosene object
|
||||||
|
*
|
||||||
|
* @return A string representation of the MetGallonsKerosene object
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "met gallons of kerosene";
|
||||||
|
}
|
||||||
|
}
|
39
src/uebung05/logistics/material/Oil.java
Executable file
39
src/uebung05/logistics/material/Oil.java
Executable file
@@ -0,0 +1,39 @@
|
|||||||
|
package uebung05.logistics.material;
|
||||||
|
|
||||||
|
import uebung05.logistics.quantities.IntUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Oil class represents a unit of measurement for oil.
|
||||||
|
* It is a singleton class, meaning only one instance of the class can exist at a time.
|
||||||
|
*
|
||||||
|
* @author Nikolaus Köberlein
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public class Oil implements IntUnit {
|
||||||
|
|
||||||
|
public static Oil INSTANCE;
|
||||||
|
|
||||||
|
private Oil() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the singleton instance of the Oil class
|
||||||
|
*
|
||||||
|
* @return The singleton instance of the Oil class
|
||||||
|
*/
|
||||||
|
public static Oil getINSTANCE() {
|
||||||
|
if (INSTANCE == null) {
|
||||||
|
INSTANCE = new Oil();
|
||||||
|
}
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a string representation of the Oil object
|
||||||
|
*
|
||||||
|
* @return A string representation of the Oil object
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "units of oil";
|
||||||
|
}
|
||||||
|
}
|
58
src/uebung05/logistics/material/RocketPods.java
Executable file
58
src/uebung05/logistics/material/RocketPods.java
Executable file
@@ -0,0 +1,58 @@
|
|||||||
|
package uebung05.logistics.material;
|
||||||
|
|
||||||
|
import uebung05.logistics.quantities.IntUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The RocketPods class represents a unit of measurement for 70mm rocket pods.
|
||||||
|
* It is a singleton class, meaning only one instance of the class can exist at a time.
|
||||||
|
*
|
||||||
|
* @author Nikolaus Köberlein
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public class RocketPods implements IntUnit {
|
||||||
|
|
||||||
|
public static RocketPods INSTANCE;
|
||||||
|
|
||||||
|
private RocketPods() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the singleton instance of the RocketPods class
|
||||||
|
*
|
||||||
|
* @return The singleton instance of the RocketPods class
|
||||||
|
*/
|
||||||
|
public static RocketPods getINSTANCE() {
|
||||||
|
if (INSTANCE == null) {
|
||||||
|
INSTANCE = new RocketPods();
|
||||||
|
}
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a string representation of the RocketPods object
|
||||||
|
*
|
||||||
|
* @return A string representation of the RocketPods object
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "pods of 70mm rockets";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the integer value of the RocketPods object
|
||||||
|
*
|
||||||
|
* @param value The integer value to set
|
||||||
|
*/
|
||||||
|
public void setValue(int value) {
|
||||||
|
// Implementation goes here
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the integer value of the RocketPods object
|
||||||
|
*
|
||||||
|
* @return The integer value of the RocketPods object
|
||||||
|
*/
|
||||||
|
public int getValue() {
|
||||||
|
// Implementation goes here
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user