diff --git a/Assignment_001/readme.md b/Assignment_001/readme.md index c0e8f35..839ab73 100644 --- a/Assignment_001/readme.md +++ b/Assignment_001/readme.md @@ -1,6 +1,6 @@ # String in Großbuchstaben umwandeln - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_001/solution/readme.md b/Assignment_001/solution/readme.md deleted file mode 100644 index 1a6e1d0..0000000 --- a/Assignment_001/solution/readme.md +++ /dev/null @@ -1,4 +0,0 @@ -# Lösung: String in Großbuchstaben umwandeln - - -[pr2.auffrischung.grossmacher](../../solutions/src/main/java/pr2/auffrischung/grossmacher) diff --git a/Assignment_002/readme.md b/Assignment_002/readme.md index 7420abe..a22f5cc 100644 --- a/Assignment_002/readme.md +++ b/Assignment_002/readme.md @@ -1,6 +1,6 @@ # Labeled Break - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_002/solution/readme.md b/Assignment_002/solution/readme.md deleted file mode 100644 index 6102863..0000000 --- a/Assignment_002/solution/readme.md +++ /dev/null @@ -1,4 +0,0 @@ -# Lösung: Labeled Break - - -[pr2.auffrischung.labeled_break](../../solutions/src/main/java/pr2/auffrischung/labeled_break) diff --git a/Assignment_003/readme.md b/Assignment_003/readme.md index 111aa6f..4c9dc8f 100644 --- a/Assignment_003/readme.md +++ b/Assignment_003/readme.md @@ -1,6 +1,6 @@ # Passwortbewertung - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_003/solution/readme.md b/Assignment_003/solution/readme.md deleted file mode 100644 index 6b1732b..0000000 --- a/Assignment_003/solution/readme.md +++ /dev/null @@ -1,4 +0,0 @@ -# Lösung: Passwortbewertung - - -[pr2.auffrischung.password](../../solutions/src/main/java/pr2/auffrischung/password) diff --git a/Assignment_004/readme.md b/Assignment_004/readme.md index 017d58e..4420c01 100644 --- a/Assignment_004/readme.md +++ b/Assignment_004/readme.md @@ -1,6 +1,6 @@ # printf mit Formatstring - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_004/solution/readme.md b/Assignment_004/solution/readme.md deleted file mode 100644 index bcda0d2..0000000 --- a/Assignment_004/solution/readme.md +++ /dev/null @@ -1,4 +0,0 @@ -# Lösung: printf mit Formatstring - - -[pr2.auffrischung.printf](../../solutions/src/main/java/pr2/auffrischung/printf) diff --git a/Assignment_005/readme.md b/Assignment_005/readme.md index f2f3aff..08f0abc 100644 --- a/Assignment_005/readme.md +++ b/Assignment_005/readme.md @@ -1,6 +1,6 @@ # Maximum in einem Array suchen - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_005/solution/readme.md b/Assignment_005/solution/readme.md deleted file mode 100644 index 9cd6fa7..0000000 --- a/Assignment_005/solution/readme.md +++ /dev/null @@ -1,4 +0,0 @@ -# Lösung: Maximum in einem Array suchen - - -[pr2.auffrischung.suchemax](../../solutions/src/main/java/pr2/auffrischung/suchemax) diff --git a/Assignment_006/readme.md b/Assignment_006/readme.md index c0d17f4..6af5467 100644 --- a/Assignment_006/readme.md +++ b/Assignment_006/readme.md @@ -1,6 +1,6 @@ # Taschenrechner - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_006/solution/readme.md b/Assignment_006/solution/readme.md deleted file mode 100644 index 7e37500..0000000 --- a/Assignment_006/solution/readme.md +++ /dev/null @@ -1,4 +0,0 @@ -# Lösung: Taschenrechner - - -[pr2.auffrischung.taschenrechner](../../solutions/src/main/java/pr2/auffrischung/taschenrechner) diff --git a/Assignment_008/readme.md b/Assignment_008/readme.md index 6ebf666..372621e 100644 --- a/Assignment_008/readme.md +++ b/Assignment_008/readme.md @@ -1,6 +1,6 @@ # Java-Coding-Standard anwenden - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_008/solution/readme.md b/Assignment_008/solution/readme.md deleted file mode 100644 index 8a75113..0000000 --- a/Assignment_008/solution/readme.md +++ /dev/null @@ -1,4 +0,0 @@ -# Lösung: Java-Coding-Standard anwenden - - -[pr2.intro.coding_standard](../../solutions/src/main/java/pr2/intro/coding_standard/) diff --git a/Assignment_009/readme.md b/Assignment_009/readme.md index 76708d6..dbecb82 100644 --- a/Assignment_009/readme.md +++ b/Assignment_009/readme.md @@ -1,6 +1,6 @@ # JavaDoc schreiben - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_009/solution/readme.md b/Assignment_009/solution/readme.md deleted file mode 100644 index e10eb89..0000000 --- a/Assignment_009/solution/readme.md +++ /dev/null @@ -1,4 +0,0 @@ -# Lösung: JavaDoc schreiben - - -[pr2.intro.javadoc](../../solutions/src/main/java/pr2/intro/javadoc/) diff --git a/Assignment_010/readme.md b/Assignment_010/readme.md index 95ad1e7..fea3bdf 100644 --- a/Assignment_010/readme.md +++ b/Assignment_010/readme.md @@ -1,6 +1,6 @@ # Klasse mit JUnit testen - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_010/solution/readme.md b/Assignment_010/solution/readme.md deleted file mode 100644 index ee12743..0000000 --- a/Assignment_010/solution/readme.md +++ /dev/null @@ -1,4 +0,0 @@ -# Lösung: Klasse mit JUnit testen - - -Gehen Sie in das Paket [pr2.intro.junit_faculty](../../solutions/src/main/java/pr2/intro/junit_faculty/). diff --git a/Assignment_011/readme.md b/Assignment_011/readme.md index d844161..b7f8a78 100644 --- a/Assignment_011/readme.md +++ b/Assignment_011/readme.md @@ -1,6 +1,6 @@ # Information-Hiding einer Klasse verbessern - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_011/solution/readme.md b/Assignment_011/solution/readme.md deleted file mode 100644 index 7584997..0000000 --- a/Assignment_011/solution/readme.md +++ /dev/null @@ -1,4 +0,0 @@ -# Lösung: Information-Hiding einer Klasse verbessern - - -[pr2.strukturierung.information_hiding](../../solutions/src/main/java/pr2/strukturierung/information_hiding/) diff --git a/Assignment_012/readme.md b/Assignment_012/readme.md index 0227074..6e5a2a5 100644 --- a/Assignment_012/readme.md +++ b/Assignment_012/readme.md @@ -1,6 +1,6 @@ # Vorhandene Bibliotheken als JAR einbinden - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_013/readme.md b/Assignment_013/readme.md index f21903c..79fe752 100644 --- a/Assignment_013/readme.md +++ b/Assignment_013/readme.md @@ -1,6 +1,6 @@ # Final anwenden - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_013/solution/readme.md b/Assignment_013/solution/readme.md deleted file mode 100644 index 9e13845..0000000 --- a/Assignment_013/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Final anwenden - -Musterlösung: - -[pr2.vererbung.finals](../../solutions/src/main/java/pr2/vererbung/finals/) diff --git a/Assignment_014/readme.md b/Assignment_014/readme.md index 17c92a8..6c1fe29 100644 --- a/Assignment_014/readme.md +++ b/Assignment_014/readme.md @@ -1,6 +1,6 @@ # Figur und Rechteck - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_014/solution/readme.md b/Assignment_014/solution/readme.md deleted file mode 100644 index f130d3d..0000000 --- a/Assignment_014/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Figur und Rechteck - -Musterlösung: - -[pr2.vererbung.geometrie1](../../solutions/src/main/java/pr2/vererbung/geometrie1/) diff --git a/Assignment_015/readme.md b/Assignment_015/readme.md index 6978e31..9093646 100644 --- a/Assignment_015/readme.md +++ b/Assignment_015/readme.md @@ -1,6 +1,6 @@ # Figur erweitern - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_015/solution/readme.md b/Assignment_015/solution/readme.md deleted file mode 100644 index e69cd4f..0000000 --- a/Assignment_015/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Figur erweitern - -Musterlösung: - -[pr2.vererbung.geometrie2](../../solutions/src/main/java/pr2/vererbung/geometrie2/) diff --git a/Assignment_016/readme.md b/Assignment_016/readme.md index cfd3b3e..5336ef6 100644 --- a/Assignment_016/readme.md +++ b/Assignment_016/readme.md @@ -1,6 +1,6 @@ # Figur noch einmal erweitern - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_016/solution/readme.md b/Assignment_016/solution/readme.md deleted file mode 100644 index d5886dd..0000000 --- a/Assignment_016/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Figur noch einmal erweitern - -Musterlösung: - -[pr2.vererbung.geometrie3](../../solutions/src/main/java/pr2/vererbung/geometrie3/) diff --git a/Assignment_017/readme.md b/Assignment_017/readme.md index 6687177..1024e29 100644 --- a/Assignment_017/readme.md +++ b/Assignment_017/readme.md @@ -1,6 +1,6 @@ # Konstruktoren schreiben - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_017/solution/readme.md b/Assignment_017/solution/readme.md deleted file mode 100644 index 38818c2..0000000 --- a/Assignment_017/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Konstruktoren schreiben - -Musterlösung: - -[pr2.vererbung.konstruktoren](../../solutions/src/main/java/pr2/vererbung/konstruktoren/) diff --git a/Assignment_018/readme.md b/Assignment_018/readme.md index bf2bbfc..08afb8e 100644 --- a/Assignment_018/readme.md +++ b/Assignment_018/readme.md @@ -1,6 +1,6 @@ # Polymorphie einsetzen - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_018/solution/readme.md b/Assignment_018/solution/readme.md deleted file mode 100644 index 3dcb152..0000000 --- a/Assignment_018/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Polymorphie einsetzen - -Musterlösung: - -[pr2.vererbung.polymorphie](../../solutions/src/main/java/pr2/vererbung/polymorphie/) diff --git a/Assignment_019/readme.md b/Assignment_019/readme.md index daca5a6..2cf5db3 100644 --- a/Assignment_019/readme.md +++ b/Assignment_019/readme.md @@ -1,6 +1,6 @@ # Singleton - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_019/solution/readme.md b/Assignment_019/solution/readme.md deleted file mode 100644 index 080acca..0000000 --- a/Assignment_019/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Singleton - -Musterlösung: - -[pr2.vererbung.singleton_einfach](../../solutions/src/main/java/pr2/vererbung/singleton_einfach/) diff --git a/Assignment_020/readme.md b/Assignment_020/readme.md index 04dbfbb..7654cf1 100644 --- a/Assignment_020/readme.md +++ b/Assignment_020/readme.md @@ -1,6 +1,6 @@ # Statische Methoden und Attribute - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_020/solution/readme.md b/Assignment_020/solution/readme.md deleted file mode 100644 index 8638c64..0000000 --- a/Assignment_020/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Statische Methoden und Attribute - -Musterlösung: - -[pr2.vererbung.statics](../../solutions/src/main/java/pr2/vererbung/statics/) diff --git a/Assignment_021/readme.md b/Assignment_021/readme.md index e40d58a..1353992 100644 --- a/Assignment_021/readme.md +++ b/Assignment_021/readme.md @@ -1,6 +1,6 @@ # Methode überladen - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_021/solution/readme.md b/Assignment_021/solution/readme.md deleted file mode 100644 index 5106e98..0000000 --- a/Assignment_021/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Methode überladen - -Musterlösung: - -[pr2.vererbung.ueberladen_summe](../../solutions/src/main/java/pr2/vererbung/ueberladen_summe) diff --git a/Assignment_022/readme.md b/Assignment_022/readme.md index 3a2b327..9ab12f4 100644 --- a/Assignment_022/readme.md +++ b/Assignment_022/readme.md @@ -1,6 +1,6 @@ # Methoden überschreiben - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_022/solution/readme.md b/Assignment_022/solution/readme.md deleted file mode 100644 index 02ce09a..0000000 --- a/Assignment_022/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Methoden überschreiben - -Musterlösung: - -[pr2.vererbung.ueberschreiben_lebewesen](../../solutions/src/main/java/pr2/vererbung/ueberschreiben_lebewesen/) diff --git a/Assignment_023/readme.md b/Assignment_023/readme.md index 65eeccd..3d2af88 100644 --- a/Assignment_023/readme.md +++ b/Assignment_023/readme.md @@ -1,6 +1,6 @@ # Varag-Methode schreiben - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_023/solution/readme.md b/Assignment_023/solution/readme.md deleted file mode 100644 index 6eb5caf..0000000 --- a/Assignment_023/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Varag-Methode schreiben - -Musterlösung: - -[pr2.vererbung.vararg_summe](../../solutions/src/main/java/pr2/vererbung/vararg_summe/) diff --git a/Assignment_024/readme.md b/Assignment_024/readme.md index 77bc4c2..745ac9a 100644 --- a/Assignment_024/readme.md +++ b/Assignment_024/readme.md @@ -1,6 +1,6 @@ # Vererbung von Figuren - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_024/solution/readme.md b/Assignment_024/solution/readme.md deleted file mode 100644 index aa8e532..0000000 --- a/Assignment_024/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Vererbung von Figuren - -Musterlösung: - -[pr2.vererbung.vererbung_geometrie](../../solutions/src/main/java/pr2/vererbung/vererbung_geometrie/) diff --git a/Assignment_025/readme.md b/Assignment_025/readme.md index 26438f1..1690a2b 100644 --- a/Assignment_025/readme.md +++ b/Assignment_025/readme.md @@ -1,6 +1,6 @@ # Abstrakte Klassen - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_025/solution/readme.md b/Assignment_025/solution/readme.md deleted file mode 100644 index 9132f53..0000000 --- a/Assignment_025/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Abstrakte Klassen - -Musterlösung: - -[pr2.interfaces.abstrakte_klassen_s](../../solutions/src/main/java/pr2/interfaces/abstrakte_klassen_s/) diff --git a/Assignment_026/readme.md b/Assignment_026/readme.md index 884e97b..2accb71 100644 --- a/Assignment_026/readme.md +++ b/Assignment_026/readme.md @@ -1,6 +1,6 @@ # Abstrakte Klasse - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_026/solution/readme.md b/Assignment_026/solution/readme.md deleted file mode 100644 index 9d09e79..0000000 --- a/Assignment_026/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Abstrakte Klasse - -Musterlösung: - -[pr2.interfaces.abstrakt_form](../../solutions/src/main/java/pr2/interfaces/abstrakt_form/) diff --git a/Assignment_027/readme.md b/Assignment_027/readme.md index 2ba9fad..0b8c9d2 100644 --- a/Assignment_027/readme.md +++ b/Assignment_027/readme.md @@ -1,6 +1,6 @@ # Comparable implementieren - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_027/solution/readme.md b/Assignment_027/solution/readme.md deleted file mode 100644 index 10a088c..0000000 --- a/Assignment_027/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Comparable implementieren - -Musterlösung: - -[pr2.interfaces.comparable_student](../../solutions/src/main/java/pr2/interfaces/abstrakte_klassen_s/) diff --git a/Assignment_028/readme.md b/Assignment_028/readme.md index 31ce6ae..d696e9d 100644 --- a/Assignment_028/readme.md +++ b/Assignment_028/readme.md @@ -1,6 +1,6 @@ # Interface Stack entwerfen - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_028/solution/readme.md b/Assignment_028/solution/readme.md deleted file mode 100644 index 18e1cff..0000000 --- a/Assignment_028/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Interface Stack entwerfen - -Musterlösung: - -[pr2.interfaces.stack](../../solutions/src/main/java/pr2/interfaces/stack/) diff --git a/Assignment_029/readme.md b/Assignment_029/readme.md index 2502b85..99b9a04 100644 --- a/Assignment_029/readme.md +++ b/Assignment_029/readme.md @@ -1,6 +1,6 @@ # Interface: Uebersetzer - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_029/solution/readme.md b/Assignment_029/solution/readme.md deleted file mode 100644 index bc67dee..0000000 --- a/Assignment_029/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Interface: Uebersetzer - -Musterlösung: - -[pr2.interfaces.uebersetzer](../../solutions/src/main/java/pr2/interfaces/uebersetzer/) diff --git a/Assignment_030/readme.md b/Assignment_030/readme.md index e100004..f09f6ff 100644 --- a/Assignment_030/readme.md +++ b/Assignment_030/readme.md @@ -1,6 +1,6 @@ # Interfaces anwenden und entwerfen - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_030/solution/readme.md b/Assignment_030/solution/readme.md deleted file mode 100644 index d93d652..0000000 --- a/Assignment_030/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Interfaces anwenden und entwerfen - -Musterlösung: - -[pr2.interfaces.interfaces_s](../../solutions/src/main/java/pr2/interfaces/interfaces_s/) diff --git a/Assignment_031/readme.md b/Assignment_031/readme.md index ef2d45a..9ff8980 100644 --- a/Assignment_031/readme.md +++ b/Assignment_031/readme.md @@ -1,6 +1,6 @@ # Deep-Copy mit `clone()` - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_031/solution/readme.md b/Assignment_031/solution/readme.md deleted file mode 100644 index e4f05e2..0000000 --- a/Assignment_031/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Deep-Copy mit `clone()` - -Musterlösung: - -[pr2.object.clone_alien](../../solutions/src/main/java/pr2/object/clone_alien/) diff --git a/Assignment_032/readme.md b/Assignment_032/readme.md index 2e17591..09f72f2 100644 --- a/Assignment_032/readme.md +++ b/Assignment_032/readme.md @@ -1,6 +1,6 @@ # Clone - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_032/solution/readme.md b/Assignment_032/solution/readme.md deleted file mode 100644 index 9dc85a1..0000000 --- a/Assignment_032/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Clone - -Musterlösung: - -[pr2.object.clone_person](../../solutions/src/main/java/pr2/object/clone_person) diff --git a/Assignment_033/readme.md b/Assignment_033/readme.md index f625e78..36462b4 100644 --- a/Assignment_033/readme.md +++ b/Assignment_033/readme.md @@ -1,6 +1,6 @@ # `equals()` und `hashCode()` implementieren und nutzen - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_033/solution/readme.md b/Assignment_033/solution/readme.md deleted file mode 100644 index ce0c7ab..0000000 --- a/Assignment_033/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: `equals()` und `hashCode()` implementieren und nutzen - -Musterlösung: - -[pr2.object.equals_hashcode](../../solutions/src/main/java/pr2/object/equals_hashcode/) diff --git a/Assignment_034/readme.md b/Assignment_034/readme.md index 43f9c30..401e331 100644 --- a/Assignment_034/readme.md +++ b/Assignment_034/readme.md @@ -1,6 +1,6 @@ # equals und hashCode - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_034/solution/readme.md b/Assignment_034/solution/readme.md deleted file mode 100644 index 7d94bc2..0000000 --- a/Assignment_034/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: equals und hashCode - -Musterlösung: - -[pr2.object.equals_person](../../solutions/src/main/java/pr2/object/equals_person) diff --git a/Assignment_035/readme.md b/Assignment_035/readme.md index 0111d61..75b878f 100644 --- a/Assignment_035/readme.md +++ b/Assignment_035/readme.md @@ -1,6 +1,6 @@ # `toString()`-Methode implementieren - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_035/solution/readme.md b/Assignment_035/solution/readme.md deleted file mode 100644 index 2073e97..0000000 --- a/Assignment_035/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: `toString()`-Methode implementieren - -Musterlösung: - -[pr2.object.tostring](../../solutions/src/main/java/pr2/object/tostring/). diff --git a/Assignment_036/readme.md b/Assignment_036/readme.md index cb5b83e..d532b34 100644 --- a/Assignment_036/readme.md +++ b/Assignment_036/readme.md @@ -1,6 +1,6 @@ # Optimierung bei Integer - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_036/solution/readme.md b/Assignment_036/solution/readme.md deleted file mode 100644 index 82555df..0000000 --- a/Assignment_036/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Optimierung bei Integer - -Musterlösung: - -[pr2.object.wrapper_boxsearch](../../solutions/src/main/java/pr2/object/wrapper_boxsearch/). diff --git a/Assignment_037/readme.md b/Assignment_037/readme.md index d19bc5e..e194821 100644 --- a/Assignment_037/readme.md +++ b/Assignment_037/readme.md @@ -1,6 +1,6 @@ # Methoden der Wrapper-Klassen - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_037/solution/readme.md b/Assignment_037/solution/readme.md deleted file mode 100644 index 13bf079..0000000 --- a/Assignment_037/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Methoden der Wrapper-Klassen - -Musterlösung: - -[pr2.object.wrapper_umwandler](../../solutions/src/main/java/pr2/object/wrapper_umwandler/). diff --git a/Assignment_038/readme.md b/Assignment_038/readme.md index 2814b59..dc5f618 100644 --- a/Assignment_038/readme.md +++ b/Assignment_038/readme.md @@ -1,6 +1,6 @@ # Eigene Enumeration schreiben und verwenden - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_038/solution/readme.md b/Assignment_038/solution/readme.md deleted file mode 100644 index b1d9f1c..0000000 --- a/Assignment_038/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Eigene Enumeration schreiben und verwenden - -Musterlösung: - -[pr2.enums.eigene](../../solutions/src/main/java/pr2/enums/eigene_enumeration/) diff --git a/Assignment_039/readme.md b/Assignment_039/readme.md index ae60187..d4eea00 100644 --- a/Assignment_039/readme.md +++ b/Assignment_039/readme.md @@ -1,6 +1,6 @@ # Enumeration schreiben - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_039/solution/readme.md b/Assignment_039/solution/readme.md deleted file mode 100644 index 9255964..0000000 --- a/Assignment_039/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Enumeration schreiben - -Musterlösung: - -[pr2.enums.filme](../../solutions/src/main/java/pr2/enums/filme/) diff --git a/Assignment_040/readme.md b/Assignment_040/readme.md index 4dd2117..31aaeb8 100644 --- a/Assignment_040/readme.md +++ b/Assignment_040/readme.md @@ -1,6 +1,6 @@ # Singleton-Eigenschaft von Enumerationen - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_040/solution/readme.md b/Assignment_040/solution/readme.md deleted file mode 100644 index e4f7fe2..0000000 --- a/Assignment_040/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Singleton-Eigenschaft von Enumerationen - -Musterlösung: - -[pr2.enums.singleton](../../solutions/src/main/java/pr2/enums/singleton/) diff --git a/Assignment_041/readme.md b/Assignment_041/readme.md index 1cf70b7..ab5618e 100644 --- a/Assignment_041/readme.md +++ b/Assignment_041/readme.md @@ -1,6 +1,6 @@ # Eine vorhandene Enumeration nutzen - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_041/solution/readme.md b/Assignment_041/solution/readme.md deleted file mode 100644 index ceb9257..0000000 --- a/Assignment_041/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Eine vorhandene Enumeration nutzen - -Musterlösung: - -[pr2.enums.verwenden](../../solutions/src/main/java/pr2/enums/verwenden/) diff --git a/Assignment_042/readme.md b/Assignment_042/readme.md index 6d0fa55..564b2e9 100644 --- a/Assignment_042/readme.md +++ b/Assignment_042/readme.md @@ -1,6 +1,6 @@ # Assignment: Stein, Papier, Schere, Echse, Spock - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_042/solution/readme.md b/Assignment_042/solution/readme.md deleted file mode 100644 index 9c45825..0000000 --- a/Assignment_042/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Stein, Papier, Schere, Echse, Spock - -Musterlösung: - -[pr2.enums.schnick](../../solutions/src/main/java/pr2/enums/schnick). diff --git a/Assignment_043/readme.md b/Assignment_043/readme.md index 0fd2f31..899741d 100644 --- a/Assignment_043/readme.md +++ b/Assignment_043/readme.md @@ -1,6 +1,6 @@ # Ausnahmen testen - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_043/solution/readme.md b/Assignment_043/solution/readme.md deleted file mode 100644 index a03a8f2..0000000 --- a/Assignment_043/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Ausnahmen testen - -Musterlösung: - -[pr2.exceptions.ausnahmen_testen](../../solutions/src/main/java/pr2/exceptions/ausnahmen_testen/) diff --git a/Assignment_044/readme.md b/Assignment_044/readme.md index 1b4045f..049b139 100644 --- a/Assignment_044/readme.md +++ b/Assignment_044/readme.md @@ -1,6 +1,6 @@ # Eigene Ausnahmen schreiben und an entsprechender Stelle werfen - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_044/solution/readme.md b/Assignment_044/solution/readme.md deleted file mode 100644 index 7cc2d13..0000000 --- a/Assignment_044/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Eigene Ausnahmen schreiben und an entsprechender Stelle werfen - -Musterlösung: - -[pr2.exceptions.eigene_ausnahme](../../solutions/src/main/java/pr2/exceptions/eigene_ausnahme/) diff --git a/Assignment_045/readme.md b/Assignment_045/readme.md index 31751af..d12a438 100644 --- a/Assignment_045/readme.md +++ b/Assignment_045/readme.md @@ -1,6 +1,6 @@ # Eigene Exception schreiben - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_045/solution/readme.md b/Assignment_045/solution/readme.md deleted file mode 100644 index 9c7ad33..0000000 --- a/Assignment_045/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Eigene Exception schreiben - -Musterlösung: - -[pr2.exceptions.fakultaet](../../solutions/src/main/java/pr2/exceptions/fakultaet/) diff --git a/Assignment_046/readme.md b/Assignment_046/readme.md index 43a5a44..d913501 100644 --- a/Assignment_046/readme.md +++ b/Assignment_046/readme.md @@ -1,6 +1,6 @@ # Handle-or-Declare-Regel anwenden - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_046/solution/readme.md b/Assignment_046/solution/readme.md deleted file mode 100644 index ca9a0e4..0000000 --- a/Assignment_046/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Handle-or-Declare-Regel anwenden - -Musterlösung: - -[pr2.exceptions.handle_or_declare](../../solutions/src/main/java/pr2/exceptions/handle_or_declare/) diff --git a/Assignment_047/readme.md b/Assignment_047/readme.md index ddd3f7b..04395e1 100644 --- a/Assignment_047/readme.md +++ b/Assignment_047/readme.md @@ -1,6 +1,6 @@ # Ausnahmen mit `try` und `catch` behandeln. - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_047/solution/readme.md b/Assignment_047/solution/readme.md deleted file mode 100644 index f28d42d..0000000 --- a/Assignment_047/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Ausnahmen mit `try` und `catch` behandeln. - -Musterlösung: - -[pr2.exceptions.try_catch](../../solutions/src/main/java/pr2/exceptions/try_catch/) diff --git a/Assignment_048/readme.md b/Assignment_048/readme.md index aa7964e..2ac07e0 100644 --- a/Assignment_048/readme.md +++ b/Assignment_048/readme.md @@ -1,6 +1,6 @@ # `BufferedReader` zum zeilenweisen Lesen einsetzen - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_048/solution/readme.md b/Assignment_048/solution/readme.md deleted file mode 100644 index 1bca802..0000000 --- a/Assignment_048/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: `BufferedReader` zum zeilenweisen Lesen einsetzen - -Musterlösung: - -[pr2.io.buffered_reader](../../solutions/src/main/java/pr2/io/buffered_reader/) diff --git a/Assignment_049/readme.md b/Assignment_049/readme.md index e2cd1bc..d829315 100644 --- a/Assignment_049/readme.md +++ b/Assignment_049/readme.md @@ -1,6 +1,6 @@ # DataOutputStream - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_049/solution/readme.md b/Assignment_049/solution/readme.md deleted file mode 100644 index 07be1ad..0000000 --- a/Assignment_049/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: DataOutputStream - -Musterlösung: - -[pr2.io.datainputoutput_1](../../solutions/src/main/java/pr2/io/datainputoutput_1/) diff --git a/Assignment_050/readme.md b/Assignment_050/readme.md index c3462ab..d84aad5 100644 --- a/Assignment_050/readme.md +++ b/Assignment_050/readme.md @@ -1,6 +1,6 @@ # DataOutputStream durch Serialisierung ersetzen - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_050/solution/readme.md b/Assignment_050/solution/readme.md deleted file mode 100644 index be1a62c..0000000 --- a/Assignment_050/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: DataOutputStream durch Serialisierung ersetzen - -Musterlösung: - -[pr2.io.datainputoutput_2](../../solutions/src/main/java/pr2/io/datainputoutput_2/) diff --git a/Assignment_051/readme.md b/Assignment_051/readme.md index 4494895..51e40f6 100644 --- a/Assignment_051/readme.md +++ b/Assignment_051/readme.md @@ -1,6 +1,6 @@ # Daten mit `DataOutputStream` und `DataInputStream` verarbeiten - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_051/solution/readme.md b/Assignment_051/solution/readme.md deleted file mode 100644 index a168ce3..0000000 --- a/Assignment_051/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Daten mit `DataOutputStream` und `DataInputStream` verarbeiten - -Musterlösung: - -[pr2.io.data_output](../../solutions/src/main/java/pr2/io/data_output/) diff --git a/Assignment_052/readme.md b/Assignment_052/readme.md index fbf66bf..9aeca1c 100644 --- a/Assignment_052/readme.md +++ b/Assignment_052/readme.md @@ -1,6 +1,6 @@ # Daten mit einem `InputStream` lesen - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_052/solution/readme.md b/Assignment_052/solution/readme.md deleted file mode 100644 index b3a3f87..0000000 --- a/Assignment_052/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Daten mit einem `InputStream` lesen - -Musterlösung: - -[pr2.io.datei_lesen](../../solutions/src/main/java/pr2/io/datei_lesen/) diff --git a/Assignment_053/readme.md b/Assignment_053/readme.md index 3a203b0..dd5e32c 100644 --- a/Assignment_053/readme.md +++ b/Assignment_053/readme.md @@ -1,6 +1,6 @@ # Daten mit einem `OutputStream` schreiben - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_053/solution/readme.md b/Assignment_053/solution/readme.md deleted file mode 100644 index 0d7f08a..0000000 --- a/Assignment_053/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Daten mit einem `OutputStream` schreiben - -Musterlösung: - -[pr2.io.datei_schreiben](../../solutions/src/main/java/pr2/io/datei_schreiben/) diff --git a/Assignment_054/readme.md b/Assignment_054/readme.md index 197a28b..2e2bc0e 100644 --- a/Assignment_054/readme.md +++ b/Assignment_054/readme.md @@ -1,6 +1,6 @@ # Filesystem-Abstraktion mit `File` - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_054/solution/readme.md b/Assignment_054/solution/readme.md deleted file mode 100644 index 0256bc8..0000000 --- a/Assignment_054/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Filesystem-Abstraktion mit `File` - -Musterlösung: - -[pr2.io.file](../../solutions/src/main/java/pr2/io/file/) diff --git a/Assignment_055/readme.md b/Assignment_055/readme.md index 3647021..9d979e5 100644 --- a/Assignment_055/readme.md +++ b/Assignment_055/readme.md @@ -1,6 +1,6 @@ # Fileattribute lesen - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_055/solution/readme.md b/Assignment_055/solution/readme.md deleted file mode 100644 index d3f3fce..0000000 --- a/Assignment_055/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Fileattribute lesen - -Musterlösung: - -[pr2.io.filetest](../../solutions/src/main/java/pr2/io/filetest/) diff --git a/Assignment_056/readme.md b/Assignment_056/readme.md index dc2236b..3b00e54 100644 --- a/Assignment_056/readme.md +++ b/Assignment_056/readme.md @@ -1,6 +1,6 @@ # `FilterReader` - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_056/solution/readme.md b/Assignment_056/solution/readme.md deleted file mode 100644 index 8f59e95..0000000 --- a/Assignment_056/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: `FilterReader` - -Musterlösung: - -[pr2.io.filter](../../solutions/src/main/java/pr2/io/filter/) diff --git a/Assignment_057/readme.md b/Assignment_057/readme.md index ef04af0..21f4697 100644 --- a/Assignment_057/readme.md +++ b/Assignment_057/readme.md @@ -1,6 +1,6 @@ # Konsolen Input/Output - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_057/solution/readme.md b/Assignment_057/solution/readme.md deleted file mode 100644 index 3ed3b1f..0000000 --- a/Assignment_057/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Konsolen Input/Output - -Musterlösung: - -[pr2.io.konsole](../../solutions/src/main/java/pr2/io/konsole/) diff --git a/Assignment_058/readme.md b/Assignment_058/readme.md index 9c367d4..d6ef785 100644 --- a/Assignment_058/readme.md +++ b/Assignment_058/readme.md @@ -1,6 +1,6 @@ # Zeilen einer Textdatei zählen - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_058/solution/readme.md b/Assignment_058/solution/readme.md deleted file mode 100644 index 92e14d5..0000000 --- a/Assignment_058/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Zeilen einer Textdatei zählen - -Musterlösung: - -[pr2.io.linecounter](../../solutions/src/main/java/pr2/io/linecounter/) diff --git a/Assignment_059/readme.md b/Assignment_059/readme.md index 322a646..b0cb70e 100644 --- a/Assignment_059/readme.md +++ b/Assignment_059/readme.md @@ -1,6 +1,6 @@ # `RandomAccessFile` - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_059/solution/readme.md b/Assignment_059/solution/readme.md deleted file mode 100644 index ccacd2b..0000000 --- a/Assignment_059/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: `RandomAccessFile` - -Musterlösung: - -[pr2.io.random_access](../../solutions/src/main/java/pr2/io/random_access/) diff --git a/Assignment_060/readme.md b/Assignment_060/readme.md index 5a9bf72..5541ca7 100644 --- a/Assignment_060/readme.md +++ b/Assignment_060/readme.md @@ -1,6 +1,6 @@ # `Reader` verwenden - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_060/solution/readme.md b/Assignment_060/solution/readme.md deleted file mode 100644 index abbde00..0000000 --- a/Assignment_060/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: `Reader` verwenden - -Musterlösung: - -[pr2.io.reader_writer](../../solutions/src/main/java/pr2/io/reader_writer/) diff --git a/Assignment_061/readme.md b/Assignment_061/readme.md index bc07e18..b9c1786 100644 --- a/Assignment_061/readme.md +++ b/Assignment_061/readme.md @@ -1,6 +1,6 @@ # Rot13-Verschlüsselung - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_061/solution/readme.md b/Assignment_061/solution/readme.md deleted file mode 100644 index afe6008..0000000 --- a/Assignment_061/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Rot13-Verschlüsselung - -Musterlösung: - -[pr2.io.rot13](../../solutions/src/main/java/pr2/io/rot13/) diff --git a/Assignment_062/readme.md b/Assignment_062/readme.md index 92bb47f..745f39a 100644 --- a/Assignment_062/readme.md +++ b/Assignment_062/readme.md @@ -1,6 +1,6 @@ # Datei zerhacken - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_062/solution/readme.md b/Assignment_062/solution/readme.md deleted file mode 100644 index ddb622a..0000000 --- a/Assignment_062/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Datei zerhacken - -Musterlösung: - -[pr2.io.scrambler](../../solutions/src/main/java/pr2/io/scrambler/) diff --git a/Assignment_063/readme.md b/Assignment_063/readme.md index 4f9438f..97c85a3 100644 --- a/Assignment_063/readme.md +++ b/Assignment_063/readme.md @@ -1,6 +1,6 @@ # Serialisierung - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_063/solution/readme.md b/Assignment_063/solution/readme.md deleted file mode 100644 index a523dfa..0000000 --- a/Assignment_063/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Serialisierung - -Musterlösung: - -[pr2.io.serialisierung](../../solutions/src/main/java/pr2/io/serialisierung/) diff --git a/Assignment_064/readme.md b/Assignment_064/readme.md index e2bf877..1863ef0 100644 --- a/Assignment_064/readme.md +++ b/Assignment_064/readme.md @@ -1,6 +1,6 @@ # Einen generischen Typ schreiben - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_064/solution/readme.md b/Assignment_064/solution/readme.md deleted file mode 100644 index 1a645c1..0000000 --- a/Assignment_064/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Einen generischen Typ schreiben - -Musterlösung: - -[pr2.generics.einfach](../../solutions/src/main/java/pr2/generics/einfach/) diff --git a/Assignment_065/readme.md b/Assignment_065/readme.md index 2deee4e..21a41de 100644 --- a/Assignment_065/readme.md +++ b/Assignment_065/readme.md @@ -1,6 +1,6 @@ # Generische Klasse Pair schreiben - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_065/solution/readme.md b/Assignment_065/solution/readme.md deleted file mode 100644 index e4303a8..0000000 --- a/Assignment_065/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Generische Klasse Pair schreiben - -Musterlösung: - -[pr2.generics.pair](../../solutions/src/main/java/pr2/generics/pair/) diff --git a/Assignment_066/readme.md b/Assignment_066/readme.md index 7937624..29c4869 100644 --- a/Assignment_066/readme.md +++ b/Assignment_066/readme.md @@ -1,6 +1,6 @@ # Generische Klasse Pair erweitern: NumberPair - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_066/solution/readme.md b/Assignment_066/solution/readme.md deleted file mode 100644 index da73c86..0000000 --- a/Assignment_066/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Generische Klasse Pair erweitern: NumberPair - -Musterlösung: - -[pr2.generics.number_pair](../../solutions/src/main/java/pr2/generics/number_pair/) diff --git a/Assignment_067/readme.md b/Assignment_067/readme.md index 98caebb..ddd4c2c 100644 --- a/Assignment_067/readme.md +++ b/Assignment_067/readme.md @@ -1,6 +1,6 @@ # Generische Klasse Pair erweitern: SamePair - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_067/solution/readme.md b/Assignment_067/solution/readme.md deleted file mode 100644 index a8c9b5c..0000000 --- a/Assignment_067/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Generische Klasse Pair erweitern: SamePair - -Musterlösung: - -[pr2.generics.same_pair](../../solutions/src/main/java/pr2/generics/same_pair/) diff --git a/Assignment_068/readme.md b/Assignment_068/readme.md index 11159a6..c774b7a 100644 --- a/Assignment_068/readme.md +++ b/Assignment_068/readme.md @@ -1,6 +1,6 @@ # PairList - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_068/solution/readme.md b/Assignment_068/solution/readme.md deleted file mode 100644 index 7a66bc8..0000000 --- a/Assignment_068/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: PairList - -Musterlösung: - -[pr2.generics.pairlist](../../solutions/src/main/java/pr2/generics/pairlist/) diff --git a/Assignment_069/readme.md b/Assignment_069/readme.md index 1a70ac6..c202e79 100644 --- a/Assignment_069/readme.md +++ b/Assignment_069/readme.md @@ -1,6 +1,6 @@ # Wildcard benutzen - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_069/solution/readme.md b/Assignment_069/solution/readme.md deleted file mode 100644 index 510b1f5..0000000 --- a/Assignment_069/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Wildcard benutzen - -Musterlösung: - -[pr2.generics.printer](../../solutions/src/main/java/pr2/generics/printer/) diff --git a/Assignment_070/readme.md b/Assignment_070/readme.md index 2e9893d..12c642c 100644 --- a/Assignment_070/readme.md +++ b/Assignment_070/readme.md @@ -1,6 +1,6 @@ # Generische Queue - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_070/solution/readme.md b/Assignment_070/solution/readme.md deleted file mode 100644 index 68a84e8..0000000 --- a/Assignment_070/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Generische Queue - -Musterlösung: - -[pr2.generics.queue](../../solutions/src/main/java/pr2/generics/queue/) diff --git a/Assignment_071/readme.md b/Assignment_071/readme.md index 584a648..25088c3 100644 --- a/Assignment_071/readme.md +++ b/Assignment_071/readme.md @@ -1,6 +1,6 @@ # `super` und `extends` einsetzen - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_071/solution/readme.md b/Assignment_071/solution/readme.md deleted file mode 100644 index 6321f6a..0000000 --- a/Assignment_071/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: `super` und `extends` einsetzen - -Musterlösung: - -[pr2.generics.super_extends](../../solutions/src/main/java/pr2/generics/super_extends/) diff --git a/Assignment_072/readme.md b/Assignment_072/readme.md index bf6be09..87ab60f 100644 --- a/Assignment_072/readme.md +++ b/Assignment_072/readme.md @@ -1,6 +1,6 @@ # Generischen Typ verwenden - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_072/solution/readme.md b/Assignment_072/solution/readme.md deleted file mode 100644 index d1c0905..0000000 --- a/Assignment_072/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Generischen Typ verwenden - -Musterlösung: - -[pr2.generics.verwenden](../../solutions/src/main/java/pr2/generics/verwenden/). diff --git a/Assignment_073/readme.md b/Assignment_073/readme.md index a351cdf..311d5b8 100644 --- a/Assignment_073/readme.md +++ b/Assignment_073/readme.md @@ -1,6 +1,6 @@ # Generische Typen zusammen mit Wildcards einsetzen - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_073/solution/readme.md b/Assignment_073/solution/readme.md deleted file mode 100644 index 3cd4d43..0000000 --- a/Assignment_073/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Generische Typen zusammen mit Wildcards einsetzen - -Musterlösung: - -[pr2.generics.wildcards](../../solutions/src/main/java/pr2/generics/wildcards/). diff --git a/Assignment_074/readme.md b/Assignment_074/readme.md index e037d19..9351d8f 100644 --- a/Assignment_074/readme.md +++ b/Assignment_074/readme.md @@ -1,6 +1,6 @@ # Anonyme Klasse schreiben - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_074/solution/readme.md b/Assignment_074/solution/readme.md deleted file mode 100644 index 6c6590c..0000000 --- a/Assignment_074/solution/readme.md +++ /dev/null @@ -1,6 +0,0 @@ -# Lösung: Anonyme Klasse schreiben - -Musterlösung: - -[pr2.lambda.anonymous](../../solutions/src/main/java/pr2/lambda/anonymous/). -va) diff --git a/Assignment_075/readme.md b/Assignment_075/readme.md index 4957e66..fbfbf93 100644 --- a/Assignment_075/readme.md +++ b/Assignment_075/readme.md @@ -1,6 +1,6 @@ # Eigene compare-Methode schreiben - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_075/solution/readme.md b/Assignment_075/solution/readme.md deleted file mode 100644 index 183c8af..0000000 --- a/Assignment_075/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Eigene compare-Methode schreiben - -Musterlösung: - -[pr2.lambda.array_sorter](../../solutions/src/main/java/pr2/lambda/array_sorter/) diff --git a/Assignment_076/readme.md b/Assignment_076/readme.md index 075bcf9..4c370e9 100644 --- a/Assignment_076/readme.md +++ b/Assignment_076/readme.md @@ -1,6 +1,6 @@ # Innere Klasse Beobachter - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_076/solution/readme.md b/Assignment_076/solution/readme.md deleted file mode 100644 index 657e078..0000000 --- a/Assignment_076/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Innere Klasse Beobachter - -Musterlösung: - -pr2.lambda.observer](../../solutions/src/main/java/pr2/lambda/observer/). diff --git a/Assignment_077/readme.md b/Assignment_077/readme.md index 4a72e78..239391b 100644 --- a/Assignment_077/readme.md +++ b/Assignment_077/readme.md @@ -1,6 +1,6 @@ # Callback mit anonymer Klasse realisieren - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_077/solution/readme.md b/Assignment_077/solution/readme.md deleted file mode 100644 index f3f2c66..0000000 --- a/Assignment_077/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Callback mit anonymer Klasse realisieren - -Musterlösung: - -[pr2.lambda.callback](../../solutions/src/main/java/pr2/lambda/callback/) diff --git a/Assignment_078/readme.md b/Assignment_078/readme.md index da32b09..62f488d 100644 --- a/Assignment_078/readme.md +++ b/Assignment_078/readme.md @@ -1,6 +1,6 @@ # Comparator als Lambda - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_078/solution/readme.md b/Assignment_078/solution/readme.md deleted file mode 100644 index 43f250d..0000000 --- a/Assignment_078/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Comparator als Lambda - -Musterlösung: - -[pr2.lambda.comparator](../../solutions/src/main/java/pr2/lambda/comparator/) diff --git a/Assignment_079/readme.md b/Assignment_079/readme.md index 3916f96..3599552 100644 --- a/Assignment_079/readme.md +++ b/Assignment_079/readme.md @@ -1,6 +1,6 @@ # Callback mit Lambda realisieren - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_079/solution/readme.md b/Assignment_079/solution/readme.md deleted file mode 100644 index dec56e3..0000000 --- a/Assignment_079/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Callback mit Lambda realisieren - -Musterlösung: - -[pr2.lambda.lambdas](../../solutions/src/main/java/pr2/lambda/lambdas/) diff --git a/Assignment_080/readme.md b/Assignment_080/readme.md index 0ef9cc9..6ac37c7 100644 --- a/Assignment_080/readme.md +++ b/Assignment_080/readme.md @@ -1,6 +1,6 @@ # Lokale Klasse schreiben - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_080/solution/readme.md b/Assignment_080/solution/readme.md deleted file mode 100644 index c7ab6e7..0000000 --- a/Assignment_080/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Lokale Klasse schreiben - -Musterlösung: - -[pr2.lambda.local](../../solutions/src/main/java/pr2/lambda/local/) diff --git a/Assignment_081/readme.md b/Assignment_081/readme.md index 1bb5de3..4181c4a 100644 --- a/Assignment_081/readme.md +++ b/Assignment_081/readme.md @@ -1,6 +1,6 @@ # MatrixSuche - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_081/solution/readme.md b/Assignment_081/solution/readme.md deleted file mode 100644 index e3b7c01..0000000 --- a/Assignment_081/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: MatrixSuche - -Musterlösung: - -[pr2.lambda.matrixsuche](../../solutions/src/main/java/pr2/lambda/matrixsuche/) diff --git a/Assignment_082/readme.md b/Assignment_082/readme.md index 9f77b27..4ed267c 100644 --- a/Assignment_082/readme.md +++ b/Assignment_082/readme.md @@ -1,6 +1,6 @@ # StringTransmogrifier - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_082/solution/readme.md b/Assignment_082/solution/readme.md deleted file mode 100644 index 8bf44e0..0000000 --- a/Assignment_082/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: StringTransmogrifier - -Musterlösung: - -[pr2.lambda.mogrifier_1](../../solutions/src/main/java/pr2/lambda/mogrifier_1/) diff --git a/Assignment_083/readme.md b/Assignment_083/readme.md index 2b68bbd..df69e87 100644 --- a/Assignment_083/readme.md +++ b/Assignment_083/readme.md @@ -1,6 +1,6 @@ # StringTransmogrifier erweitern - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_083/solution/readme.md b/Assignment_083/solution/readme.md deleted file mode 100644 index 9746d8f..0000000 --- a/Assignment_083/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: StringTransmogrifier erweitern - -Musterlösung: - -[pr2.lambda.mogrifier_2](../../solutions/src/main/java/pr2/lambda/mogrifier_2/) diff --git a/Assignment_084/readme.md b/Assignment_084/readme.md index 7cd3271..e4cc852 100644 --- a/Assignment_084/readme.md +++ b/Assignment_084/readme.md @@ -1,6 +1,6 @@ # Nonstatic Member Class - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_084/solution/readme.md b/Assignment_084/solution/readme.md deleted file mode 100644 index c993b1e..0000000 --- a/Assignment_084/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Nonstatic Member Class - -Musterlösung: - -[pr2.lambda.nonstatic](../../solutions/src/main/java/pr2/lambda/nonstatic/) diff --git a/Assignment_085/readme.md b/Assignment_085/readme.md index f8d84fc..976a1a4 100644 --- a/Assignment_085/readme.md +++ b/Assignment_085/readme.md @@ -1,6 +1,6 @@ # Static Member Class - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_085/solution/readme.md b/Assignment_085/solution/readme.md deleted file mode 100644 index 75f6291..0000000 --- a/Assignment_085/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Static Member Class - -Musterlösung: - -[pr2.lambda.static_member](../../solutions/src/main/java/pr2/lambda/static_member/) diff --git a/Assignment_086/readme.md b/Assignment_086/readme.md index 3371860..1d4b2ea 100644 --- a/Assignment_086/readme.md +++ b/Assignment_086/readme.md @@ -1,6 +1,6 @@ # Iterator schreiben - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_086/solution/readme.md b/Assignment_086/solution/readme.md deleted file mode 100644 index 2af19d3..0000000 --- a/Assignment_086/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Iterator schreiben - -Musterlösung: - -[pr2.collections.iterator](../../solutions/src/main/java/pr2/collections/iterator/) diff --git a/Assignment_087/readme.md b/Assignment_087/readme.md index 1af5096..0549724 100644 --- a/Assignment_087/readme.md +++ b/Assignment_087/readme.md @@ -1,6 +1,6 @@ # Mithilfe eines Iterators über Daten iterieren - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_087/solution/readme.md b/Assignment_087/solution/readme.md deleted file mode 100644 index a052299..0000000 --- a/Assignment_087/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Mithilfe eines Iterators über Daten iterieren - -Musterlösung: - -[pr2.collections.iterieren](../../solutions/src/main/java/pr2/collections/iterieren/) diff --git a/Assignment_088/readme.md b/Assignment_088/readme.md index 03fc5f4..4e42672 100644 --- a/Assignment_088/readme.md +++ b/Assignment_088/readme.md @@ -1,6 +1,6 @@ # Iterator programmieren - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_088/solution/readme.md b/Assignment_088/solution/readme.md deleted file mode 100644 index 85889cd..0000000 --- a/Assignment_088/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Iterator programmieren - -Musterlösung: - -[pr2.collections.list_iterator](../../solutions/src/main/java/pr2/collections/list_iterator/) diff --git a/Assignment_089/readme.md b/Assignment_089/readme.md index 48a6673..240203a 100644 --- a/Assignment_089/readme.md +++ b/Assignment_089/readme.md @@ -1,6 +1,6 @@ # `List` und dessen Implementierungen - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_089/solution/readme.md b/Assignment_089/solution/readme.md deleted file mode 100644 index 6157b4c..0000000 --- a/Assignment_089/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: `List` und dessen Implementierungen - -Musterlösung: - -[pr2.collections.list](../../solutions/src/main/java/pr2/collections/list/) diff --git a/Assignment_090/readme.md b/Assignment_090/readme.md index 6432de9..640f6cd 100644 --- a/Assignment_090/readme.md +++ b/Assignment_090/readme.md @@ -1,6 +1,6 @@ # `Map` verwenden - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_090/solution/readme.md b/Assignment_090/solution/readme.md deleted file mode 100644 index cd64cf7..0000000 --- a/Assignment_090/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: `Map` verwenden - -Musterlösung: - -[pr2.collections.map](../../solutions/src/main/java/pr2/collections/map/) diff --git a/Assignment_091/readme.md b/Assignment_091/readme.md index 45da4e9..1451721 100644 --- a/Assignment_091/readme.md +++ b/Assignment_091/readme.md @@ -1,6 +1,6 @@ # ReverserGeneric - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_091/solution/readme.md b/Assignment_091/solution/readme.md deleted file mode 100644 index 727c05e..0000000 --- a/Assignment_091/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: ReverserGeneric - -Musterlösung: - -[pr2.collections.reverser_generic](../../solutions/src/main/java/pr2/collections/reverser_generic/) diff --git a/Assignment_092/readme.md b/Assignment_092/readme.md index 6770802..5f56bc0 100644 --- a/Assignment_092/readme.md +++ b/Assignment_092/readme.md @@ -1,6 +1,6 @@ # Strings umgekehrt sortieren: Reverser - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_092/solution/readme.md b/Assignment_092/solution/readme.md deleted file mode 100644 index 297fa12..0000000 --- a/Assignment_092/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Strings umgekehrt sortieren: Reverser - -Musterlösung: - -[pr2.collections.reverser](../../solutions/src/main/java/pr2/collections/reverser/) diff --git a/Assignment_093/readme.md b/Assignment_093/readme.md index 8f28425..688a1a2 100644 --- a/Assignment_093/readme.md +++ b/Assignment_093/readme.md @@ -1,6 +1,6 @@ # `Set` und dessen Implementierungen - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_093/solution/readme.md b/Assignment_093/solution/readme.md deleted file mode 100644 index a7c6da7..0000000 --- a/Assignment_093/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: `Set` und dessen Implementierungen - -Musterlösung: - -[pr2.collections.set](../../solutions/src/main/java/pr2/collections/set/) diff --git a/Assignment_094/readme.md b/Assignment_094/readme.md index b094686..8a56cb3 100644 --- a/Assignment_094/readme.md +++ b/Assignment_094/readme.md @@ -1,6 +1,6 @@ # CommandLineSorter - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_094/solution/readme.md b/Assignment_094/solution/readme.md deleted file mode 100644 index 6c8a0cf..0000000 --- a/Assignment_094/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: CommandLineSorter - -Musterlösung: - -[pr2.collections.sorter_1](../../solutions/src/main/java/pr2/collections/sorter_1/) diff --git a/Assignment_095/readme.md b/Assignment_095/readme.md index 45b249d..3a41e46 100644 --- a/Assignment_095/readme.md +++ b/Assignment_095/readme.md @@ -1,6 +1,6 @@ # CommandLineSorter -- Version 2 - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_095/solution/readme.md b/Assignment_095/solution/readme.md deleted file mode 100644 index be55751..0000000 --- a/Assignment_095/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: CommandLineSorter -- Version 2 - -Musterlösung: - -[pr2.collections.sorter_2](../../solutions/src/main/java/pr2/collections/sorter_2/) diff --git a/Assignment_096/readme.md b/Assignment_096/readme.md index 9db1174..e1fcc93 100644 --- a/Assignment_096/readme.md +++ b/Assignment_096/readme.md @@ -1,6 +1,6 @@ # `Comparator` verwenden und Objekte sortieren - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_096/solution/readme.md b/Assignment_096/solution/readme.md deleted file mode 100644 index f543e35..0000000 --- a/Assignment_096/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: `Comparator` verwenden und Objekte sortieren - -Musterlösung: - -[pr2.collections.sortieren](../../solutions/src/main/java/pr2/collections/sortieren/) diff --git a/Assignment_097/readme.md b/Assignment_097/readme.md index 5cc4e93..ae66148 100644 --- a/Assignment_097/readme.md +++ b/Assignment_097/readme.md @@ -1,6 +1,6 @@ # Wörterbuchprogramm - [Musterlösung](solution/) + ## Lernziel diff --git a/Assignment_097/solution/readme.md b/Assignment_097/solution/readme.md deleted file mode 100644 index 8fa5708..0000000 --- a/Assignment_097/solution/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Lösung: Wörterbuchprogramm - -Musterlösung: - -[pr2.collections.woerterbuch](../../solutions/src/main/java/pr2/collections/woerterbuch/) diff --git a/readme.md b/readme.md index 4e9e152..ec879be 100644 --- a/readme.md +++ b/readme.md @@ -8,100 +8,100 @@ Hinweise zur nötigen Softwareausstattung finden Sie [hier](help/softwareausstat | # | Ausgabe | Thema | |----|---------------------------------------------------------------------------------------------|----------------| -| 1. | 14.03.2023 | [String in Großbuchstaben umwandeln](Assignment_001/readme.md) | -| 2. | 14.03.2023 | [Labeled Break](Assignment_002/readme.md) | -| 3. | 14.03.2023 | [Passwortbewertung](Assignment_003/readme.md) | -| 4. | 14.03.2023 | [printf mit Formatstring](Assignment_004/readme.md) | -| 5. | 14.03.2023 | [Maximum in einem Array suchen](Assignment_005/readme.md) | -| 6. | 14.03.2023 | [Taschenrechner](Assignment_006/readme.md) | -| 7. | 14.03.2023 | [Quine](Assignment_007/readme.md) | -| 8. | 20.03.2023 | [Java-Coding-Standard anwenden](Assignment_008/readme.md) | -| 9. | 20.03.2023 | [JavaDoc schreiben](Assignment_009/readme.md) | -| 10. | 20.03.2023 | [Klasse mit JUnit testen](Assignment_010/readme.md) | -| 11. | 20.03.2023 | [Information-Hiding einer Klasse verbessern](Assignment_011/readme.md) | -| 12. | 20.03.2023 | [Vorhandene Bibliotheken als JAR einbinden](Assignment_012/readme.md) | -| 13. | 24.03.2023 | [Final anwenden](Assignment_013/readme.md) | -| 14. | 24.03.2023 | [Figur und Rechteck](Assignment_014/readme.md) | -| 15. | 24.03.2023 | [Figur erweitern](Assignment_015/readme.md) | -| 16. | 24.03.2023 | [Figur noch einmal erweitern](Assignment_016/readme.md) | -| 17. | 24.03.2023 | [Konstruktoren schreiben](Assignment_017/readme.md) | -| 18. | 24.03.2023 | [Polymorphie einsetzen](Assignment_018/readme.md) | -| 19. | 24.03.2023 | [Singleton](Assignment_019/readme.md) | -| 20. | 24.03.2023 | [Statische Methoden und Attribute](Assignment_020/readme.md) | -| 21. | 24.03.2023 | [Methode überladen](Assignment_021/readme.md) | -| 22. | 24.03.2023 | [Methoden überschreiben](Assignment_022/readme.md) | -| 23. | 24.03.2023 | [Varag-Methode schreiben](Assignment_023/readme.md) | -| 24. | 24.03.2023 | [Vererbung von Figuren](Assignment_024/readme.md) | -| 25. | 11.04.2023 | [Abstrakte Klassen](Assignment_025/readme.md) | -| 26. | 11.04.2023 | [Abstrakte Klasse](Assignment_026/readme.md) | -| 27. | 11.04.2023 | [Comparable implementieren](Assignment_027/readme.md) | -| 28. | 11.04.2023 | [Interface Stack entwerfen](Assignment_028/readme.md) | -| 29. | 11.04.2023 | [Interface: Uebersetzer](Assignment_029/readme.md) | -| 30. | 11.04.2023 | [Interfaces anwenden und entwerfen](Assignment_030/readme.md) | -| 31. | 20.04.2023 | [Deep-Copy mit `clone()`](Assignment_031/readme.md) | -| 32. | 20.04.2023 | [Clone](Assignment_032/readme.md) | -| 33. | 20.04.2023 | [`equals()` und `hashCode()` implementieren und nutzen](Assignment_033/readme.md) | -| 34. | 20.04.2023 | [equals und hashCode](Assignment_034/readme.md) | -| 35. | 20.04.2023 | [`toString()`-Methode implementieren](Assignment_035/readme.md) | -| 36. | 20.04.2023 | [Optimierung bei Integer](Assignment_036/readme.md) | -| 37. | 20.04.2023 | [Methoden der Wrapper-Klassen](Assignment_037/readme.md) | -| 38. | 20.04.2023 | [Eigene Enumeration schreiben und verwenden](Assignment_038/readme.md) | -| 39. | 20.04.2023 | [Enumeration schreiben](Assignment_039/readme.md) | -| 40. | 20.04.2023 | [Singleton-Eigenschaft von Enumerationen](Assignment_040/readme.md) | -| 41. | 20.04.2023 | [Eine vorhandene Enumeration nutzen](Assignment_041/readme.md) | -| 42. | 20.04.2023 | [Stein, Papier, Schere, Echse, Spock](Assignment_042/readme.md) | -| 43. | 27.04.2023 | [Ausnahmen testen](Assignment_043/readme.md) | -| 44. | 27.04.2023 | [Eigene Ausnahmen schreiben und an entsprechender Stelle werfen](Assignment_044/readme.md) | -| 45. | 27.04.2023 | [Eigene Exception schreiben](Assignment_045/readme.md) | -| 46. | 27.04.2023 | [Handle-or-Declare-Regel anwenden](Assignment_046/readme.md) | -| 47. | 27.04.2023 | [Ausnahmen mit `try` und `catch` behandeln.](Assignment_047/readme.md) | -| 48. | 04.05.2023 | [`BufferedReader` zum zeilenweisen Lesen einsetzen](Assignment_048/readme.md) | -| 49. | 04.05.2023 | [DataOutputStream](Assignment_049/readme.md) | -| 50. | 04.05.2023 | [DataOutputStream durch Serialisierung ersetzen](Assignment_050/readme.md) | -| 51. | 04.05.2023 | [Daten mit `DataOutputStream` und `DataInputStream` verarbeiten](Assignment_051/readme.md) | -| 52. | 04.05.2023 | [Daten mit einem `InputStream` lesen](Assignment_052/readme.md) | -| 53. | 04.05.2023 | [Daten mit einem `OutputStream` schreiben](Assignment_053/readme.md) | -| 54. | 04.05.2023 | [Filesystem-Abstraktion mit `File`](Assignment_054/readme.md) | -| 55. | 04.05.2023 | [Fileattribute lesen](Assignment_055/readme.md) | -| 56. | 04.05.2023 | [`FilterReader`](Assignment_056/readme.md) | -| 57. | 04.05.2023 | [Konsolen Input/Output](Assignment_057/readme.md) | -| 58. | 04.05.2023 | [Zeilen einer Textdatei zählen](Assignment_058/readme.md) | -| 59. | 04.05.2023 | [`RandomAccessFile`](Assignment_059/readme.md) | -| 60. | 04.05.2023 | [`Reader` verwenden](Assignment_060/readme.md) | -| 61. | 04.05.2023 | [Rot13-Verschlüsselung](Assignment_061/readme.md) | -| 62. | 04.05.2023 | [Datei zerhacken](Assignment_062/readme.md) | -| 63. | 04.05.2023 | [Serialisierung](Assignment_063/readme.md) | -| 64. | 22.05.2023 | [Einen generischen Typ schreiben](Assignment_064/readme.md) | -| 65. | 22.05.2023 | [Generische Klasse Pair schreiben](Assignment_065/readme.md) | -| 66. | 22.05.2023 | [Generische Klasse Pair erweitern: NumberPair](Assignment_066/readme.md) | -| 67. | 22.05.2023 | [Generische Klasse Pair erweitern: SamePair](Assignment_067/readme.md) | -| 68. | 22.05.2023 | [PairList](Assignment_068/readme.md) | -| 69. | 22.05.2023 | [Wildcard benutzen](Assignment_069/readme.md) | -| 70. | 22.05.2023 | [Generische Queue](Assignment_070/readme.md) | -| 71. | 22.05.2023 | [`super` und `extends` einsetzen](Assignment_071/readme.md) | -| 72. | 22.05.2023 | [Generischen Typ verwenden](Assignment_072/readme.md) | -| 73. | 22.05.2023 | [Generische Typen zusammen mit Wildcards einsetzen](Assignment_073/readme.md) | -| 74. | 05.06.2023 | [Anonyme Klasse schreiben](Assignment_074/readme.md) | -| 75. | 05.06.2023 | [Eigene compare-Methode schreiben](Assignment_075/readme.md) | -| 76. | 05.06.2023 | [Innere Klasse Beobachter](Assignment_076/readme.md) | -| 77. | 05.06.2023 | [Callback mit anonymer Klasse realisieren](Assignment_077/readme.md) | -| 78. | 05.06.2023 | [Comparator als Lambda](Assignment_078/readme.md) | -| 79. | 05.06.2023 | [Callback mit Lambda realisieren](Assignment_079/readme.md) | -| 80. | 05.06.2023 | [Lokale Klasse schreiben](Assignment_080/readme.md) | -| 81. | 05.06.2023 | [MatrixSuche](Assignment_081/readme.md) | -| 82. | 05.06.2023 | [StringTransmogrifier](Assignment_082/readme.md) | -| 83. | 05.06.2023 | [StringTransmogrifier erweitern](Assignment_083/readme.md) | -| 84. | 05.06.2023 | [Nonstatic Member Class](Assignment_084/readme.md) | -| 85. | 05.06.2023 | [Static Member Class](Assignment_085/readme.md) | -| 86. | 12.06.2023 | [Iterator schreiben](Assignment_086/readme.md) | -| 87. | 12.06.2023 | [Mithilfe eines Iterators über Daten iterieren](Assignment_087/readme.md) | -| 88. | 12.06.2023 | [Iterator programmieren](Assignment_088/readme.md) | -| 89. | 12.06.2023 | [`List` und dessen Implementierungen](Assignment_089/readme.md) | -| 90. | 12.06.2023 | [`Map` verwenden](Assignment_090/readme.md) | -| 91. | 12.06.2023 | [ReverserGeneric](Assignment_091/readme.md) | -| 92. | 12.06.2023 | [Strings umgekehrt sortieren: Reverser](Assignment_092/readme.md) | -| 93. | 12.06.2023 | [`Set` und dessen Implementierungen](Assignment_093/readme.md) | -| 94. | 12.06.2023 | [CommandLineSorter](Assignment_094/readme.md) | -| 95. | 12.06.2023 | [CommandLineSorter -- Version 2](Assignment_095/readme.md) | -| 96. | 12.06.2023 | [`Comparator` verwenden und Objekte sortieren](Assignment_096/readme.md) | -| 97. | 12.06.2023 | [Wörterbuchprogramm](Assignment_097/readme.md) | +| 1. | n/a | [String in Großbuchstaben umwandeln](Assignment_001/readme.md) | +| 2. | n/a | [Labeled Break](Assignment_002/readme.md) | +| 3. | n/a | [Passwortbewertung](Assignment_003/readme.md) | +| 4. | n/a | [printf mit Formatstring](Assignment_004/readme.md) | +| 5. | n/a | [Maximum in einem Array suchen](Assignment_005/readme.md) | +| 6. | n/a | [Taschenrechner](Assignment_006/readme.md) | +| 7. | n/a | [Quine](Assignment_007/readme.md) | +| 8. | n/a | [Java-Coding-Standard anwenden](Assignment_008/readme.md) | +| 9. | n/a | [JavaDoc schreiben](Assignment_009/readme.md) | +| 10. | n/a | [Klasse mit JUnit testen](Assignment_010/readme.md) | +| 11. | n/a | [Information-Hiding einer Klasse verbessern](Assignment_011/readme.md) | +| 12. | n/a | [Vorhandene Bibliotheken als JAR einbinden](Assignment_012/readme.md) | +| 13. | n/a | [Final anwenden](Assignment_013/readme.md) | +| 14. | n/a | [Figur und Rechteck](Assignment_014/readme.md) | +| 15. | n/a | [Figur erweitern](Assignment_015/readme.md) | +| 16. | n/a | [Figur noch einmal erweitern](Assignment_016/readme.md) | +| 17. | n/a | [Konstruktoren schreiben](Assignment_017/readme.md) | +| 18. | n/a | [Polymorphie einsetzen](Assignment_018/readme.md) | +| 19. | n/a | [Singleton](Assignment_019/readme.md) | +| 20. | n/a | [Statische Methoden und Attribute](Assignment_020/readme.md) | +| 21. | n/a | [Methode überladen](Assignment_021/readme.md) | +| 22. | n/a | [Methoden überschreiben](Assignment_022/readme.md) | +| 23. | n/a | [Varag-Methode schreiben](Assignment_023/readme.md) | +| 24. | n/a | [Vererbung von Figuren](Assignment_024/readme.md) | +| 25. | n/a | [Abstrakte Klassen](Assignment_025/readme.md) | +| 26. | n/a | [Abstrakte Klasse](Assignment_026/readme.md) | +| 27. | n/a | [Comparable implementieren](Assignment_027/readme.md) | +| 28. | n/a | [Interface Stack entwerfen](Assignment_028/readme.md) | +| 29. | n/a | [Interface: Uebersetzer](Assignment_029/readme.md) | +| 30. | n/a | [Interfaces anwenden und entwerfen](Assignment_030/readme.md) | +| 31. | n/a | [Deep-Copy mit `clone()`](Assignment_031/readme.md) | +| 32. | n/a | [Clone](Assignment_032/readme.md) | +| 33. | n/a | [`equals()` und `hashCode()` implementieren und nutzen](Assignment_033/readme.md) | +| 34. | n/a | [equals und hashCode](Assignment_034/readme.md) | +| 35. | n/a | [`toString()`-Methode implementieren](Assignment_035/readme.md) | +| 36. | n/a | [Optimierung bei Integer](Assignment_036/readme.md) | +| 37. | n/a | [Methoden der Wrapper-Klassen](Assignment_037/readme.md) | +| 38. | n/a | [Eigene Enumeration schreiben und verwenden](Assignment_038/readme.md) | +| 39. | n/a | [Enumeration schreiben](Assignment_039/readme.md) | +| 40. | n/a | [Singleton-Eigenschaft von Enumerationen](Assignment_040/readme.md) | +| 41. | n/a | [Eine vorhandene Enumeration nutzen](Assignment_041/readme.md) | +| 42. | n/a | [Stein, Papier, Schere, Echse, Spock](Assignment_042/readme.md) | +| 43. | n/a | [Ausnahmen testen](Assignment_043/readme.md) | +| 44. | n/a | [Eigene Ausnahmen schreiben und an entsprechender Stelle werfen](Assignment_044/readme.md) | +| 45. | n/a | [Eigene Exception schreiben](Assignment_045/readme.md) | +| 46. | n/a | [Handle-or-Declare-Regel anwenden](Assignment_046/readme.md) | +| 47. | n/a | [Ausnahmen mit `try` und `catch` behandeln.](Assignment_047/readme.md) | +| 48. | n/a | [`BufferedReader` zum zeilenweisen Lesen einsetzen](Assignment_048/readme.md) | +| 49. | n/a | [DataOutputStream](Assignment_049/readme.md) | +| 50. | n/a | [DataOutputStream durch Serialisierung ersetzen](Assignment_050/readme.md) | +| 51. | n/a | [Daten mit `DataOutputStream` und `DataInputStream` verarbeiten](Assignment_051/readme.md) | +| 52. | n/a | [Daten mit einem `InputStream` lesen](Assignment_052/readme.md) | +| 53. | n/a | [Daten mit einem `OutputStream` schreiben](Assignment_053/readme.md) | +| 54. | n/a | [Filesystem-Abstraktion mit `File`](Assignment_054/readme.md) | +| 55. | n/a | [Fileattribute lesen](Assignment_055/readme.md) | +| 56. | n/a | [`FilterReader`](Assignment_056/readme.md) | +| 57. | n/a | [Konsolen Input/Output](Assignment_057/readme.md) | +| 58. | n/a | [Zeilen einer Textdatei zählen](Assignment_058/readme.md) | +| 59. | n/a | [`RandomAccessFile`](Assignment_059/readme.md) | +| 60. | n/a | [`Reader` verwenden](Assignment_060/readme.md) | +| 61. | n/a | [Rot13-Verschlüsselung](Assignment_061/readme.md) | +| 62. | n/a | [Datei zerhacken](Assignment_062/readme.md) | +| 63. | n/a | [Serialisierung](Assignment_063/readme.md) | +| 64. | n/a | [Einen generischen Typ schreiben](Assignment_064/readme.md) | +| 65. | n/a | [Generische Klasse Pair schreiben](Assignment_065/readme.md) | +| 66. | n/a | [Generische Klasse Pair erweitern: NumberPair](Assignment_066/readme.md) | +| 67. | n/a | [Generische Klasse Pair erweitern: SamePair](Assignment_067/readme.md) | +| 68. | n/a | [PairList](Assignment_068/readme.md) | +| 69. | n/a | [Wildcard benutzen](Assignment_069/readme.md) | +| 70. | n/a | [Generische Queue](Assignment_070/readme.md) | +| 71. | n/a | [`super` und `extends` einsetzen](Assignment_071/readme.md) | +| 72. | n/a | [Generischen Typ verwenden](Assignment_072/readme.md) | +| 73. | n/a | [Generische Typen zusammen mit Wildcards einsetzen](Assignment_073/readme.md) | +| 74. | n/a | [Anonyme Klasse schreiben](Assignment_074/readme.md) | +| 75. | n/a | [Eigene compare-Methode schreiben](Assignment_075/readme.md) | +| 76. | n/a | [Innere Klasse Beobachter](Assignment_076/readme.md) | +| 77. | n/a | [Callback mit anonymer Klasse realisieren](Assignment_077/readme.md) | +| 78. | n/a | [Comparator als Lambda](Assignment_078/readme.md) | +| 79. | n/a | [Callback mit Lambda realisieren](Assignment_079/readme.md) | +| 80. | n/a | [Lokale Klasse schreiben](Assignment_080/readme.md) | +| 81. | n/a | [MatrixSuche](Assignment_081/readme.md) | +| 82. | n/a | [StringTransmogrifier](Assignment_082/readme.md) | +| 83. | n/a | [StringTransmogrifier erweitern](Assignment_083/readme.md) | +| 84. | n/a | [Nonstatic Member Class](Assignment_084/readme.md) | +| 85. | n/a | [Static Member Class](Assignment_085/readme.md) | +| 86. | n/a | [Iterator schreiben](Assignment_086/readme.md) | +| 87. | n/a | [Mithilfe eines Iterators über Daten iterieren](Assignment_087/readme.md) | +| 88. | n/a | [Iterator programmieren](Assignment_088/readme.md) | +| 89. | n/a | [`List` und dessen Implementierungen](Assignment_089/readme.md) | +| 90. | n/a | [`Map` verwenden](Assignment_090/readme.md) | +| 91. | n/a | [ReverserGeneric](Assignment_091/readme.md) | +| 92. | n/a | [Strings umgekehrt sortieren: Reverser](Assignment_092/readme.md) | +| 93. | n/a | [`Set` und dessen Implementierungen](Assignment_093/readme.md) | +| 94. | n/a | [CommandLineSorter](Assignment_094/readme.md) | +| 95. | n/a | [CommandLineSorter -- Version 2](Assignment_095/readme.md) | +| 96. | n/a | [`Comparator` verwenden und Objekte sortieren](Assignment_096/readme.md) | +| 97. | n/a | [Wörterbuchprogramm](Assignment_097/readme.md) | diff --git a/solutions/src/main/java/pr2/auffrischung/grossmacher/Grossmacher.java b/solutions/src/main/java/pr2/auffrischung/grossmacher/Grossmacher.java deleted file mode 100644 index 2ed9101..0000000 --- a/solutions/src/main/java/pr2/auffrischung/grossmacher/Grossmacher.java +++ /dev/null @@ -1,16 +0,0 @@ -package pr2.auffrischung.grossmacher; - -public class Grossmacher { - - public static void main(String[] args) { - if (args.length < 1) { - System.err.println("Kein Argument angeben!"); - return; - } - - String ergebnis = args[0].toUpperCase(); - - System.out.printf("Ergebnis: %s%n", ergebnis); - System.out.printf("Zeichen : %d%n", ergebnis.length()); - } -} diff --git a/solutions/src/main/java/pr2/auffrischung/labeled_break/ArraySucher.java b/solutions/src/main/java/pr2/auffrischung/labeled_break/ArraySucher.java deleted file mode 100644 index 82e1359..0000000 --- a/solutions/src/main/java/pr2/auffrischung/labeled_break/ArraySucher.java +++ /dev/null @@ -1,27 +0,0 @@ -package pr2.auffrischung.labeled_break; - -public class ArraySucher { - - /** - * Sucht das erste Element, dass nicht 0 ist. - * - * @param array das Array in dem gesucht werden soll - * @return {@code true}, wenn ein Element gefunden wird, - * andernfalls {@code false}. - */ - public boolean suche(int[][] array) { - boolean found = false; - - outer: - for (int[] is : array) { - for (int i : is) { - if (i != 0) { - found = true; - break outer; - } - } - } - - return found; - } -} diff --git a/solutions/src/main/java/pr2/auffrischung/password/PasswortChecker.java b/solutions/src/main/java/pr2/auffrischung/password/PasswortChecker.java deleted file mode 100644 index 147b8be..0000000 --- a/solutions/src/main/java/pr2/auffrischung/password/PasswortChecker.java +++ /dev/null @@ -1,53 +0,0 @@ -package pr2.auffrischung.password; - -public class PasswortChecker { - - private static final char[] NUMBERS = "1234567890".toCharArray(); - private static final char[] LOWERCASE - = "abcdefghijklmnopqrstuvwxyz".toCharArray(); - private static final char[] UPPERCASE - = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray(); - private static final char[] SPECIAL_CHARS = "!%()\"".toCharArray(); - - private static boolean contains(String string, char[] chars) { - for (char c : chars) { - if (string.indexOf(c) >= 0) { - return true; - } - } - return false; - } - - public static int checkPassword(String password) { - int points = 0; - - if (password.length() >= 8) { - points++; - } - - if (contains(password, NUMBERS) - && (contains(password, LOWERCASE) - || contains(password, UPPERCASE))) { - points++; - } - - if (contains(password, SPECIAL_CHARS)) { - points++; - } - - if (contains(password, LOWERCASE) && contains(password, UPPERCASE)) { - points++; - } - - return points; - } - - public static void main(String[] args) { - System.out.println(checkPassword("mutti")); - System.out.println(checkPassword("Mutti")); - System.out.println(checkPassword("mutti123")); - System.out.println(checkPassword("Mutti123")); - System.out.println(checkPassword("Mutti123!%")); - System.out.println(checkPassword("1234")); - } -} diff --git a/solutions/src/main/java/pr2/auffrischung/printf/DoubleFormatter.java b/solutions/src/main/java/pr2/auffrischung/printf/DoubleFormatter.java deleted file mode 100644 index 788b1a6..0000000 --- a/solutions/src/main/java/pr2/auffrischung/printf/DoubleFormatter.java +++ /dev/null @@ -1,18 +0,0 @@ -package pr2.auffrischung.printf; - -public class DoubleFormatter { - - public static void printDouble(double d) { - System.out.printf("%.3f%n", d); - } - - public static void main(String[] args) { - printDouble(1.0); - printDouble(10.1); - printDouble(2.01); - printDouble(2.001); - printDouble(2.0001); - printDouble(2.0004); - printDouble(2.0005); - } -} diff --git a/solutions/src/main/java/pr2/auffrischung/suchemax/GroessteZahl.java b/solutions/src/main/java/pr2/auffrischung/suchemax/GroessteZahl.java deleted file mode 100644 index 92f89b7..0000000 --- a/solutions/src/main/java/pr2/auffrischung/suchemax/GroessteZahl.java +++ /dev/null @@ -1,21 +0,0 @@ -package pr2.auffrischung.suchemax; - -public class GroessteZahl { - - public int sucheMax(int[] zahlen) { - int max = Integer.MIN_VALUE; - - for (int zahl : zahlen) { - max = Math.max(max, zahl); - } - - return max; - } - - public static void main(String[] args) { - GroessteZahl g = new GroessteZahl(); - System.out.println(g.sucheMax(new int[] {1, 5, 8, 2, 0})); - System.out.println(g.sucheMax(new int[] {-1, -5, -8, -2, -20})); - System.out.println(g.sucheMax(new int[] {10000, -10000, 1, 2, 33})); - } -} diff --git a/solutions/src/main/java/pr2/auffrischung/taschenrechner/Taschenrechner.java b/solutions/src/main/java/pr2/auffrischung/taschenrechner/Taschenrechner.java deleted file mode 100644 index ecba9e2..0000000 --- a/solutions/src/main/java/pr2/auffrischung/taschenrechner/Taschenrechner.java +++ /dev/null @@ -1,25 +0,0 @@ -package pr2.auffrischung.taschenrechner; - -public class Taschenrechner { - - public double rechne(double o1, char op, double o2) { - return switch (op) { - case '+' -> o1 + o2; - case '-' -> o1 - o2; - case '*' -> o1 * o2; - case '/' -> o1 / o2; - case '^' -> Math.pow(o1, o2); - default -> Double.NaN; - }; -// return 0.0; - } - - public static void main(String[] args) { - Taschenrechner t = new Taschenrechner(); - System.out.println(t.rechne(1, '+', 2)); - System.out.println(t.rechne(1, '-', 2)); - System.out.println(t.rechne(2, '*', 2)); - System.out.println(t.rechne(4, '/', 2)); - System.out.println(t.rechne(2, '^', 32)); - } -} diff --git a/solutions/src/main/java/pr2/collections/iterator/SimpleStack.java b/solutions/src/main/java/pr2/collections/iterator/SimpleStack.java deleted file mode 100644 index e52bfe6..0000000 --- a/solutions/src/main/java/pr2/collections/iterator/SimpleStack.java +++ /dev/null @@ -1,80 +0,0 @@ -package pr2.collections.iterator; - -import java.util.Iterator; - -/** - * Eine einfache, naive Stack Implementierung. - * - * @param Typ, der gespeichert werden soll. - */ -public class SimpleStack implements Iterable { - - - // Variablen sind nicht private wegen Zugriff durch den Iterator - T[] stack; - - int pos; - - /** - * Legt einen neuen Stack mit der gegebenen Größe an. - * - * @param size Größe des Stacks. - */ - @SuppressWarnings("unchecked") - public SimpleStack(int size) { - stack = (T[]) new Object[size]; - pos = 0; - } - - /** - * Fügt dem Stack ein neues Element hinzu. - * - * @param o Element, das hinzugefügt werden soll. - */ - public void push(T o) { - stack[pos++] = o; - } - - /** - * Holt das oberste Element und entfernt es. - * - * @return das oberste Element - */ - public T pop() { - return stack[--pos]; - } - - /** - * Gibt das oberste Element zurück, ohne es zu entfernen. - * - * @return das oberste Element - */ - public T peek() { - return stack[pos - 1]; - } - - - /** - * Erzeugt einen Iterator. - * - * @return Iterator - * @see java.lang.Iterable#iterator() - */ - @Override - public Iterator iterator() { - return new Iterator() { - - int iteratorPos = pos - 1; - - @Override - public boolean hasNext() { - return iteratorPos >= 0; - } - - @Override - public T next() { - return stack[iteratorPos--]; - } - }; - } -} diff --git a/solutions/src/main/java/pr2/collections/iterator/test/SimpleStackTest.java b/solutions/src/main/java/pr2/collections/iterator/test/SimpleStackTest.java deleted file mode 100644 index 79ce559..0000000 --- a/solutions/src/main/java/pr2/collections/iterator/test/SimpleStackTest.java +++ /dev/null @@ -1,86 +0,0 @@ -package pr2.collections.iterator.test; - -import org.junit.jupiter.api.Test; -import pr2.collections.iterator.SimpleStack; - -import java.util.Iterator; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * Test für den Stack. - */ -public class SimpleStackTest { - - /** - * Testet den Stack an sich. - */ - @Test - void testStack() { - SimpleStack s = new SimpleStack<>(10); - s.push("A"); - s.push("B"); - s.push("C"); - s.push("D"); - assertEquals("D", s.peek()); - assertEquals("D", s.pop()); - assertEquals("C", s.pop()); - assertEquals("B", s.pop()); - s.push("A2"); - s.push("A3"); - assertEquals("A3", s.peek()); - assertEquals("A3", s.pop()); - assertEquals("A2", s.pop()); - assertEquals("A", s.pop()); - } - - - /** - * Testet den Iterator. - */ - @Test - void testIterator() { - SimpleStack s = new SimpleStack<>(10); - s.push("A"); - s.push("B"); - s.push("C"); - s.push("D"); - - String[] result = new String[5]; - int count = 0; - - for (String string : s) { - result[count++] = string; - } - - assertEquals("D", s.peek()); - - assertEquals("D", result[0]); - assertEquals("C", result[1]); - assertEquals("B", result[2]); - assertEquals("A", result[3]); - - s.push("E"); - - Iterator it = s.iterator(); - - count = 0; - while (it.hasNext()) { - result[count++] = it.next(); - } - - assertEquals("E", result[0]); - assertEquals("D", result[1]); - assertEquals("C", result[2]); - assertEquals("B", result[3]); - assertEquals("A", result[4]); - - assertFalse(it.hasNext()); - - it = s.iterator(); - - assertTrue(it.hasNext()); - } -} diff --git a/solutions/src/main/java/pr2/collections/iterieren/CoinGenerator.java b/solutions/src/main/java/pr2/collections/iterieren/CoinGenerator.java deleted file mode 100644 index acb849f..0000000 --- a/solutions/src/main/java/pr2/collections/iterieren/CoinGenerator.java +++ /dev/null @@ -1,115 +0,0 @@ -package pr2.collections.iterieren; - -import de.smits_net.games.framework.board.Board; -import de.smits_net.games.framework.image.SimpleImage; -import de.smits_net.games.framework.sprite.Sprite; -import de.smits_net.games.framework.sprite.Sprite.BoundaryPolicy; - -import java.awt.Point; -import java.util.Iterator; -import java.util.Random; - -/** - * Klasse, die eine beliebige Menge an Geld generiert. - */ -public class CoinGenerator implements Iterable { - - /** - * Zufallszahlen-Generator. - */ - private static final Random RND = new Random(); - - /** - * Das Spielfeld. - */ - private final Board board; - - /** - * Anzahl der Münzen, die erzeugt werden sollen. - */ - int number; // nicht private wegen innerer Klasse - - /** - * Erzeugt eine neue Instanz, die zu dem übergebenen Spielfeld gehört. - * - * @param board Das Spielfeld. - * @param number Anzahl der Münzen. - */ - public CoinGenerator(Board board, int number) { - this.board = board; - this.number = number; - } - - /** - * Erzeugt einen neuen Iterator. - * - * @return Der Iterator. - */ - @Override - public Iterator iterator() { - return new Iterator() { - - int count = 0; - - @Override - public boolean hasNext() { - return count < number; - } - - @Override - public Sprite next() { - count++; - return createCoin(); - } - }; - } - - /** - * Legt eine zufällige Münze an. - * - * @return die Münze als Sprite. - */ - Sprite createCoin() { - final String prefix = "pr2/collections/iterieren"; - - String asset; - - switch (RND.nextInt(8)) { - case 0: - asset = prefix + "/1c.png"; - break; - case 1: - asset = prefix + "/2c.png"; - break; - case 3: - asset = prefix + "/5c.png"; - break; - case 4: - asset = prefix + "/10c.png"; - break; - case 5: - asset = prefix + "/20c.png"; - break; - case 6: - asset = prefix + "/50c.png"; - break; - case 7: - asset = prefix + "/1e.png"; - break; - default: - asset = prefix + "/2e.png"; - break; - } - - int xPos = RND.nextInt(board.getWidth()) - 20; - int yPos = RND.nextInt(board.getHeight()) - 20; - - return new Sprite(board, new Point(xPos, yPos), BoundaryPolicy.NONE, - new SimpleImage(asset)) { - @Override - protected void mousePressed() { - this.setVisible(false); - } - }; - } -} diff --git a/solutions/src/main/java/pr2/collections/iterieren/GameBoard.java b/solutions/src/main/java/pr2/collections/iterieren/GameBoard.java deleted file mode 100644 index 275c613..0000000 --- a/solutions/src/main/java/pr2/collections/iterieren/GameBoard.java +++ /dev/null @@ -1,66 +0,0 @@ -package pr2.collections.iterieren; - -import de.smits_net.games.framework.board.Board; -import de.smits_net.games.framework.sprite.Sprite; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.util.Iterator; - -/** - * Spielfeld. - */ -public class GameBoard extends Board { - - /** - * Anzahl der Münzen. - */ - private static final int NUM_COINS = 1000; - - /** - * Münzgenerator. - */ - private final CoinGenerator generator; - - /** - * Münzen auf dem Spielfeld. - */ - private final Sprite[] coins = new Sprite[NUM_COINS]; - - /** - * Erzeugt ein neues Board. - */ - public GameBoard() { - // neues Spielfeld anlegen - super(10, new Dimension(600, 600), Color.BLACK); - - generator = new CoinGenerator(this, NUM_COINS); - - int count = 0; - Iterator it = generator.iterator(); - - while (it.hasNext()) { - coins[count++] = it.next(); - } - } - - - /** - * Spielfeld neu zeichnen. Wird vom Framework aufgerufen. - */ - @Override - public synchronized void drawGame(Graphics g) { - for (Sprite sprite : coins) { - sprite.draw(g); - } - } - - /** - * Spielsituation updaten. Wird vom Framework aufgerufen. - */ - @Override - public boolean updateGame() { - return true; - } -} diff --git a/solutions/src/main/java/pr2/collections/iterieren/GameMain.java b/solutions/src/main/java/pr2/collections/iterieren/GameMain.java deleted file mode 100644 index 2f4c578..0000000 --- a/solutions/src/main/java/pr2/collections/iterieren/GameMain.java +++ /dev/null @@ -1,28 +0,0 @@ -package pr2.collections.iterieren; - -import de.smits_net.games.framework.board.MainWindow; - -import java.awt.EventQueue; - -/** - * Hauptklasse des Spiels. - */ -public class GameMain extends MainWindow { - - /** - * Neues Spiel anlegen. - */ - public GameMain() { - super("Click the coins as fast as you can", new GameBoard()); - } - - /** - * Startpunkt. - * - * @param args command line arguments. - */ - public static void main(String[] args) { - // Spiel starten - EventQueue.invokeLater(GameMain::new); - } -} diff --git a/solutions/src/main/java/pr2/collections/list/WordCollector.java b/solutions/src/main/java/pr2/collections/list/WordCollector.java deleted file mode 100644 index 84b9e0d..0000000 --- a/solutions/src/main/java/pr2/collections/list/WordCollector.java +++ /dev/null @@ -1,267 +0,0 @@ -package pr2.collections.list; - -import java.io.BufferedReader; -import java.io.FileReader; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; - -/** - * Klassen, um die in einem Text vorkommenden Wörter zu sammeln. - */ -public class WordCollector { - - - /** - * Listet alle Worte in der Datei alphabetisch auf. Duplikate werden - * entfernt. Die Wörter werden in Kleinbuchstaben umgewandelt. - * - * @param filename Dateiname - * @return die Liste der vorhandenen Worte - * @throws IOException Fehler beim Dateizugriff. - */ - public static List listWords(String filename) throws IOException { - List allWords = readFileAndSplitIntoWords(filename); - List result = removeDuplicates(allWords); - - return result; - } - - /** - * Listet alle Worte in der Datei auf. - * - * @param filename Dateiname - * @return die Liste der vorhandenen Worte - * @throws IOException Fehler beim Dateizugriff. - */ - private static List readFileAndSplitIntoWords(String filename) - throws IOException { - - // Datei zum Lesen öffnen - BufferedReader reader = new BufferedReader(new FileReader(filename)); - - String line; // aktuelle Zeile - - List wordList = new LinkedList<>(); - - // Über die Zeilen der Datei iterieren - while ((line = reader.readLine()) != null) { - - // Sonderzeichen entfernen und die Zeilen in Worte splitten - line = line.toLowerCase(); - line = line.replaceAll("[\",.:'\\-!?]", ""); - - String[] words = line.toLowerCase().split("[,. ]"); - - // Worte in den Puffer übertragen - wordList.addAll(Arrays.asList(words)); - } - - reader.close(); - - return wordList; - } - - /** - * Sortiert das übergebene Array alphabetisch und entfernt Duplikate. - * - * @param input Eingabe Array - * @return sortiertes und bereinigtes Array - */ - @SuppressWarnings("PMD.AvoidReassigningLoopVariables") - private static List removeDuplicates(List input) { - - // Eingabe-Liste kopieren - List strings = new ArrayList<>(input); - - // Liste sortieren - Collections.sort(strings); - - // Über die Einträge laufen - for (int i = 0; i < strings.size(); i++) { - - String word = strings.get(i); - - // Über die Einträge laufen - for (int k = i + 1; k < strings.size(); k++) { - - String otherWord = strings.get(k); - - if (otherWord.compareTo(word) > 0) { - // Sind schon hinter der möglichen Position - break; - } - else if (otherWord.equals(word)) { - // Duplikat, entfernen - strings.remove(k); - k--; - } - } - } - - return strings; - } - - /** - * Hauptmethode. - * - * @param args Kommandozeilen-Argumente. - */ - public static void main(String[] args) { - - try { - List words = listWords( - "pr2/collections/list/kafka.txt"); - System.out.println(words); - } catch (IOException e) { - System.err.println("Probleme beim Dateizugriff: " + e); - } - } - -// /** -// * Listet alle Worte in der Datei alphabetisch auf. Duplikate werden -// * entfernt. Die Wörter werden in Kleinbuchstaben umgewandelt. -// * -// * @param filename Dateiname -// * @return die Liste der vorhandenen Wort -// * @throws IOException Fehler beim Dateizugriff. -// */ -// public static String[] listWords(String filename) throws IOException { -// String[] allWords = readFileAndSplitIntoWords(filename); -// String[] result = removeDuplicates(allWords); -// -// return result; -// } -// -// /** -// * Listet alle Worte in der Datei auf. -// * -// * @param filename Dateiname -// * @return die Liste der vorhandenen Wort -// * @throws IOException Fehler beim Dateizugriff. -// */ -// private static String[] readFileAndSplitIntoWords(String filename) -// throws IOException { -// -// // Datei zum Lesen öffnen -// BufferedReader reader = new BufferedReader( -// new FileReader(filename)); -// -// String line; // aktuelle Zeile -// String[] wordBuffer = new String[100]; // Puffer für die Worte -// int pos = 0; // Position im Word-Puffer -// -// // Über die Zeilen der Datei iterieren -// while ((line = reader.readLine()) != null) { -// -// // Sonderzeichen entfernen und die Zeilen in Worte splitten -// line = line.toLowerCase(); -// line = line.replaceAll("[\",.:'\\-\\!?]", ""); -// -// String[] words = line.toLowerCase().split("[,. ]"); -// -// // Worte in den Puffer übertragen -// for (String word : words) { -// -// if (pos >= wordBuffer.length) { -// // Puffer ist voll, vergrößern -// String[] newBuffer = -// new String[wordBuffer.length * 2]; -// System.arraycopy(wordBuffer, 0, newBuffer, -// 0, wordBuffer.length); -// wordBuffer = newBuffer; -// } -// -// wordBuffer[pos++] = word; -// } -// } -// -// reader.close(); -// -// // Ergebnis-Array mit der richtigen Größe anlegen -// String[] result = new String[pos]; -// System.arraycopy(wordBuffer, 0, result, 0, pos); -// -// return result; -// } -// -// /** -// * Sortiert das übergebene Array alphabetisch und entfernt Duplikate. -// * -// * @param input Eingabe Array -// * @return sortiertes und bereinigtes Array -// */ -// private static String[] removeDuplicates(String[] input) { -// -// // Eingabe Array clonen, da es verändert wird (Seiteneffekt) -// String[] strings = input.clone(); -// -// // Array sortieren -// Arrays.sort(strings); -// -// // Über die Einträge laufen -// for (int i = 0; i < strings.length; i++) { -// String word = strings[i]; -// -// if (word == null) { -// // Bereits entfernter Eintrag -// continue; -// } -// -// // Über die Einträge laufen -// for (int k = i + 1; k < strings.length; k++) { -// String otherWord = strings[k]; -// -// if (otherWord == null) { -// // Bereits entfernter Eintrag -// continue; -// } -// else if (otherWord.compareTo(word) > 0) { -// // Sind schon hinter der möglichen Position -// break; -// } -// else if (otherWord.equals(word)) { -// // Duplikat, ausnullen -// strings[k] = null; -// } -// } -// } -// -// // Ausgenullte Einträge entfernen -// int pos = 0; -// String[] temp = new String[strings.length]; -// -// for (int i = 0; i < strings.length; i++) { -// if (strings[i] != null) { -// temp[pos++] = strings[i]; -// } -// } -// -// // Ergebnis auf die richtige Länge bringen -// String[] result = new String[pos]; -// System.arraycopy(temp, 0, result, 0, pos); -// -// return result; -// } -// -// /** -// * Hauptmethode. -// * -// * @param args Kommandozeilen-Argumente. -// */ -// public static void main(String[] args) { -// -// try { -// String[] words = listWords( -// "pr2/collections/list/kafka.txt"); -// System.out.println(Arrays.toString(words)); -// } -// catch (IOException e) { -// System.err.println("Probleme beim Dateizugriff: " + e); -// } -// } - -} diff --git a/solutions/src/main/java/pr2/collections/list_iterator/Liste.java b/solutions/src/main/java/pr2/collections/list_iterator/Liste.java deleted file mode 100644 index c76aa82..0000000 --- a/solutions/src/main/java/pr2/collections/list_iterator/Liste.java +++ /dev/null @@ -1,57 +0,0 @@ -package pr2.collections.list_iterator; - -import java.util.Iterator; -public class Liste implements Iterable { - - static class Item { - T element; - Item next; - - public Item(T element) { - this.element = element; - } - } - - Item first; - Item last; - - class ListenIterator implements Iterator { - Item position = first; - - @Override - public boolean hasNext() { - return (position != null); - } - - @Override - public T next() { - T element = position.element; - position = position.next; - return element; - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - } - - public void add(T element) { - Item item = new Item(element); - - first = (first != null) ? first : item; - - if (last == null) { - last = item; - } else { - last.next = item; - last = item; - } - - } - - @Override - public Iterator iterator() { - return new ListenIterator(); - } -} diff --git a/solutions/src/main/java/pr2/collections/map/WordCount.java b/solutions/src/main/java/pr2/collections/map/WordCount.java deleted file mode 100644 index cd18cba..0000000 --- a/solutions/src/main/java/pr2/collections/map/WordCount.java +++ /dev/null @@ -1,83 +0,0 @@ -package pr2.collections.map; - -import java.io.BufferedReader; -import java.io.FileReader; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Zählen von Worthäufigkeiten. - */ -public class WordCount { - - /** - * Listet alle Worte in der Datei und deren Häufigkeit auf. - * Die zurückgegebene Liste ist bereits nach der Häufigkeit - * sortiert. - * - * @param filename Dateiname - * @return die Liste der vorhandenen Wörter - * @throws IOException Fehler beim Dateizugriff. - */ - private static List countWords(String filename) - throws IOException { - - // Map mit dem Wort als Schlüssel und der Häufigkeit als Key - Map frequencyMap = new HashMap<>(); - - // Datei zum Lesen öffnen - BufferedReader reader = new BufferedReader(new FileReader(filename)); - - String line; // aktuelle Zeile - - // Über die Zeilen der Datei iterieren - while ((line = reader.readLine()) != null) { - - // Sonderzeichen entfernen und die Zeilen in Worte splitten - line = line.toLowerCase(); - line = line.replaceAll("[\",.:;)'\\-!?]", ""); - - String[] words = line.toLowerCase().split("[,. ]"); - - for (String word : words) { - WordFrequency entry = frequencyMap.get(word); - if (entry == null) { - entry = new WordFrequency(word, 0); - frequencyMap.put(word, entry); - } - - entry.incrementFrequency(); - } - } - - reader.close(); - - List liste = new ArrayList<>(frequencyMap.values()); - Collections.sort(liste); - - return liste; - } - - /** - * Hauptmethode. - * - * @param args Kommandozeilen-Argumente. - */ - public static void main(String[] args) { - - try { - List words = countWords( - "pr2/collections/map/kafka.txt"); - - for (WordFrequency word : words) { - System.out.println(word); - } - } catch (IOException e) { - System.err.println("Probleme beim Dateizugriff: " + e); - } - } -} diff --git a/solutions/src/main/java/pr2/collections/map/WordFrequency.java b/solutions/src/main/java/pr2/collections/map/WordFrequency.java deleted file mode 100644 index a4cba2f..0000000 --- a/solutions/src/main/java/pr2/collections/map/WordFrequency.java +++ /dev/null @@ -1,56 +0,0 @@ -package pr2.collections.map; - -/** - * Klasse für die Verwaltung der Worthäufigkeiten. - */ -public class WordFrequency implements Comparable { - - /** - * Das Wort. - */ - String word; - - /** - * Seine Häufigkeit. - */ - int frequency; - - /** - * Legt ein neues Objekt an. - * - * @param word das gespeicherte Wort - * @param frequency die Häfigkeit - */ - WordFrequency(String word, int frequency) { - this.word = word; - this.frequency = frequency; - } - - - /** - * Vergleich mit anderem Objekt. - * - * @param o das andere Objekt - * @return Ergebnis des Vergleiches - * @see java.lang.Comparable#compareTo(java.lang.Object) - */ - @Override - public int compareTo(WordFrequency o) { - return o.frequency - frequency; - } - - /** - * Erhöht die Häufigkeit des Wortes. - */ - public void incrementFrequency() { - frequency++; - } - - /** - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return String.format("%s: %d", word, frequency); - } -} diff --git a/solutions/src/main/java/pr2/collections/reverser/Reverser.java b/solutions/src/main/java/pr2/collections/reverser/Reverser.java deleted file mode 100644 index 0025563..0000000 --- a/solutions/src/main/java/pr2/collections/reverser/Reverser.java +++ /dev/null @@ -1,18 +0,0 @@ -package pr2.collections.reverser; - -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -public class Reverser { - public void reverse(List liste) { - - Collections.sort(liste, new Comparator() { - - @Override - public int compare(String o1, String o2) { - return o1.compareTo(o2) * -1; - } - }); - } -} diff --git a/solutions/src/main/java/pr2/collections/reverser/test/ReverserTest.java b/solutions/src/main/java/pr2/collections/reverser/test/ReverserTest.java deleted file mode 100644 index 09f0091..0000000 --- a/solutions/src/main/java/pr2/collections/reverser/test/ReverserTest.java +++ /dev/null @@ -1,23 +0,0 @@ -package pr2.collections.reverser.test; - -import org.junit.jupiter.api.Test; -import pr2.collections.reverser.Reverser; - -import java.util.Arrays; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class ReverserTest { - - @Test - void testReverser() { - List testListe = Arrays.asList("Meier", "Zabelmann", "Schulze", - "Xavier", "Albert"); - new Reverser().reverse(testListe); - assertEquals(Arrays.asList( - "Zabelmann", "Xavier", "Schulze", "Meier", "Albert"), - testListe); - } - -} diff --git a/solutions/src/main/java/pr2/collections/reverser_generic/Reverser.java b/solutions/src/main/java/pr2/collections/reverser_generic/Reverser.java deleted file mode 100644 index 0958574..0000000 --- a/solutions/src/main/java/pr2/collections/reverser_generic/Reverser.java +++ /dev/null @@ -1,19 +0,0 @@ -package pr2.collections.reverser_generic; - -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -public class Reverser> { - - public void reverse(List liste) { - - Collections.sort(liste, new Comparator() { - - @Override - public int compare(T o1, T o2) { - return o1.compareTo(o2) * -1; - } - }); - } -} diff --git a/solutions/src/main/java/pr2/collections/reverser_generic/test/ReverserTest.java b/solutions/src/main/java/pr2/collections/reverser_generic/test/ReverserTest.java deleted file mode 100644 index a623dc2..0000000 --- a/solutions/src/main/java/pr2/collections/reverser_generic/test/ReverserTest.java +++ /dev/null @@ -1,23 +0,0 @@ -package pr2.collections.reverser_generic.test; - -import org.junit.jupiter.api.Test; -import pr2.collections.reverser_generic.Reverser; - -import java.util.Arrays; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class ReverserTest { - - @Test - void testReverser() { - List testListe = Arrays.asList("Meier", "Zabelmann", "Schulze", - "Xavier", "Albert"); - new Reverser().reverse(testListe); - assertEquals(Arrays.asList( - "Zabelmann", "Xavier", "Schulze", "Meier", "Albert"), - testListe); - } - -} diff --git a/solutions/src/main/java/pr2/collections/set/WordCollector.java b/solutions/src/main/java/pr2/collections/set/WordCollector.java deleted file mode 100644 index 177d6fc..0000000 --- a/solutions/src/main/java/pr2/collections/set/WordCollector.java +++ /dev/null @@ -1,80 +0,0 @@ -package pr2.collections.set; - -import java.io.BufferedReader; -import java.io.FileReader; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** - * Klassen, um die in einem Text vorkommenen Wörter zu sammeln. - */ -public class WordCollector { - - - /** - * Listet alle Worte in der Datei alphabetisch auf. Duplikate werden - * entfernt. Die Wörter werden in Kleinbuchstaben umgewandelt. - * - * @param filename Dateiname - * @return die Liste der vorhandenen Worte - * @throws IOException Fehler beim Dateizugriff. - */ - public static List listWords(String filename) throws IOException { - Set allWords = readFileAndSplitIntoWords(filename); - List wordsSorted = new ArrayList<>(allWords); - Collections.sort(wordsSorted); - return wordsSorted; - } - - /** - * Listet alle Worte in der Datei auf. - * - * @param filename Dateiname - * @return die Liste der vorhandenen Worte - * @throws IOException Fehler beim Dateizugriff. - */ - private static Set readFileAndSplitIntoWords(String filename) - throws IOException { - - // Datei zum Lesen öffnen - BufferedReader reader = new BufferedReader(new FileReader(filename)); - - String line; // aktuelle Zeile - Set wordBuffer = new HashSet<>(); // Puffer für die Worte - - // Über die Zeilen der Datei iterieren - while ((line = reader.readLine()) != null) { - - // Sonderzeichen entfernen und die Zeilen in Worte splitten - line = line.replaceAll("[\",.:'\\-!?]", ""); - - String[] words = line.toLowerCase().split("[,. ]"); - - // Worte in den Puffer übertragen - wordBuffer.addAll(Arrays.asList(words)); - } - - reader.close(); - - return wordBuffer; - } - - /** - * Hauptmethode. - * - * @param args Kommandozeilen-Argumente. - */ - public static void main(String[] args) { - - try { - List words = listWords("pr2/collections/set/kafka.txt"); - System.out.println(words); - } catch (IOException e) { - System.err.println("Probleme beim Dateizugriff: " + e); - } - } diff --git a/solutions/src/main/java/pr2/collections/sorter_1/CommandLineSorter.java b/solutions/src/main/java/pr2/collections/sorter_1/CommandLineSorter.java deleted file mode 100644 index 471bf93..0000000 --- a/solutions/src/main/java/pr2/collections/sorter_1/CommandLineSorter.java +++ /dev/null @@ -1,17 +0,0 @@ -package pr2.collections.sorter_1; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -public class CommandLineSorter { - - public static void main(String[] args) { - List argList = Arrays.asList(args); - Collections.sort(argList); - - for (String element : argList) { - System.out.println(element); - } - } -} diff --git a/solutions/src/main/java/pr2/collections/sorter_2/CommandLineSorter.java b/solutions/src/main/java/pr2/collections/sorter_2/CommandLineSorter.java deleted file mode 100644 index 6ab92bb..0000000 --- a/solutions/src/main/java/pr2/collections/sorter_2/CommandLineSorter.java +++ /dev/null @@ -1,16 +0,0 @@ -package pr2.collections.sorter_2; - -import java.util.Arrays; -import java.util.Set; -import java.util.TreeSet; - -public class CommandLineSorter { - - public static void main(String[] args) { - Set argList = new TreeSet(Arrays.asList(args)); - - for (String element : argList) { - System.out.println(element); - } - } -} diff --git a/solutions/src/main/java/pr2/collections/sortieren/Sorter.java b/solutions/src/main/java/pr2/collections/sortieren/Sorter.java deleted file mode 100644 index 1613994..0000000 --- a/solutions/src/main/java/pr2/collections/sortieren/Sorter.java +++ /dev/null @@ -1,83 +0,0 @@ -package pr2.collections.sortieren; - -import java.util.Arrays; -import java.util.Comparator; - -/** - * Klasse zum Sortieren von Strings. - */ -public class Sorter { - - /** - * Liefert einen Comparator für Strings. - * - * @param order Sortierreihenfolge. - * @return Comparator, entsprechend der gewünschten Sortierreihenfolge. - */ - private static Comparator stringComparator(final SortOrder order) { - /* Comparator. */ - class MyComparator implements Comparator { - - /** - * Vergleicht die Strings. - * - * @param o1 Erster String - * @param o2 Zweiter String - * @return Ergebnis des Vergleichs. - */ - @Override - public int compare(String o1, String o2) { - switch (order) { - case ASCENDING: - return o1.compareTo(o2); - case DESCENDING: - return -o1.compareTo(o2); - case ASCENDING_CASE_INSENSITIVE: - return o1.toUpperCase().compareTo(o2.toUpperCase()); - case DESCENDING_CASE_INSENSITIVE: - return -o1.toUpperCase().compareTo(o2.toUpperCase()); - default: - throw new IllegalArgumentException(); - } - } - } - - return new MyComparator(); - } - - /** - * Sortiert das übergebene Array entsprechend der gewünschten Reihenfolge. - * - * @param array das zu sortierende Array. - * @param order die Sortierreihenfolge. - */ - public static void sort(String[] array, SortOrder order) { - Arrays.sort(array, stringComparator(order)); - } - - /** - * Sortierreihenfolge für die Strings. - */ - public enum SortOrder { - - /** - * Aufsteigend. - */ - ASCENDING, - - /** - * Absteigend. - */ - DESCENDING, - - /** - * Aufsteigend, ohne Beachtung der Groß-/Kleinschreibung. - */ - ASCENDING_CASE_INSENSITIVE, - - /** - * Absteigend, ohne Beachtung der Groß-/Kleinschreibung. - */ - DESCENDING_CASE_INSENSITIVE - } -} diff --git a/solutions/src/main/java/pr2/collections/sortieren/test/SorterTest.java b/solutions/src/main/java/pr2/collections/sortieren/test/SorterTest.java deleted file mode 100644 index a2c30f2..0000000 --- a/solutions/src/main/java/pr2/collections/sortieren/test/SorterTest.java +++ /dev/null @@ -1,75 +0,0 @@ -package pr2.collections.sortieren.test; - -import org.junit.jupiter.api.Test; -import pr2.collections.sortieren.Sorter; -import pr2.collections.sortieren.Sorter.SortOrder; - -import static org.junit.jupiter.api.Assertions.assertArrayEquals; - - -/** - * Test für die Sortierung. - */ -public class SorterTest { - - private static final String[] DATA = - {"aaron", "ALFONS", "bond", "BerND", "henry", "Hugo"}; - - /** - * Testet die Sortierung: aufsteigend. - */ - @Test - void testAscendingSorting() { - - String[] asc = DATA.clone(); - - Sorter.sort(asc, SortOrder.ASCENDING); - - assertArrayEquals( - new String[] {"ALFONS", "BerND", "Hugo", "aaron", "bond", - "henry"}, asc); - } - - /** - * Testet die Sortierung: Absteigend. - */ - @Test - void testDescendingSorting() { - - String[] desc = DATA.clone(); - Sorter.sort(desc, SortOrder.DESCENDING); - - assertArrayEquals( - new String[] {"henry", "bond", "aaron", "Hugo", "BerND", - "ALFONS"}, desc); - } - - /** - * Testet die Sortierung: Aufsteigend, CI. - */ - @Test - void testAscendingCISorting() { - - String[] ascCI = DATA.clone(); - Sorter.sort(ascCI, SortOrder.ASCENDING_CASE_INSENSITIVE); - - assertArrayEquals( - new String[] {"aaron", "ALFONS", "BerND", "bond", "henry", - "Hugo"}, ascCI); - } - - /** - * Testet die Sortierung: Absteigend, CI. - */ - @Test - void testDescendingCISorting() { - - String[] descCI = DATA.clone(); - - Sorter.sort(descCI, SortOrder.DESCENDING_CASE_INSENSITIVE); - - assertArrayEquals( - new String[] {"Hugo", "henry", "bond", "BerND", "ALFONS", - "aaron"}, descCI); - } -} diff --git a/solutions/src/main/java/pr2/collections/woerterbuch/Woerterbuch.java b/solutions/src/main/java/pr2/collections/woerterbuch/Woerterbuch.java deleted file mode 100644 index 9a4d618..0000000 --- a/solutions/src/main/java/pr2/collections/woerterbuch/Woerterbuch.java +++ /dev/null @@ -1,37 +0,0 @@ -package pr2.collections.woerterbuch; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -public class Woerterbuch { - - private static final Map WOERTER; - - static { - Map map = new HashMap(); - map.put("gehen", "go"); - map.put("schlafen", "sleep"); - map.put("tanzen", "dance"); - map.put("springen", "jump"); - - WOERTER = Collections.unmodifiableMap(map); - } - - public static void main(String[] args) { - if (args.length == 0) { - System.err.println("Bitte mindestens ein Wort angeben!"); - System.exit(1); - } - - for (String wort : args) { - String uebersetzung = WOERTER.get(wort); - - if (uebersetzung == null) { - uebersetzung = ""; - } - - System.out.printf("%s => %s%n", wort, uebersetzung); - } - } -} diff --git a/solutions/src/main/java/pr2/enums/eigene/Wuerfel.java b/solutions/src/main/java/pr2/enums/eigene/Wuerfel.java deleted file mode 100644 index 347679b..0000000 --- a/solutions/src/main/java/pr2/enums/eigene/Wuerfel.java +++ /dev/null @@ -1,9 +0,0 @@ -package pr2.enums.eigene; - -import java.util.Random; - -/** - * Ein einfacher Würfel. - */ -public class Wuerfel { - diff --git a/solutions/src/main/java/pr2/enums/eigene/WuerfelTyp.java b/solutions/src/main/java/pr2/enums/eigene/WuerfelTyp.java deleted file mode 100644 index c17f4fc..0000000 --- a/solutions/src/main/java/pr2/enums/eigene/WuerfelTyp.java +++ /dev/null @@ -1,71 +0,0 @@ - -package pr2.enums.eigene; - -/** - * Enumeration für die verschiedenen Würfel-Typen. - */ -public enum WuerfelTyp { - - /** - * 4-seitiger Würfel. - */ - D4(4), - - /** - * 6-seitiger Würfel. - */ - D6(6), - - /** - * 8-seitiger Würfel. - */ - D8(8), - - /** - * 10-seitiger Würfel. - */ - D10(10), - - /** - * 12-seitiger Würfel. - */ - D12(12), - - /** - * 20-seitiger Würfel. - */ - D20(20); - - /** - * Anzahl der Seiten. - */ - private final int seiten; - - /** - * Neue Instanz anlegen. - * - * @param seiten Anzahl der Seiten. - */ - WuerfelTyp(int seiten) { - this.seiten = seiten; - } - - /** - * Anzahl der Seiten. - * - * @return Anzahl der Seiten. - */ - public int getSeiten() { - return seiten; - } - - /** - * Durchschnittliche Augenzahl bei einer großen Anzahl von - * Würfen. - * - * @return Durchschnittliche Augenzahl. - */ - public double average() { - return 0.5 * (seiten + 1); - } -} diff --git a/solutions/src/main/java/pr2/enums/eigene/test/WuerfelTest.java b/solutions/src/main/java/pr2/enums/eigene/test/WuerfelTest.java deleted file mode 100644 index 793c803..0000000 --- a/solutions/src/main/java/pr2/enums/eigene/test/WuerfelTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package pr2.enums.eigene.test; - -import org.junit.jupiter.api.Test; -import pr2.enums.eigene.Wuerfel; -import pr2.enums.eigene.WuerfelTyp; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * Test für die Würfel. - */ -public class WuerfelTest { - - /** - * Anzahl der Durchläufe (Gesetz der großen Zahl!). - */ - private static final int RUNS = 10000000; - - @Test - void testFairness() { - for (WuerfelTyp typ : WuerfelTyp.values()) { - internalTestFairness(new Wuerfel(typ), typ.average()); - } - } diff --git a/solutions/src/main/java/pr2/enums/filme/LieblingsFilme.java b/solutions/src/main/java/pr2/enums/filme/LieblingsFilme.java deleted file mode 100644 index 7ae95b1..0000000 --- a/solutions/src/main/java/pr2/enums/filme/LieblingsFilme.java +++ /dev/null @@ -1,50 +0,0 @@ -package pr2.enums.filme; - -public enum LieblingsFilme { - - /** - * Pulp Fiction. - */ - PULP_FICTION("Pulp Fiction", "Quentin Tarantino", 9), - /** - * Fight Club. - */ - FIGHT_CLUB("Fight Club", "David Fincher", 9), - /** - * Twelve Monkeys. - */ - TWELVE_MONKEYS("Twelve Monkeys", "Terry Giliam", 8), - /** - * Killer Tomatos. - */ - KILLER_TOMATOES("Attack of the Killer Tomatoes", "John de Bello", 4); - - private final String name; - private final int bewertung; - private final String regisseur; - - private LieblingsFilme(String name, String regisseur, - int bewertung) { - this.name = name; - this.regisseur = regisseur; - this.bewertung = bewertung; - } - - public String getName() { - return name; - } - - public int getBewertung() { - return bewertung; - } - - public String getRegisseur() { - return regisseur; - } - - @Override - public String toString() { - return String.format("'%s' von %s; Bewertung %d", name, - regisseur, bewertung); - } -} diff --git a/solutions/src/main/java/pr2/enums/filme/Main.java b/solutions/src/main/java/pr2/enums/filme/Main.java deleted file mode 100644 index 8a53673..0000000 --- a/solutions/src/main/java/pr2/enums/filme/Main.java +++ /dev/null @@ -1,9 +0,0 @@ -package pr2.enums.filme; - -public class Main { - public static void main(String[] args) { - for (LieblingsFilme f : LieblingsFilme.values()) { - System.out.println(f); - } - } -} diff --git a/solutions/src/main/java/pr2/enums/schnick/Move.java b/solutions/src/main/java/pr2/enums/schnick/Move.java deleted file mode 100644 index eccdd75..0000000 --- a/solutions/src/main/java/pr2/enums/schnick/Move.java +++ /dev/null @@ -1,46 +0,0 @@ -package pr2.enums.schnick; - -public enum Move { - /** - * Konstante für Schere. - */ - SCISSORS("Scissors", "s"), - - /** - * Konstante für Papier. - */ - PAPER("Paper", "p"), - - /** - * Konstante für Stein. - */ - ROCK("Rock", "r"); - - private final String name; - private final String key; - - private Move(String name, String key) { - this.name = name; - this.key = key; - } - - @Override - public String toString() { - return name; - } - - /** - * Returns the move corresponding to the key entered. - * - * @param key the key pressed. - * @return the corresponding move. - */ - public static Move find(String key) { - for (Move m : values()) { - if (m.key.equals(key.toLowerCase())) { - return m; - } - } - return null; - } -} diff --git a/solutions/src/main/java/pr2/enums/schnick/SchnickSchnackSchnuck.java b/solutions/src/main/java/pr2/enums/schnick/SchnickSchnackSchnuck.java deleted file mode 100644 index 68ada87..0000000 --- a/solutions/src/main/java/pr2/enums/schnick/SchnickSchnackSchnuck.java +++ /dev/null @@ -1,89 +0,0 @@ -package pr2.enums.schnick; - -import java.util.Random; -import java.util.Scanner; - -/** - * Schick - Schnack - Schnuck (Rock - Paper - Scissors). - */ -public class SchnickSchnackSchnuck { - - /** - * Vergleicht den Zug zweier Spieler. - * - * @param a Zug von Spieler a. - * @param b Zug von Spieler b. - * @return 1 spieler a hat gewonnen, 0, unentschieden, -1 spieler b - * hat gewonnen. - */ - private static int compare(Move a, Move b) { - - if (a == b) { - return 0; - } - else if (a == Move.SCISSORS && b == Move.PAPER) { - return 1; - } - else if (a == Move.ROCK && b == Move.SCISSORS) { - return 1; - } - else if (a == Move.PAPER && b == Move.ROCK) { - return 1; - } - else { - return compare(b, a) * -1; - } - } - - public static void main(String[] args) { - - Scanner scanner = new Scanner(System.in); - Random rnd = new Random(); - - int pointsPlayer = 0; - int pointsComputer = 0; - - // Play three rounds - for (int i = 0; i < 3; i++) { - - // Read the player's choice - Move movePlayer = null; - - while (movePlayer == null) { - System.out.printf( - "\nRunde %s: Dein Zug ([r]rock, [p]aper, [s]cissors)? ", - i); - String move = scanner.nextLine().trim(); - movePlayer = Move.find(move); - } - - // Random move of the computer - Move moveComputer = - Move.values()[rnd.nextInt(2)]; - - // Compare moves - int winner = compare(movePlayer, moveComputer); - - String winnerText; - - if (winner == 1) { - pointsPlayer++; - winnerText = "Du hast gewonnen"; - } else if (winner == -1) { - pointsComputer++; - winnerText = "Der Computer hat gewonnen"; - } else { - winnerText = "Unentschieden"; - } - System.out.printf("%s: %s, Computer: %s - [%d:%d]\n", - winnerText, - movePlayer, moveComputer, - pointsPlayer, pointsComputer); - } - - System.out.printf( - "\nErgebnis - Du %d Punkt(e), " - + "Computer %d Punkt(e)", - pointsPlayer, pointsComputer); - } -} diff --git a/solutions/src/main/java/pr2/enums/singleton/MyEnum.java b/solutions/src/main/java/pr2/enums/singleton/MyEnum.java deleted file mode 100644 index be83cc0..0000000 --- a/solutions/src/main/java/pr2/enums/singleton/MyEnum.java +++ /dev/null @@ -1,7 +0,0 @@ -package pr2.enums.singleton; - -enum MyEnum { - A, - B, - C; -} diff --git a/solutions/src/main/java/pr2/enums/singleton/SingletonBeweis.java b/solutions/src/main/java/pr2/enums/singleton/SingletonBeweis.java deleted file mode 100644 index 327cf52..0000000 --- a/solutions/src/main/java/pr2/enums/singleton/SingletonBeweis.java +++ /dev/null @@ -1,14 +0,0 @@ -package pr2.enums.singleton; - -public class SingletonBeweis { - - public static void main(String[] args) { - MyEnum e1 = MyEnum.A; - MyEnum e2 = MyEnum.valueOf("A"); - MyEnum e3 = MyEnum.values()[0]; - - System.out.println(e1 == e2); - System.out.println(e2 == e3); - System.out.println(e1 == e3); - } -} diff --git a/solutions/src/main/java/pr2/enums/verwenden/GameBoard.java b/solutions/src/main/java/pr2/enums/verwenden/GameBoard.java deleted file mode 100644 index a0c12b5..0000000 --- a/solutions/src/main/java/pr2/enums/verwenden/GameBoard.java +++ /dev/null @@ -1,47 +0,0 @@ -package pr2.enums.verwenden; - -import de.smits_net.games.framework.board.Board; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Point; - -/** - * Spielfeld. - */ -public class GameBoard extends Board { - - /** - * Sprite, das durch das Bild läuft. - */ - private final Professor sprite; - - /** - * Erzeugt ein neues Board. - */ - public GameBoard() { - // neues Spielfeld anlegen - super(10, new Dimension(400, 400), Color.BLACK); - - // Sprite initialisieren - sprite = new Professor(this, new Point(300, 200)); - } - - /** - * Spielfeld neu zeichnen. Wird vom Framework aufgerufen. - */ - @Override - public void drawGame(Graphics g) { - sprite.draw(g, this); - } - - /** - * Spielsituation updaten. Wird vom Framework aufgerufen. - */ - @Override - public boolean updateGame() { - sprite.move(); - return sprite.isVisible(); - } -} diff --git a/solutions/src/main/java/pr2/enums/verwenden/GameMain.java b/solutions/src/main/java/pr2/enums/verwenden/GameMain.java deleted file mode 100644 index becc1ae..0000000 --- a/solutions/src/main/java/pr2/enums/verwenden/GameMain.java +++ /dev/null @@ -1,28 +0,0 @@ -package pr2.enums.verwenden; - -import de.smits_net.games.framework.board.MainWindow; - -import java.awt.EventQueue; - -/** - * Hauptklasse des Spiels. - */ -public class GameMain extends MainWindow { - - /** - * Neues Spiel anlegen. - */ - public GameMain() { - super("Watch me walk...", new GameBoard()); - } - - /** - * Startpunkt. - * - * @param args command line arguments. - */ - public static void main(String[] args) { - // Spiel starten - EventQueue.invokeLater(GameMain::new); - } -} diff --git a/solutions/src/main/java/pr2/enums/verwenden/Professor.java b/solutions/src/main/java/pr2/enums/verwenden/Professor.java deleted file mode 100644 index 6d648a4..0000000 --- a/solutions/src/main/java/pr2/enums/verwenden/Professor.java +++ /dev/null @@ -1,32 +0,0 @@ -package pr2.enums.verwenden; - -import de.smits_net.games.framework.board.Board; -import de.smits_net.games.framework.image.AnimatedImage; -import de.smits_net.games.framework.sprite.AnimatedSprite; -import de.smits_net.games.framework.sprite.Direction; - -import java.awt.Point; - -/** - * Ein Sprite. - */ -public class Professor extends AnimatedSprite { - - /** - * Geschwindigkeit der Figur in X-Richtung. - */ - private static final int SPRITE_SPEED = 2; - - /** - * Neues Sprite anlegen. - * - * @param board das Spielfeld - * @param startPoint Start-Position - */ - public Professor(Board board, Point startPoint) { - super(board, startPoint, BoundaryPolicy.NONE, - new AnimatedImage(50, 9, - "pr2/enums/use/professor_left")); - velocity.setVelocity(Direction.WEST, SPRITE_SPEED); - } -} diff --git a/solutions/src/main/java/pr2/exceptions/ausnahmen_testen/CrypterCaesar.java b/solutions/src/main/java/pr2/exceptions/ausnahmen_testen/CrypterCaesar.java deleted file mode 100644 index 5b9f0ab..0000000 --- a/solutions/src/main/java/pr2/exceptions/ausnahmen_testen/CrypterCaesar.java +++ /dev/null @@ -1,164 +0,0 @@ -package pr2.exceptions.ausnahmen_testen; - -/** - * Implementierung einer Caesar-Verschlüsselung. - *

- * Der Eingabetext ({@literal message}) darf nur aus den Groß-Buchstaben A-Z - * bestehen. Alle anderen Zeichen (einschließlich der Leerzeichen) führen zu - * einer entsprechenden Ausnahme. - *

- * Dasselbe gilt für die Entschlüsselung. Auch hier dürfen nur gültige - * Zeichen auftauchen. Andernfalls kommt es zu einer Ausnahme. - *

- * Der Schlüssel darf nur aus einem einzelnen Zeichen bestehen und muss - * ebenfalls aus dem Bereich A-Z stammen. Kleinbuchstaben oder andere - * Zeichen führen zu einer Ausnahme. - *

- * Zwischen den beiden Methoden muss bei gleichem Schlüssel {@code key} - * folgendes gelten: - *

- * {@code text.equals(decrypt(key, encrypt(key, text)) == true}. - */ -public class CrypterCaesar { - - /** - * Gültige Zeichen für Schlüssel und Text. - */ - protected static final String ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - - /** - * Verschlüsselt den gegebenen Text mit dem angegebenen Schlüssel. - * - * @param key Schlüssel, der verwendet werden soll. - * @param message Nachricht, die Verschlüsselt werden soll. - * @return verschlüsselter Text. - * @throws IllegalMessageException Wird geworfen, wenn die - * Nachricht ungültig ist. - * @throws IllegalKeyException Wird geworfen, wenn der Schlüssel - * ungültig ist. - */ - public String encrypt(String key, String message) - throws IllegalMessageException, IllegalKeyException { - - checkKeyAndMessage(key, message); - - int shift = key.charAt(0) - 'A' + 1; - return shift(message, shift); - } - - /** - * Entschlüsselt den gegebenen Text mit dem angegebenen Schlüssel. - * - * @param key Schlüssel, der verwendet werden soll. - * @param cypherText Nachricht, die entschlüsselt werden soll. - * @return entschlüsselter Text. - * @throws IllegalMessageException Wird geworfen, wenn die - * Nachricht ungültig ist. - * @throws IllegalKeyException Wird geworfen, wenn der Schlüssel - * ungültig ist. - */ - public String decrypt(String key, String cypherText) - throws IllegalKeyException, IllegalMessageException { - - checkKeyAndMessage(key, cypherText); - - int shift = key.charAt(0) - 'A' + 1; - return shift(cypherText, -shift); - } - - /** - * Verschiebt die Zeichen im Text um den gegebenen Faktor. - * - * @param text Nachricht - * @param shift Verschiebefaktor - * @return das Ergebnis als String - */ - private String shift(String text, int shift) { - - StringBuilder result = new StringBuilder(); - - for (char c : text.toCharArray()) { - char newChar = (char) (c + shift); - - if (newChar > 'Z') { - // Überlauf nach hinten - newChar = (char) (newChar - ('Z' - 'A' + 1)); - } - else if (newChar < 'A') { - // Überlauf nach vorne - newChar = (char) (newChar + ('Z' - 'A' + 1)); - } - - result.append(newChar); - } - - return result.toString(); - } - - /** - * Prüft Schlüssel und Nachricht. - * - * @param key der Schlüssel - * @param message die Nachricht - * @throws IllegalKeyException Schlüssel nicht OK - * @throws IllegalMessageException Nachricht nicht OK - */ - private void checkKeyAndMessage(String key, String message) - throws IllegalKeyException, IllegalMessageException { - - if (!checkKey(key)) { - throw new IllegalKeyException(key); - } - - if (!checkCharacters(message, ALPHABET)) { - throw new IllegalMessageException(key); - } - } - - /** - * Testet den Schlüssel auf Korrektheit: Er muss mindestens die Länge 1 - * haben und darf nur Zeichen von A-Z enthalten. - * - * @param key zu testender Schlüssel - * @return {@code true} if characters are ok, otherwise {@code false} - */ - protected boolean checkKey(String key) { - - if (key.length() != 1) { - return false; - } - - return checkCharacters(key, ALPHABET); - } - - /** - * Checks the given input to ensure that it only contains the given - * character set and no other characters. - * - * @param inputChars the string to be checked - * @param charSet a string containing all allowed characters - * @return {@code true} if characters are ok, otherwise {@code false} - */ - protected boolean checkCharacters(char[] inputChars, String charSet) { - - for (char c : inputChars) { - if (charSet.indexOf(c) == -1) { - return false; - } - } - - return true; - } - - /** - * Checks the given input to ensure that it only contains the given - * character set and no other characters. - * - * @param input the string to be checked - * @param charSet a string containing all allowed characters - * @return {@code true} if characters are ok, otherwise {@code false} - */ - protected boolean checkCharacters(String input, String charSet) { - return checkCharacters(input.toCharArray(), charSet); - } -} diff --git a/solutions/src/main/java/pr2/exceptions/ausnahmen_testen/IllegalKeyException.java b/solutions/src/main/java/pr2/exceptions/ausnahmen_testen/IllegalKeyException.java deleted file mode 100644 index 469e5bf..0000000 --- a/solutions/src/main/java/pr2/exceptions/ausnahmen_testen/IllegalKeyException.java +++ /dev/null @@ -1,31 +0,0 @@ -package pr2.exceptions.ausnahmen_testen; - -/** - * Ungültiger Schlüssel. - */ -public class IllegalKeyException extends Exception { - - /** - * Legt eine neue Ausnahme an. - */ - public IllegalKeyException() { - super(); - } - - /** - * Legt eine neue Ausnahme an. - * - * @param message die Nachricht. - */ - public IllegalKeyException(String message) { - super(message); - } - - /** - * @see java.lang.Throwable#toString() - */ - @Override - public String toString() { - return getMessage(); - } -} diff --git a/solutions/src/main/java/pr2/exceptions/ausnahmen_testen/IllegalMessageException.java b/solutions/src/main/java/pr2/exceptions/ausnahmen_testen/IllegalMessageException.java deleted file mode 100644 index 141a2b7..0000000 --- a/solutions/src/main/java/pr2/exceptions/ausnahmen_testen/IllegalMessageException.java +++ /dev/null @@ -1,31 +0,0 @@ -package pr2.exceptions.ausnahmen_testen; - -/** - * Ungültige Nachricht. - */ -public class IllegalMessageException extends Exception { - - /** - * Legt eine neue Ausnahme an. - */ - public IllegalMessageException() { - super(); - } - - /** - * Legt eine neue Ausnahme an. - * - * @param message die Nachricht. - */ - public IllegalMessageException(String message) { - super(message); - } - - /** - * @see java.lang.Throwable#toString() - */ - @Override - public String toString() { - return getMessage(); - } -} diff --git a/solutions/src/main/java/pr2/exceptions/ausnahmen_testen/test/CaesarTest.java b/solutions/src/main/java/pr2/exceptions/ausnahmen_testen/test/CaesarTest.java deleted file mode 100644 index edc2ebc..0000000 --- a/solutions/src/main/java/pr2/exceptions/ausnahmen_testen/test/CaesarTest.java +++ /dev/null @@ -1,149 +0,0 @@ -package pr2.exceptions.ausnahmen_testen.test; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import pr2.exceptions.ausnahmen_testen.CrypterCaesar; -import pr2.exceptions.ausnahmen_testen.IllegalKeyException; -import pr2.exceptions.ausnahmen_testen.IllegalMessageException; - -import static org.junit.jupiter.api.Assertions.assertEquals; - - -/** - * Testklasse für die Verschlüsselung. - */ -public class CaesarTest { - - - /** - * Testet auf falschen Schlüssel. - * - * @throws pr2.exceptions.ausnahmen_testen.IllegalMessageException - * Wird geworfen, wenn die Nachricht ungültig ist. - * @throws pr2.exceptions.ausnahmen_testen.IllegalKeyException - * Wird geworfen, wenn der Schlüssel ungültig ist. - */ - @Test - void testWrongKey1() - throws IllegalKeyException, IllegalMessageException { - - String key = "AB"; - CrypterCaesar c = new CrypterCaesar(); - - Assertions.assertThrows(IllegalKeyException.class, () -> { - c.encrypt(key, "HALLO"); - }); - } - - /** - * Testet auf falschen Schlüssel. - * - * @throws IllegalMessageException Wird geworfen, wenn die - * Nachricht ungültig ist. - * @throws IllegalKeyException Wird geworfen, wenn der Schlüssel - * ungültig ist. - */ - @Test - void testWrongKey2() - throws IllegalKeyException, IllegalMessageException { - String key = "0"; - CrypterCaesar c = new CrypterCaesar(); - Assertions.assertThrows(IllegalKeyException.class, () -> { - c.encrypt(key, "HALLO"); - }); - } - - /** - * Testet auf falsche Nachricht. - * - * @throws IllegalMessageException Wird geworfen, wenn die - * Nachricht ungültig ist. - * @throws IllegalKeyException Wird geworfen, wenn der Schlüssel - * ungültig ist. - */ - @Test - void testWrongMessage1() - throws IllegalKeyException, IllegalMessageException { - String key = "K"; - CrypterCaesar c = new CrypterCaesar(); - - Assertions.assertThrows(IllegalKeyException.class, () -> { - c.encrypt(key, "üäaD&"); - }); - } - - /** - * Testet auf falsche Nachricht. - * - * @throws IllegalMessageException Wird geworfen, wenn die - * Nachricht ungültig ist. - * @throws IllegalKeyException Wird geworfen, wenn der Schlüssel - * ungültig ist. - */ - @Test - void testWrongMessage2() - throws IllegalKeyException, IllegalMessageException { - String key = "K"; - CrypterCaesar c = new CrypterCaesar(); - - Assertions.assertThrows(IllegalKeyException.class, () -> { - c.encrypt(key, "üäaD&"); - }); - } - - /** - * Testet auf falsche Nachricht. - * - * @throws IllegalMessageException Wird geworfen, wenn die - * Nachricht ungültig ist. - * @throws IllegalKeyException Wird geworfen, wenn der Schlüssel - * ungültig ist. - */ - @Test - void testWrongCypher1() - throws IllegalKeyException, IllegalMessageException { - String key = "K"; - CrypterCaesar c = new CrypterCaesar(); - - Assertions.assertThrows(IllegalKeyException.class, () -> { - c.decrypt(key, "üäaD&"); - }); - } - - /** - * Testet auf falsche Nachricht. - * - * @throws IllegalMessageException Wird geworfen, wenn die - * Nachricht ungültig ist. - * @throws IllegalKeyException Wird geworfen, wenn der Schlüssel - * ungültig ist. - */ - @Test - void testWrongCypher2() - throws IllegalKeyException, IllegalMessageException { - String key = "K"; - CrypterCaesar c = new CrypterCaesar(); - Assertions.assertThrows(IllegalKeyException.class, () -> { - c.decrypt(key, "DIESiSTEINTEST&"); - }); - } - - - /** - * Testet die Verschlüsselung an sich. - * - * @throws IllegalMessageException Wird geworfen, wenn die - * Nachricht ungültig ist. - * @throws IllegalKeyException Wird geworfen, wenn der Schlüssel - * ungültig ist. - */ - @Test - void testCaesar() - throws IllegalKeyException, IllegalMessageException { - String klarText = "KATHARGOMUSSFALLEN"; - CrypterCaesar c = new CrypterCaesar(); - assertEquals(klarText, c.decrypt("C", c.encrypt("C", klarText))); - assertEquals("FDHVDU", c.encrypt("C", "CAESAR")); - assertEquals(klarText, c.encrypt("Z", klarText)); - } -} diff --git a/solutions/src/main/java/pr2/exceptions/eigene_ausnahme/Fuse.java b/solutions/src/main/java/pr2/exceptions/eigene_ausnahme/Fuse.java deleted file mode 100644 index 6f30f3e..0000000 --- a/solutions/src/main/java/pr2/exceptions/eigene_ausnahme/Fuse.java +++ /dev/null @@ -1,58 +0,0 @@ -package pr2.exceptions.eigene_ausnahme; - -/** - * Eine Sicherung im Stromkreis. - */ -public class Fuse { - - /** - * 16 Ampere-Sicherung. - */ - public static final int A16 = 16; - - /** - * 25 Ampere-Sicherung. - */ - public static final int A25 = 25; - - /** - * 32 Ampere-Sicherung. - */ - public static final int A32 = 32; - - /** - * Strom, bei dem die Sicherung auslöst. - */ - private final int tripCurrent; - - /** - * Legt eine neue Sicherung an. - * - * @param tripCurrent Strom, bei dem die Sicherung auslösen soll. - * @throws IllegalCurrentException Ausnahme bei einem - * ungültigen Spannungswert. - */ - public Fuse(int tripCurrent) throws IllegalCurrentException { - switch (tripCurrent) { - case A16: - case A25: - case A32: - this.tripCurrent = tripCurrent; - break; - default: - throw new IllegalCurrentException(tripCurrent); - } - } - - /** - * Die Sicherung benutzen. - * - * @param current Strom, der durch die Sicherung fließt. - * @throws FuseTrippedException wird geworfen, wenn der Srom zu groß wird. - */ - public void use(int current) throws FuseTrippedException { - if (current > tripCurrent) { - throw new FuseTrippedException(current, tripCurrent); - } - } -} diff --git a/solutions/src/main/java/pr2/exceptions/eigene_ausnahme/FuseTrippedException.java b/solutions/src/main/java/pr2/exceptions/eigene_ausnahme/FuseTrippedException.java deleted file mode 100644 index 82308a4..0000000 --- a/solutions/src/main/java/pr2/exceptions/eigene_ausnahme/FuseTrippedException.java +++ /dev/null @@ -1,37 +0,0 @@ -package pr2.exceptions.eigene_ausnahme; - -/** - * Ausnahme, wenn die Sicherung auslöst. - */ -public class FuseTrippedException extends Exception { - /** - * Strom, bei dem die Sicherung ausgelöst hat. - */ - private final int current; - - /** - * Auslösestrom der Sicherung. - */ - private final int tripCurrent; - - /** - * Erzeugt eine neue Ausnahme. - * - * @param current Strom, bei dem die Sicherung ausgelöst hat. - * @param tripCurrent Auslösestrom der Sicherung. - */ - public FuseTrippedException(int current, int tripCurrent) { - super(); - this.current = current; - this.tripCurrent = tripCurrent; - } - - /** - * @see java.lang.Throwable#toString() - */ - @Override - public String toString() { - return String.format("Maximaler Strom: %d, Auslösestrom: %d", - tripCurrent, current); - } -} diff --git a/solutions/src/main/java/pr2/exceptions/eigene_ausnahme/IllegalCurrentException.java b/solutions/src/main/java/pr2/exceptions/eigene_ausnahme/IllegalCurrentException.java deleted file mode 100644 index 980783e..0000000 --- a/solutions/src/main/java/pr2/exceptions/eigene_ausnahme/IllegalCurrentException.java +++ /dev/null @@ -1,30 +0,0 @@ -package pr2.exceptions.eigene_ausnahme; - -/** - * Ausnahme, wenn eine Sicherung angelegt werden soll, die es nicht gibt. - */ -public class IllegalCurrentException extends Exception { - - /** - * Übergebener Strom. - */ - private final int givenValue; - - /** - * Erzeugt eine neue Ausnahme. - * - * @param givenValue gegebener Strom. - */ - public IllegalCurrentException(int givenValue) { - super(); - this.givenValue = givenValue; - } - - /** - * @see java.lang.Throwable#toString() - */ - @Override - public String toString() { - return String.format("Falscher Wert %d", givenValue); - } -} diff --git a/solutions/src/main/java/pr2/exceptions/eigene_ausnahme/test/FuseTest.java b/solutions/src/main/java/pr2/exceptions/eigene_ausnahme/test/FuseTest.java deleted file mode 100644 index 1d37afb..0000000 --- a/solutions/src/main/java/pr2/exceptions/eigene_ausnahme/test/FuseTest.java +++ /dev/null @@ -1,158 +0,0 @@ -package pr2.exceptions.eigene_ausnahme.test; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import pr2.exceptions.eigene_ausnahme.Fuse; -import pr2.exceptions.eigene_ausnahme.FuseTrippedException; -import pr2.exceptions.eigene_ausnahme.IllegalCurrentException; - -/** - * Testet die Sicherung. - */ -public class FuseTest { - - - /** - * Testet die Erzeugung von Sicherungen mit gültigen Werten. - * - * @throws IllegalCurrentException ungültiger Wert für die Sicherung. - */ - @Test - void testCreationValid() throws IllegalCurrentException { - new Fuse(Fuse.A16); - new Fuse(Fuse.A25); - new Fuse(Fuse.A32); - } - - /** - * Testet die Erzeugung von Sicherungen mit ungültigen Werten. - * - * @throws IllegalCurrentException ungültiger Wert für die Sicherung. - */ - @Test - void testCreationValid1() throws IllegalCurrentException { - Assertions.assertThrows(IllegalCurrentException.class, () -> { - new Fuse(15); - }); - } - - /** - * Testet die Erzeugung von Sicherungen mit ungültigen Werten. - * - * @throws IllegalCurrentException ungültiger Wert für die Sicherung. - */ - @Test - void testCreationValid2() throws IllegalCurrentException { - Assertions.assertThrows(IllegalCurrentException.class, () -> { - new Fuse(-1); - }); - } - - /** - * Testet die Erzeugung von Sicherungen mit ungültigen Werten. - * - * @throws IllegalCurrentException ungültiger Wert für die Sicherung. - */ - @Test - void testCreationValid3() throws IllegalCurrentException { - Assertions.assertThrows(IllegalCurrentException.class, () -> { - new Fuse(0); - }); - } - - /** - * Testet die Erzeugung von Sicherungen mit ungültigen Werten. - * - * @throws IllegalCurrentException ungültiger Wert für die Sicherung. - */ - @Test - void testCreationValid4() throws IllegalCurrentException { - Assertions.assertThrows(IllegalCurrentException.class, () -> { - new Fuse(Integer.MAX_VALUE); - }); - } - - /** - * Testet die Erzeugung von Sicherungen mit ungültigen Werten. - * - * @throws IllegalCurrentException ungültiger Wert für die Sicherung. - */ - @Test - void testCreationValid5() throws IllegalCurrentException { - Assertions.assertThrows(IllegalCurrentException.class, () -> { - new Fuse(Integer.MIN_VALUE); - }); - } - - /** - * Testet das Auslösen der Sicherung. - * - * @throws FuseTrippedException Sicherung hat ausgelöst. - * @throws IllegalCurrentException ungültiger Wert für die Sicherung. - */ - @Test - void testTripping1() - throws FuseTrippedException, IllegalCurrentException { - - Fuse f = new Fuse(Fuse.A16); - f.use(5); - f.use(16); - f.use(0); - - f = new Fuse(Fuse.A25); - f.use(5); - f.use(16); - f.use(25); - - - Assertions.assertThrows(FuseTrippedException.class, () -> { - Fuse f2 = new Fuse(Fuse.A32); - f2.use(0); - f2.use(16); - f2.use(25); - }); - } - - /** - * Testet das Auslösen der Sicherung. - * - * @throws FuseTrippedException Sicherung hat ausgelöst. - * @throws IllegalCurrentException ungültiger Wert für die Sicherung. - */ - @Test - void testTripping2() - throws FuseTrippedException, IllegalCurrentException { - Assertions.assertThrows(FuseTrippedException.class, () -> { - new Fuse(Fuse.A16).use(17); - }); - } - - /** - * Testet das Auslösen der Sicherung. - * - * @throws FuseTrippedException Sicherung hat ausgelöst. - * @throws IllegalCurrentException ungültiger Wert für die Sicherung. - */ - @Test - void testTripping3() - throws FuseTrippedException, IllegalCurrentException { - - Assertions.assertThrows(FuseTrippedException.class, () -> { - new Fuse(Fuse.A16).use(Integer.MAX_VALUE); - }); - } - - /** - * Testet das Auslösen der Sicherung. - * - * @throws FuseTrippedException Sicherung hat ausgelöst. - * @throws IllegalCurrentException ungültiger Wert für die Sicherung. - */ - @Test - void testTripping4() - throws FuseTrippedException, IllegalCurrentException { - Assertions.assertThrows(FuseTrippedException.class, () -> { - new Fuse(Fuse.A32).use(40); - }); - } -} diff --git a/solutions/src/main/java/pr2/exceptions/fakultaet/Fakultaet.java b/solutions/src/main/java/pr2/exceptions/fakultaet/Fakultaet.java deleted file mode 100644 index 736edf6..0000000 --- a/solutions/src/main/java/pr2/exceptions/fakultaet/Fakultaet.java +++ /dev/null @@ -1,18 +0,0 @@ -package pr2.exceptions.fakultaet; - -public class Fakultaet { - - public int fact(int n) throws FakultaetException { - if (n < 0) { - throw new FakultaetException("Keine negativen Zahlen!", n); - } - else if (n > 20) { - throw new FakultaetException("Keine Zahlen > 20", n); - } - return factIntern(n); - } - - private int factIntern(int n) { - return (n == 0) ? 1 : factIntern(n - 1) * n; - } -} diff --git a/solutions/src/main/java/pr2/exceptions/fakultaet/FakultaetException.java b/solutions/src/main/java/pr2/exceptions/fakultaet/FakultaetException.java deleted file mode 100644 index 5c47848..0000000 --- a/solutions/src/main/java/pr2/exceptions/fakultaet/FakultaetException.java +++ /dev/null @@ -1,15 +0,0 @@ -package pr2.exceptions.fakultaet; - -public class FakultaetException extends Exception { - - private final int zahl; - - public FakultaetException(String message, int zahl) { - super(message); - this.zahl = zahl; - } - - public int getZahl() { - return zahl; - } -} diff --git a/solutions/src/main/java/pr2/exceptions/fakultaet/test/FakultaetTest.java b/solutions/src/main/java/pr2/exceptions/fakultaet/test/FakultaetTest.java deleted file mode 100644 index 3892e52..0000000 --- a/solutions/src/main/java/pr2/exceptions/fakultaet/test/FakultaetTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package pr2.exceptions.fakultaet.test; - -import org.junit.jupiter.api.Test; -import pr2.exceptions.fakultaet.Fakultaet; -import pr2.exceptions.fakultaet.FakultaetException; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; - -public class FakultaetTest { - - @Test - void testFact() throws FakultaetException { - Fakultaet f = new Fakultaet(); - assertEquals(1, f.fact(0)); - assertEquals(1, f.fact(1)); - assertEquals(2, f.fact(2)); - assertEquals(6, f.fact(3)); - assertEquals(24, f.fact(4)); - assertEquals(3628800, f.fact(10)); - } - - @Test - void testFactEx1() { - assertThrows(FakultaetException.class, () -> { - Fakultaet f = new Fakultaet(); - f.fact(-1); - }); - } - - @Test - void testFactEx2() { - assertThrows(FakultaetException.class, () -> { - Fakultaet f = new Fakultaet(); - f.fact(21); - }); - } -} diff --git a/solutions/src/main/java/pr2/exceptions/handle_or_declare/Buchstabenzaehler.java b/solutions/src/main/java/pr2/exceptions/handle_or_declare/Buchstabenzaehler.java deleted file mode 100644 index 895b5ab..0000000 --- a/solutions/src/main/java/pr2/exceptions/handle_or_declare/Buchstabenzaehler.java +++ /dev/null @@ -1,124 +0,0 @@ -package pr2.exceptions.handle_or_declare; - -import java.io.BufferedReader; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.util.Scanner; - -/** - * Anwendung, die die Buchstabenhäufigkeit in einem Text analysiert. - */ -public class Buchstabenzaehler { - - /** - * Einstiegspunkt in das Programm. - * - * @param args Kommandozeilenargumente - */ - public static void main(String[] args) { - Buchstabenzaehler bs = new Buchstabenzaehler(); - - try { - bs.run(); - } - catch (StatistikException e) { - System.out.println("Statistik-Fehler: " + e); - } - } - - /** - * Startet den Buchstabenzaehler. - * - * @throws StatistikException Fehler bei der Berechnung der - * Buchstabenhäufigkeit. - */ - private void run() throws StatistikException { - System.out.print("Bitte geben Sie den Dateinamen an: "); - Scanner scanner = new Scanner(System.in); - String dateiname = scanner.nextLine(); - - int[] statistik; - - - - - try { - statistik = parseFile("assets/" + dateiname); - printStatistik(statistik); - } - catch (FileNotFoundException e) { - System.out.println("Datei gibt es nicht"); - } - catch (IOException e) { - System.out.println("Fehler beim Zugriff auf die Datei: " + e); - } - finally { - scanner.close(); - } - } - - /** - * Druckt die Statistik aus. - * - * @param statistik Statistik - * @throws StatistikException Fehler bei den Eingabedaten - */ - private void printStatistik(int[] statistik) throws StatistikException { - - int summe = 0; - - for (int haeufigkeit : statistik) { - summe += haeufigkeit; - } - - double prozentSumme = 0.0; - - for (char c = 'a'; c <= 'z'; c++) { - int anzahl = statistik[c - 'a']; - double prozent = (double) anzahl / (double) summe * 100; - System.out.printf("%s: %.2f%% %n", "" + c, prozent); - - prozentSumme += prozent; - } - - if ((prozentSumme < 99.0) || (prozentSumme > 101.0)) { - throw new StatistikException(Double.toString(prozentSumme)); - } - - System.out.printf("Summe: %.2f%% %n", prozentSumme); - } - - /** - * Analysiert die übergebene Datei und berechnet die Buchstabenhäufigkeit. - * - * @param filename Dateiname - * @return die Buchstabenhäufigkeit. Das 'a' ist das erste Element, - * das 'b' das zweite etc. - * @throws IOException generelles IO-Problem - * @throws FileNotFoundException Datei gibt es nicht - */ - private int[] parseFile(String filename) - throws IOException, FileNotFoundException { - - int[] statistik = new int['z' - 'a' + 1]; - - BufferedReader br = new BufferedReader(new FileReader(filename)); - - String line; - - while ((line = br.readLine()) != null) { - char[] chars = line.toLowerCase().toCharArray(); - - for (char c : chars) { - if (('a' <= c) && (c <= 'z')) { - statistik[c - 'a']++; - } - } - } - - br.close(); - - return statistik; - } -} diff --git a/solutions/src/main/java/pr2/exceptions/handle_or_declare/StatistikException.java b/solutions/src/main/java/pr2/exceptions/handle_or_declare/StatistikException.java deleted file mode 100644 index 0d83170..0000000 --- a/solutions/src/main/java/pr2/exceptions/handle_or_declare/StatistikException.java +++ /dev/null @@ -1,31 +0,0 @@ -package pr2.exceptions.handle_or_declare; - -/** - * Ausnahme, wenn die Statisitk nicht konsistent ist. - */ -public class StatistikException extends Exception { - - /** - * Legt eine neue Ausnahme an. - */ - public StatistikException() { - super(); - } - - /** - * Legt eine neue Ausnahme an. - * - * @param message die Nachricht. - */ - public StatistikException(String message) { - super(message); - } - - /** - * @see java.lang.Throwable#toString() - */ - @Override - public String toString() { - return getMessage(); - } -} diff --git a/solutions/src/main/java/pr2/exceptions/try_catch/Zahlenraten.java b/solutions/src/main/java/pr2/exceptions/try_catch/Zahlenraten.java deleted file mode 100644 index 712287d..0000000 --- a/solutions/src/main/java/pr2/exceptions/try_catch/Zahlenraten.java +++ /dev/null @@ -1,67 +0,0 @@ -package pr2.exceptions.try_catch; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.Random; - -/** - * Ein simples Zahlenraten-Spiel. - */ -public final class Zahlenraten { - - /** - * Liest einen String von der Tastatur. - * - * @return der gelesene String - * @throws IOException Probleme mit der Console - */ - private static String readNumber() throws IOException { - BufferedReader br = - new BufferedReader(new InputStreamReader(System.in)); - return br.readLine(); - } - - /** - * Hauptmethode. - * - * @param args Kommandozeilenargumente - */ - public static void main(String[] args) { - - // zu ratende Zahl bestimmen - int zahl = new Random().nextInt(100) + 1; - - int versuche = 0; - - while (true) { - System.out.print("Bitte geben Sie eine Zahl ein: "); - - int geraten; - - try { - geraten = Integer.parseInt(readNumber()); - } - catch (IOException e) { - System.out.println("Problem mit der Konsole."); - break; - } - catch (NumberFormatException e) { - System.out.println("Bitte nur Zahlen eingeben!"); - continue; - } - - versuche++; - - if (geraten < zahl) { - System.out.println("Zu niedrig"); - } - else if (geraten > zahl) { - System.out.println("Zu hoch."); - } - else { - System.out.printf("Richtig in %d Versuchen", versuche); - break; - } - } - } diff --git a/solutions/src/main/java/pr2/generics/einfach/Liste.java b/solutions/src/main/java/pr2/generics/einfach/Liste.java deleted file mode 100644 index 25518e5..0000000 --- a/solutions/src/main/java/pr2/generics/einfach/Liste.java +++ /dev/null @@ -1,90 +0,0 @@ -package pr2.generics.einfach; - -/** - * Eine einfache, verkettete Liste. - * - * @param Typ der gespeicherten Objekte - */ - -public class Liste { - - /** - * Referenz auf den ersten Knoten. - */ - private ListeNode first; - - /** - * Referenz auf den aktuellen Knoten. - */ - private ListeNode current; - - /** - * Fügt ein neues Element an das Ende der Liste an. - * - * @param data das Element - */ - public void add(T data) { - - ListeNode nextNode = new ListeNode<>(data); - - if (current == null) { - // Liste komplett leer - first = nextNode; - current = nextNode; - } - else { - current.next = nextNode; - current = nextNode; - } - } - - /** - * Liest das Element an der gegebenen Position. - * - * @param index Index, beginnend bei 0. - * @return Das Element oder {@code null}, wenn es nicht gefunden wurde. - */ - public T get(int index) { - int count = 0; - ListeNode node = first; - - while ((node != null) && (count < index)) { - node = node.next; - count++; - } - - if ((count == index) && (node != null)) { - return node.data; - } - else { - // index does not exist - return null; - } - } - - /** - * Löscht die Liste und entfernt alle Elemente. - */ - public void clear() { - first = null; - current = null; - } - - /** - * Liefert die Anzahl der Elemente der Liste zurück. - * - * @return die Anzahl der Elemente. - */ - public int size() { - int count = 0; - ListeNode node = first; - - while (node != null) { - node = node.next; - count++; - } - - return count; - } -} - diff --git a/solutions/src/main/java/pr2/generics/einfach/ListeNode.java b/solutions/src/main/java/pr2/generics/einfach/ListeNode.java deleted file mode 100644 index b981cd2..0000000 --- a/solutions/src/main/java/pr2/generics/einfach/ListeNode.java +++ /dev/null @@ -1,30 +0,0 @@ -package pr2.generics.einfach; - - -/** - * Interne Repräsentation der Knoten in der Liste. - * - * @param Typ der gespeicherten Daten. - */ -class ListeNode { - - /** - * Daten. - */ - T data; - - /** - * Referenz auf den nächsten Knoten. - */ - ListeNode next; - - /** - * Legt einen neuen Knoten an. - * - * @param data daten, die gespeichert werden - */ - ListeNode(T data) { - this.data = data; - } -} - diff --git a/solutions/src/main/java/pr2/generics/einfach/test/ListeTest.java b/solutions/src/main/java/pr2/generics/einfach/test/ListeTest.java deleted file mode 100644 index b9d09bc..0000000 --- a/solutions/src/main/java/pr2/generics/einfach/test/ListeTest.java +++ /dev/null @@ -1,61 +0,0 @@ -package pr2.generics.einfach.test; - -import org.junit.jupiter.api.Test; -import pr2.generics.einfach.Liste; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; - -/** - * Test für die Liste. - */ -public class ListeTest { - - /** - * Testet das Hinzufügen und Löschen der Liste. - */ - @Test - void testAddAndClear() { - Liste l = new Liste<>(); - - assertEquals(0, l.size()); - - l.add("Hallo"); - assertEquals(1, l.size()); - l.add("Hugo"); - assertEquals(2, l.size()); - l.add("Peter"); - l.add("Alfons"); - assertEquals(4, l.size()); - - l.clear(); - assertEquals(0, l.size()); - } - - /** - * Testet das Lesen von Elementen. - */ - @Test - void testGet() { - Liste l = new Liste<>(); - l.add("Hallo"); - l.add("Hugo"); - l.add("Peter"); - l.add("Alfons"); - - assertNull(l.get(-1)); - assertNull(l.get(4)); - assertEquals("Hallo", l.get(0)); - assertEquals("Hugo", l.get(1)); - assertEquals("Peter", l.get(2)); - assertEquals("Alfons", l.get(3)); - - assertEquals(4, l.size()); - l.clear(); - assertEquals(0, l.size()); - assertNull(l.get(0)); - assertNull(l.get(1)); - assertNull(l.get(2)); - assertNull(l.get(3)); - } -} diff --git a/solutions/src/main/java/pr2/generics/number_pair/Main.java b/solutions/src/main/java/pr2/generics/number_pair/Main.java deleted file mode 100644 index fcbc53b..0000000 --- a/solutions/src/main/java/pr2/generics/number_pair/Main.java +++ /dev/null @@ -1,15 +0,0 @@ -package pr2.generics.number_pair; - -public class Main { - public static void main(String[] args) { - var note = new Pair("Peter", 1); - var name = new Pair("Peter", "Meier"); - var tel = new NumberPair(621, 292122); - - System.out.printf("%s:%d\n", note.getFirst(), note.getSecond()); - - System.out.printf("%s %s\n", name.getFirst(), name.getSecond()); - - System.out.printf("%d %d\n", tel.getFirst(), tel.getSecond()); - } -} diff --git a/solutions/src/main/java/pr2/generics/number_pair/NumberPair.java b/solutions/src/main/java/pr2/generics/number_pair/NumberPair.java deleted file mode 100644 index beaa2cf..0000000 --- a/solutions/src/main/java/pr2/generics/number_pair/NumberPair.java +++ /dev/null @@ -1,8 +0,0 @@ -package pr2.generics.number_pair; - -public class NumberPair extends Pair { - - public NumberPair(T first, T second) { - super(first, second); - } -} diff --git a/solutions/src/main/java/pr2/generics/number_pair/Pair.java b/solutions/src/main/java/pr2/generics/number_pair/Pair.java deleted file mode 100644 index 63d841e..0000000 --- a/solutions/src/main/java/pr2/generics/number_pair/Pair.java +++ /dev/null @@ -1,20 +0,0 @@ -package pr2.generics.number_pair; - -public class Pair { - - private final T first; - private final V second; - - public Pair(T first, V second) { - this.first = first; - this.second = second; - } - - public T getFirst() { - return first; - } - - public V getSecond() { - return second; - } -} diff --git a/solutions/src/main/java/pr2/generics/pair/Main.java b/solutions/src/main/java/pr2/generics/pair/Main.java deleted file mode 100644 index 2df11ce..0000000 --- a/solutions/src/main/java/pr2/generics/pair/Main.java +++ /dev/null @@ -1,17 +0,0 @@ -package pr2.generics.pair; - -public class Main { - public static void main(String[] args) { - var note1 = new Pair("Peter", 1); - var note2 = new Pair("Frank", 3); - var note3 = new Pair("Sabine", 1); - - var name = new Pair("Peter", "Meier"); - - System.out.printf("%s:%d\n", note1.getFirst(), note1.getSecond()); - System.out.printf("%s:%d\n", note2.getFirst(), note1.getSecond()); - System.out.printf("%s:%d\n", note3.getFirst(), note1.getSecond()); - - System.out.printf("%s %s\n", name.getFirst(), name.getSecond()); - } -} diff --git a/solutions/src/main/java/pr2/generics/pair/Pair.java b/solutions/src/main/java/pr2/generics/pair/Pair.java deleted file mode 100644 index 8680eb1..0000000 --- a/solutions/src/main/java/pr2/generics/pair/Pair.java +++ /dev/null @@ -1,20 +0,0 @@ -package pr2.generics.pair; - -public class Pair { - - private final T first; - private final V second; - - public Pair(T first, V second) { - this.first = first; - this.second = second; - } - - public T getFirst() { - return first; - } - - public V getSecond() { - return second; - } -} diff --git a/solutions/src/main/java/pr2/generics/pairlist/Main.java b/solutions/src/main/java/pr2/generics/pairlist/Main.java deleted file mode 100644 index d414e41..0000000 --- a/solutions/src/main/java/pr2/generics/pairlist/Main.java +++ /dev/null @@ -1,19 +0,0 @@ -package pr2.generics.pairlist; - -public class Main { - public static void main(String[] args) { - var note1 = new Pair("Peter", 1); - var note2 = new Pair("Frank", 3); - var note3 = new Pair("Sabine", 1); - - var pl = new PairList(3); - pl.add(note1); - pl.add(note2); - pl.add(note3); - - for (int i = 0; i < 3; i++) { - System.out.printf("%s:%d\n", pl.get(i).getFirst(), - pl.get(i).getSecond()); - } - } -} diff --git a/solutions/src/main/java/pr2/generics/pairlist/Pair.java b/solutions/src/main/java/pr2/generics/pairlist/Pair.java deleted file mode 100644 index 3fbbfdf..0000000 --- a/solutions/src/main/java/pr2/generics/pairlist/Pair.java +++ /dev/null @@ -1,20 +0,0 @@ -package pr2.generics.pairlist; - -public class Pair { - - private final T first; - private final V second; - - public Pair(T first, V second) { - this.first = first; - this.second = second; - } - - public T getFirst() { - return first; - } - - public V getSecond() { - return second; - } -} diff --git a/solutions/src/main/java/pr2/generics/pairlist/PairList.java b/solutions/src/main/java/pr2/generics/pairlist/PairList.java deleted file mode 100644 index 0d6a7e1..0000000 --- a/solutions/src/main/java/pr2/generics/pairlist/PairList.java +++ /dev/null @@ -1,20 +0,0 @@ -package pr2.generics.pairlist; - -public class PairList { - - protected final Pair[] elements; - protected int pos; - - @SuppressWarnings("unchecked") - public PairList(int size) { - elements = (Pair[]) new Pair[size]; - } - - public void add(Pair element) { - elements[pos++] = element; - } - - public Pair get(int index) { - return elements[index]; - } -} diff --git a/solutions/src/main/java/pr2/generics/printer/CollectionPrinter.java b/solutions/src/main/java/pr2/generics/printer/CollectionPrinter.java deleted file mode 100644 index 4c895ab..0000000 --- a/solutions/src/main/java/pr2/generics/printer/CollectionPrinter.java +++ /dev/null @@ -1,11 +0,0 @@ -package pr2.generics.printer; - -import java.util.Collection; - -public class CollectionPrinter { - public static void print(Collection collection) { - for (Object object : collection) { - System.out.println(object); - } - } -} diff --git a/solutions/src/main/java/pr2/generics/printer/Main.java b/solutions/src/main/java/pr2/generics/printer/Main.java deleted file mode 100644 index 4f162d5..0000000 --- a/solutions/src/main/java/pr2/generics/printer/Main.java +++ /dev/null @@ -1,23 +0,0 @@ -package pr2.generics.printer; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -public class Main { - public static void main(String[] args) { - List ls = new ArrayList<>(); - List li = new ArrayList<>(); - ls.add("PR2"); - ls.add("ist"); - ls.add("cool"); - Set s = new HashSet<>(ls); - li.add(23); - li.add(42); - - CollectionPrinter.print(ls); - CollectionPrinter.print(li); - CollectionPrinter.print(s); - } -} diff --git a/solutions/src/main/java/pr2/generics/queue/Queue.java b/solutions/src/main/java/pr2/generics/queue/Queue.java deleted file mode 100644 index 258604a..0000000 --- a/solutions/src/main/java/pr2/generics/queue/Queue.java +++ /dev/null @@ -1,39 +0,0 @@ -package pr2.generics.queue; - -public class Queue { - - private final T[] elements; - private int pos = 0; - private int pos2 = 0; - - @SuppressWarnings("unchecked") - public Queue(int size) { - elements = (T[]) new Object[size]; - } - - public void offer(T element) { - elements[pos] = element; - pos++; - pos = pos % elements.length; - } - - public T poll() { - T element = elements[pos2]; - elements[pos2] = null; - pos2++; - pos2 = pos2 % elements.length; - return element; - } - - public void addAll(Queue other) { - for (T t : other.elements) { - offer(t); - } - } - - public void copyInto(Queue other) { - for (T t : elements) { - other.offer(t); - } - } -} diff --git a/solutions/src/main/java/pr2/generics/same_pair/Main.java b/solutions/src/main/java/pr2/generics/same_pair/Main.java deleted file mode 100644 index 0b85368..0000000 --- a/solutions/src/main/java/pr2/generics/same_pair/Main.java +++ /dev/null @@ -1,15 +0,0 @@ -package pr2.generics.same_pair; - -public class Main { - public static void main(String[] args) { - var note = new Pair("Peter", 1); - var name = new SamePair("Peter", "Meier"); - var tel = new SamePair(621, 2009992); - - System.out.printf("%s:%d\n", note.getFirst(), note.getSecond()); - - System.out.printf("%s %s\n", name.getFirst(), name.getSecond()); - - System.out.printf("%d %d\n", tel.getFirst(), tel.getSecond()); - } -} diff --git a/solutions/src/main/java/pr2/generics/same_pair/Pair.java b/solutions/src/main/java/pr2/generics/same_pair/Pair.java deleted file mode 100644 index 587225a..0000000 --- a/solutions/src/main/java/pr2/generics/same_pair/Pair.java +++ /dev/null @@ -1,20 +0,0 @@ -package pr2.generics.same_pair; - -public class Pair { - - private final T first; - private final V second; - - public Pair(T first, V second) { - this.first = first; - this.second = second; - } - - public T getFirst() { - return first; - } - - public V getSecond() { - return second; - } -} diff --git a/solutions/src/main/java/pr2/generics/same_pair/SamePair.java b/solutions/src/main/java/pr2/generics/same_pair/SamePair.java deleted file mode 100644 index 32323a8..0000000 --- a/solutions/src/main/java/pr2/generics/same_pair/SamePair.java +++ /dev/null @@ -1,8 +0,0 @@ -package pr2.generics.same_pair; - -public class SamePair extends Pair { - - public SamePair(T first, T second) { - super(first, second); - } -} diff --git a/solutions/src/main/java/pr2/generics/super_extends/Liste.java b/solutions/src/main/java/pr2/generics/super_extends/Liste.java deleted file mode 100644 index 26cce2b..0000000 --- a/solutions/src/main/java/pr2/generics/super_extends/Liste.java +++ /dev/null @@ -1,108 +0,0 @@ -package pr2.generics.super_extends; - -/** - * Eine einfache, verkettete Liste. - * - * @param Typ der gespeicherten Objekte - */ -public class Liste { - - /** - * Referenz auf den ersten Knoten. - */ - private ListeNode first; - - /** - * Referenz auf den aktuellen Knoten. - */ - private ListeNode current; - - /** - * Fügt ein neues Element an das Ende der Liste an. - * - * @param data das Element - */ - public void add(T data) { - - ListeNode nextNode = new ListeNode<>(data); - - if (current == null) { - // Liste komplett leer - first = nextNode; - current = nextNode; - } - else { - current.next = nextNode; - current = nextNode; - } - } - - /** - * Liest das Element an der gegebenen Position. - * - * @param index Index, beginnend bei 0. - * @return Das Element oder {@code null}, wenn es nicht gefunden wurde. - */ - public T get(int index) { - int count = 0; - ListeNode node = first; - - while ((node != null) && (count < index)) { - node = node.next; - count++; - } - - if ((count == index) && (node != null)) { - return node.data; - } - else { - // index does not exist - return null; - } - } - - /** - * Löscht die Liste und entfernt alle Elemente. - */ - public void clear() { - first = null; - current = null; - } - - /** - * Liefert die Anzahl der Elemente der Liste zurück. - * - * @return die Anzahl der Elemente. - */ - public int size() { - int count = 0; - ListeNode node = first; - - while (node != null) { - node = node.next; - count++; - } - - return count; - } - - /** - * Kopiert alle Elemente dieser Liste in die andere Liste. - * - * @param other die andere Liste. - */ - public void copyInto(Liste other) { - for (int i = 0; i < size(); i++) { - other.add(get(i)); - } - } - - /** - * Füllt diese Liste mit dem Inhalt der übergebenen Liste. - * - * @param other die andere Liste. - */ - public void fillFrom(Liste other) { - other.copyInto(this); - } -} diff --git a/solutions/src/main/java/pr2/generics/super_extends/ListeNode.java b/solutions/src/main/java/pr2/generics/super_extends/ListeNode.java deleted file mode 100644 index 487f1b1..0000000 --- a/solutions/src/main/java/pr2/generics/super_extends/ListeNode.java +++ /dev/null @@ -1,28 +0,0 @@ -package pr2.generics.super_extends; - -/** - * Interne Repräsentation der Knoten in der Liste. - * - * @param Typ der gespeicherten Daten. - */ -class ListeNode { - - /** - * Daten. - */ - T data; - - /** - * Referenz auf den nächsten Knoten. - */ - ListeNode next; - - /** - * Legt einen neuen Knoten an. - * - * @param data daten, die gespeichert werden - */ - ListeNode(T data) { - this.data = data; - } -} \ No newline at end of file diff --git a/solutions/src/main/java/pr2/generics/super_extends/test/ListeTest.java b/solutions/src/main/java/pr2/generics/super_extends/test/ListeTest.java deleted file mode 100644 index 84997ad..0000000 --- a/solutions/src/main/java/pr2/generics/super_extends/test/ListeTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package pr2.generics.super_extends.test; - -import org.junit.jupiter.api.Test; -import pr2.generics.super_extends.Liste; - -import static org.junit.jupiter.api.Assertions.assertEquals; - - -/** - * Test für die Liste. - */ -public class ListeTest { - - /** - * Testet das Umkopieren. - */ - @Test - void testAddAndClear() { - Liste ls = new Liste<>(); - Liste lo = new Liste<>(); - - ls.add("Hallo"); - ls.add("Hugo"); - ls.add("Peter"); - ls.add("Alfons"); - - ls.copyInto(lo); - - assertEquals("Hallo", lo.get(0)); - assertEquals("Hugo", lo.get(1)); - assertEquals("Peter", lo.get(2)); - assertEquals("Alfons", lo.get(3)); - - lo = new Liste<>(); - lo.fillFrom(ls); - - assertEquals("Hallo", lo.get(0)); - assertEquals("Hugo", lo.get(1)); - assertEquals("Peter", lo.get(2)); - assertEquals("Alfons", lo.get(3)); - } -} diff --git a/solutions/src/main/java/pr2/generics/verwenden/GameBoard.java b/solutions/src/main/java/pr2/generics/verwenden/GameBoard.java deleted file mode 100644 index 9de262e..0000000 --- a/solutions/src/main/java/pr2/generics/verwenden/GameBoard.java +++ /dev/null @@ -1,169 +0,0 @@ -package pr2.generics.verwenden; - -import de.smits_net.games.framework.board.Board; -import de.smits_net.games.framework.image.SimpleImage; -import de.smits_net.games.framework.sprite.Sprite; -import de.smits_net.games.framework.sprite.Sprite.BoundaryPolicy; -import de.smits_net.games.framework.sprite.Velocity; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Point; -import java.awt.event.MouseEvent; -import java.util.Random; -import java.util.Stack; - -/** - * Spielfeld. - */ -public class GameBoard extends Board { - - /** - * Zufallszahlengenerator. - */ - private final Random rnd = new Random(); - - /** - * Münzstapel. - */ - private final Stack stapel = new Stack<>(); - - /** - * A moving coin. - */ - private Sprite moving; - - /** - * Punkte. - */ - private int points = 0; - - /** - * Zeitpunkt des ersten Klicks. - */ - private long startzeit; - - /** - * Erzeugt ein neues Board. - */ - public GameBoard() { - // neues Spielfeld anlegen - super(10, new Dimension(400, 400), Color.BLACK); - - // Münzen anlegen - for (int i = 0; i < 20; i++) { - stapel.push(createCoin()); - } - } - - /** - * Legt eine zufällige Münze an. - * - * @return die Münze als Sprite. - */ - private Sprite createCoin() { - final String prefix = "pr2/generics/verwendung"; - - String asset; - - switch (rnd.nextInt(8)) { - case 0: - asset = prefix + "/1c.png"; - break; - case 1: - asset = prefix + "/2c.png"; - break; - case 3: - asset = prefix + "/5c.png"; - break; - case 4: - asset = prefix + "/10c.png"; - break; - case 5: - asset = prefix + "/20c.png"; - break; - case 6: - asset = prefix + "/50c.png"; - break; - case 7: - asset = prefix + "/1e.png"; - break; - default: - asset = prefix + "/2e.png"; - break; - } - - int offset = rnd.nextInt(10); - - return new Sprite(this, new Point(100 + offset, 100 + offset), - BoundaryPolicy.NONE, new SimpleImage(asset)); - } - - /** - * Spielfeld neu zeichnen. Wird vom Framework aufgerufen. - */ - @Override - public synchronized void drawGame(Graphics g) { - for (Sprite sprite : stapel) { - sprite.draw(g, this); - } - - if (moving != null) { - moving.draw(g, this); - } - - writeText(g, 0, 20, "Punkte: " + points); - } - - /** - * Spielfeld zeichnen. - * - * @param g Grafik-Kontext. - */ - @Override - protected void drawGameOver(Graphics g) { - centerText(g, String.format("%d Punkte in %.2f Sekunden", points, - (System.currentTimeMillis() - startzeit) / 1000.0)); - } - - /** - * Mausklick abfangen. - * - * @param e Maus-Event. - */ - @Override - public synchronized void mouseClicked(MouseEvent e) { - - if (startzeit == 0) { - startzeit = System.currentTimeMillis(); - } - - if (stapel.isEmpty()) { - return; - } - - // Oberstes Sprite vom Stapel ansehen und s zuweisen - Sprite s = stapel.peek(); - - if (s.intersects(new Point(e.getX(), e.getY()))) { - points++; - s = stapel.pop(); - moving = s; - moving.setVelocity(new Velocity(0, 20)); - } - } - - /** - * Spielsituation updaten. Wird vom Framework aufgerufen. - */ - @Override - public boolean updateGame() { - - if (moving != null) { - moving.move(); - } - - return !stapel.isEmpty(); - } -} diff --git a/solutions/src/main/java/pr2/generics/verwenden/GameMain.java b/solutions/src/main/java/pr2/generics/verwenden/GameMain.java deleted file mode 100644 index c305e4a..0000000 --- a/solutions/src/main/java/pr2/generics/verwenden/GameMain.java +++ /dev/null @@ -1,28 +0,0 @@ -package pr2.generics.verwenden; - -import de.smits_net.games.framework.board.MainWindow; - -import java.awt.EventQueue; - -/** - * Hauptklasse des Spiels. - */ -public class GameMain extends MainWindow { - - /** - * Neues Spiel anlegen. - */ - public GameMain() { - super("Click the coins as fast as you can", new GameBoard()); - } - - /** - * Startpunkt. - * - * @param args command line arguments. - */ - public static void main(String[] args) { - // Spiel starten - EventQueue.invokeLater(GameMain::new); - } -} diff --git a/solutions/src/main/java/pr2/generics/wildcards/ListHelper.java b/solutions/src/main/java/pr2/generics/wildcards/ListHelper.java deleted file mode 100644 index a6aba36..0000000 --- a/solutions/src/main/java/pr2/generics/wildcards/ListHelper.java +++ /dev/null @@ -1,35 +0,0 @@ -package pr2.generics.wildcards; - -/** - * Klasse zum Ausdrucken von Listen. - */ -public class ListHelper { - - /** - * Druckt alle Elemente der Liste auf der Konsole aus. - * - * @param liste Die zu druckende Liste. - */ - public static void printList(SimpleList liste) { - for (Object o : liste) { - System.out.println(o); - } - } - - /** - * Summiert die Elemente der Liste. Deswegen können nur Listen übergeben - * werden, deren Elemente mindestens vom Typ {@code Number} sind. - * - * @param liste Die Liste, deren Elemente summiert werden sollen. - * @return das Ergebnis - */ - public static double sumList(SimpleList liste) { - double sum = 0; - - for (Number number : liste) { - sum += number.doubleValue(); - } - - return sum; - } -} diff --git a/solutions/src/main/java/pr2/generics/wildcards/Main.java b/solutions/src/main/java/pr2/generics/wildcards/Main.java deleted file mode 100644 index 6401bdc..0000000 --- a/solutions/src/main/java/pr2/generics/wildcards/Main.java +++ /dev/null @@ -1,39 +0,0 @@ -package pr2.generics.wildcards; - -/** - * Ausgabe der Liste. - */ -public final class Main { - - /** - * Constructor. - */ - private Main() { - // keine Instanzen - } - - /** - * Haupt-Methode. - * - * @param args Kommandozeilenargumente. - */ - public static void main(String[] args) { - SimpleList l1 = new SimpleList<>(); - l1.add("Dies"); - l1.add("ist"); - l1.add("ein"); - l1.add("Test"); - l1.add("."); - - SimpleList l2 = new SimpleList<>(); - l2.add(1); - l2.add(2); - l2.add(3); - l2.add(4); - l2.add(5); - - ListHelper.printList(l1); - ListHelper.printList(l2); - System.out.println(ListHelper.sumList(l2)); - } -} diff --git a/solutions/src/main/java/pr2/generics/wildcards/SimpleList.java b/solutions/src/main/java/pr2/generics/wildcards/SimpleList.java deleted file mode 100644 index b4241c1..0000000 --- a/solutions/src/main/java/pr2/generics/wildcards/SimpleList.java +++ /dev/null @@ -1,12 +0,0 @@ -package pr2.generics.wildcards; - -import java.util.ArrayList; - -/** - * Listenklasse. - * - * @param Typ, der in der Liste gespeichert wird. - */ -public class SimpleList extends ArrayList { - // nothing here -} diff --git a/solutions/src/main/java/pr2/interfaces/abstrakt_form/Form.java b/solutions/src/main/java/pr2/interfaces/abstrakt_form/Form.java deleted file mode 100644 index 6ea1f70..0000000 --- a/solutions/src/main/java/pr2/interfaces/abstrakt_form/Form.java +++ /dev/null @@ -1,16 +0,0 @@ -package pr2.interfaces.abstrakt_form; - -public abstract class Form { - - protected double x; - protected double y; - - public Form(double x, double y) { - this.x = x; - this.y = y; - } - - public abstract double flaeche(); - - public abstract double umfang(); -} diff --git a/solutions/src/main/java/pr2/interfaces/abstrakte_klassen_s/Dreieck.java b/solutions/src/main/java/pr2/interfaces/abstrakte_klassen_s/Dreieck.java deleted file mode 100644 index a11edee..0000000 --- a/solutions/src/main/java/pr2/interfaces/abstrakte_klassen_s/Dreieck.java +++ /dev/null @@ -1,39 +0,0 @@ -package pr2.interfaces.abstrakte_klassen_s; - -/** - * Ein Dreieck. - */ -public class Dreieck extends Figur { - - /** - * Grundseite des Dreiecks. - */ - private final double grundseite; - - /** - * Höhe. - */ - private final double hoehe; - - /** - * Erzeugt ein neues Dreieck. - * - * @param grundseite Grundseite. - * @param hoehe Höhe. - */ - public Dreieck(double grundseite, double hoehe) { - super(); - this.grundseite = grundseite; - this.hoehe = hoehe; - } - - /** - * Berechnet die Fläche. - * - * @return die Fläche. - */ - @Override - public double flaeche() { - return grundseite * hoehe / 2; - } -} diff --git a/solutions/src/main/java/pr2/interfaces/abstrakte_klassen_s/Figur.java b/solutions/src/main/java/pr2/interfaces/abstrakte_klassen_s/Figur.java deleted file mode 100644 index a0351f2..0000000 --- a/solutions/src/main/java/pr2/interfaces/abstrakte_klassen_s/Figur.java +++ /dev/null @@ -1,14 +0,0 @@ -package pr2.interfaces.abstrakte_klassen_s; - -/** - * Basisklasse für geometrische Figuren. - */ -public abstract class Figur { - - /** - * Berechnet die Fläche einer geometrischen Figur. - * - * @return die Fläche. - */ - public abstract double flaeche(); -} diff --git a/solutions/src/main/java/pr2/interfaces/abstrakte_klassen_s/Geometer.java b/solutions/src/main/java/pr2/interfaces/abstrakte_klassen_s/Geometer.java deleted file mode 100644 index 3257c45..0000000 --- a/solutions/src/main/java/pr2/interfaces/abstrakte_klassen_s/Geometer.java +++ /dev/null @@ -1,43 +0,0 @@ -package pr2.interfaces.abstrakte_klassen_s; - -/** - * Flächenberechnung. - */ -public final class Geometer { - - /** - * Keine Instanzen. - */ - private Geometer() { - // keine Objekte - } - - /** - * Hauptmethode. - * - * @param args Kommandozeilenargumente - */ - public static void main(String[] args) { - Figur[] figuren = new Figur[10]; - - figuren[0] = new Kreis(10.0); - figuren[1] = new Kreis(5.5); - figuren[2] = new Kreis(3.3); - figuren[3] = new Kreis(7.2); - figuren[4] = new Kreis(8.0); - - figuren[5] = new Dreieck(4.0, 3.0); - figuren[6] = new Dreieck(2.0, 1.0); - figuren[7] = new Dreieck(5.0, 8.0); - figuren[8] = new Dreieck(2.0, 7.2); - figuren[9] = new Dreieck(14.0, 3.8); - - double gesamtflaeche = 0.0; - - for (Figur figur : figuren) { - gesamtflaeche += figur.flaeche(); - } - - System.out.printf("Die Fläche beträgt: %.2f", gesamtflaeche); - } -} diff --git a/solutions/src/main/java/pr2/interfaces/abstrakte_klassen_s/Kreis.java b/solutions/src/main/java/pr2/interfaces/abstrakte_klassen_s/Kreis.java deleted file mode 100644 index 86bf749..0000000 --- a/solutions/src/main/java/pr2/interfaces/abstrakte_klassen_s/Kreis.java +++ /dev/null @@ -1,32 +0,0 @@ -package pr2.interfaces.abstrakte_klassen_s; - -/** - * Ein Kreis. - */ -public class Kreis extends Figur { - - /** - * Radius des Kreises. - */ - private final double radius; - - /** - * Legt einen neuen Kreis an. - * - * @param radius Radius des Kreises. - */ - public Kreis(double radius) { - super(); - this.radius = radius; - } - - /** - * Berechnet die Fläche. - * - * @return die Fläche. - */ - @Override - public double flaeche() { - return Math.PI * radius * radius; - } -} diff --git a/solutions/src/main/java/pr2/interfaces/comparable_student/Student.java b/solutions/src/main/java/pr2/interfaces/comparable_student/Student.java deleted file mode 100644 index 13ab812..0000000 --- a/solutions/src/main/java/pr2/interfaces/comparable_student/Student.java +++ /dev/null @@ -1,42 +0,0 @@ -package pr2.interfaces.comparable_student; - -public class Student implements Comparable { - - private final String vorname; - private final String nachname; - private final int matrikelNr; - - public Student(String vorname, String nachname, - int matrikelNr) { - this.vorname = vorname; - this.nachname = nachname; - this.matrikelNr = matrikelNr; - } - - @Override - public String toString() { - return String.format("%s, %s (%d)", nachname, vorname, - matrikelNr); - } - - @Override - public int compareTo(Object o) { - - Student other = (Student) o; - - if (nachname.compareTo(other.nachname) == 0) { - if (vorname.compareTo(other.vorname) == 0) { - if (matrikelNr == other.matrikelNr) { - return 0; - } - else { - return (matrikelNr > other.matrikelNr) ? 1 : -1; - } - } - - return vorname.compareTo(other.vorname); - } - - return nachname.compareTo(other.nachname); - } -} diff --git a/solutions/src/main/java/pr2/interfaces/interfaces_s/api/AnalogController.java b/solutions/src/main/java/pr2/interfaces/interfaces_s/api/AnalogController.java deleted file mode 100644 index 5cea5ce..0000000 --- a/solutions/src/main/java/pr2/interfaces/interfaces_s/api/AnalogController.java +++ /dev/null @@ -1,44 +0,0 @@ -package pr2.interfaces.interfaces_s.api; - -import java.awt.Point; - -/** - * Analoger Joystick. - */ -public interface AnalogController { - - /** - * Nach oben bewegen. - * - * @param percentage Auslenkung in Prozent (zwischen 0 - 1) - */ - void up(double percentage); - - /** - * Nach unten bewegen. - * - * @param percentage Auslenkung in Prozent (zwischen 0 - 1) - */ - void down(double percentage); - - /** - * Nach links bewegen. - * - * @param percentage Auslenkung in Prozent (zwischen 0 - 1) - */ - void left(double percentage); - - /** - * Nach rechts bewegen. - * - * @param percentage Auslenkung in Prozent (zwischen 0 - 1) - */ - void right(double percentage); - - /** - * Liefert die aktuelle Position zurück. - * - * @return Die Position. - */ - Point getPosition(); -} diff --git a/solutions/src/main/java/pr2/interfaces/interfaces_s/api/DigitalController.java b/solutions/src/main/java/pr2/interfaces/interfaces_s/api/DigitalController.java deleted file mode 100644 index ec760b9..0000000 --- a/solutions/src/main/java/pr2/interfaces/interfaces_s/api/DigitalController.java +++ /dev/null @@ -1,36 +0,0 @@ -package pr2.interfaces.interfaces_s.api; - -import java.awt.Point; - -/** - * Ein digitaler Joystick. - */ -public interface DigitalController { - - /** - * Nach oben bewegen. - */ - void up(); - - /** - * Nach unten bewegen. - */ - void down(); - - /** - * Nach links bewegen. - */ - void left(); - - /** - * Nach rechts bewegen. - */ - void right(); - - /** - * Liefert die aktuelle Position zurück. - * - * @return Die Position. - */ - Point getPosition(); -} diff --git a/solutions/src/main/java/pr2/interfaces/interfaces_s/impl/AnalogControllerImpl.java b/solutions/src/main/java/pr2/interfaces/interfaces_s/impl/AnalogControllerImpl.java deleted file mode 100644 index e6241ee..0000000 --- a/solutions/src/main/java/pr2/interfaces/interfaces_s/impl/AnalogControllerImpl.java +++ /dev/null @@ -1,61 +0,0 @@ -package pr2.interfaces.interfaces_s.impl; - -import pr2.interfaces.interfaces_s.api.AnalogController; - -import java.awt.Point; - -/** - * Analoger Joystick. - */ -public class AnalogControllerImpl implements AnalogController { - - /** - * Auslenkung in X-Richtung. - */ - private double deltaX; - - /** - * Auslenkung in Y-Richtung. - */ - private double deltaY; - - /** - * @see AnalogController#up(double) - */ - @Override - public void up(double percentage) { - deltaY -= percentage; - } - - /** - * @see AnalogController#down(double) - */ - @Override - public void down(double percentage) { - deltaY += percentage; - } - - /** - * @see AnalogController#left(double) - */ - @Override - public void left(double percentage) { - deltaX -= percentage; - } - - /** - * @see AnalogController#right(double) - */ - @Override - public void right(double percentage) { - deltaX += percentage; - } - - /** - * @see AnalogController#getPosition() - */ - @Override - public Point getPosition() { - return new Point((int) deltaX, (int) deltaY); - } -} diff --git a/solutions/src/main/java/pr2/interfaces/interfaces_s/impl/DigitalControllerImpl.java b/solutions/src/main/java/pr2/interfaces/interfaces_s/impl/DigitalControllerImpl.java deleted file mode 100644 index 2007280..0000000 --- a/solutions/src/main/java/pr2/interfaces/interfaces_s/impl/DigitalControllerImpl.java +++ /dev/null @@ -1,55 +0,0 @@ -package pr2.interfaces.interfaces_s.impl; - -import pr2.interfaces.interfaces_s.api.DigitalController; - -import java.awt.Point; - -/** - * Implementierung eines digitalen Joysticks. - */ -public class DigitalControllerImpl implements DigitalController { - - private final Point position = new Point(0, 0); - - /** - * @see DigitalController#up() - */ - @Override - public void up() { - position.translate(0, -1); - } - - /** - * @see DigitalController#down() - */ - @Override - public void down() { - position.translate(0, 1); - } - - /** - * @see DigitalController#left() - */ - @Override - public void left() { - position.translate(-1, 0); - } - - /** - * @see DigitalController#right() - */ - @Override - public void right() { - position.translate(1, 0); - } - - /** - * @see DigitalController#getPosition() - */ - @Override - public Point getPosition() { - return (Point) position.clone(); - } - - -} diff --git a/solutions/src/main/java/pr2/interfaces/interfaces_s/impl/DualShock4.java b/solutions/src/main/java/pr2/interfaces/interfaces_s/impl/DualShock4.java deleted file mode 100644 index 35c2b8f..0000000 --- a/solutions/src/main/java/pr2/interfaces/interfaces_s/impl/DualShock4.java +++ /dev/null @@ -1,95 +0,0 @@ -package pr2.interfaces.interfaces_s.impl; - -import pr2.interfaces.interfaces_s.api.AnalogController; -import pr2.interfaces.interfaces_s.api.DigitalController; - -import java.awt.Point; - -/** - * Linke Seite eines DualShock 4 Controllers. - */ -public class DualShock4 implements AnalogController, DigitalController { - - private final AnalogController analogStick = new AnalogControllerImpl(); - - private final DigitalController digitalStick = new DigitalControllerImpl(); - - /** - * @see DigitalController#up() - */ - @Override - public void up() { - digitalStick.up(); - } - - /** - * @see DigitalController#down() - */ - @Override - public void down() { - digitalStick.down(); - } - - /** - * @see DigitalController#left() - */ - @Override - public void left() { - digitalStick.left(); - } - - /** - * @see DigitalController#right() - */ - @Override - public void right() { - digitalStick.right(); - } - - /** - * @see AnalogController#up(double) - */ - @Override - public void up(double percentage) { - analogStick.up(percentage); - } - - /** - * @see AnalogController#down(double) - */ - @Override - public void down(double percentage) { - analogStick.down(percentage); - } - - /** - * @see AnalogController#left(double) - */ - @Override - public void left(double percentage) { - analogStick.left(percentage); - } - - /** - * @see AnalogController#right(double) - */ - @Override - public void right(double percentage) { - analogStick.right(percentage); - } - - /** - * @see AnalogController#getPosition() - */ - @Override - public Point getPosition() { - Point resultAnalog = analogStick.getPosition(); - Point resultDigital = digitalStick.getPosition(); - Point result = new Point(); - - result.x = resultAnalog.x + resultDigital.x; - result.y = resultAnalog.y + resultDigital.y; - - return result; - } -} diff --git a/solutions/src/main/java/pr2/interfaces/interfaces_s/test/AnalogControllerTest.java b/solutions/src/main/java/pr2/interfaces/interfaces_s/test/AnalogControllerTest.java deleted file mode 100644 index 65dd577..0000000 --- a/solutions/src/main/java/pr2/interfaces/interfaces_s/test/AnalogControllerTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package pr2.interfaces.interfaces_s.test; - -import org.junit.jupiter.api.Test; -import pr2.interfaces.interfaces_s.api.AnalogController; -import pr2.interfaces.interfaces_s.impl.AnalogControllerImpl; - -/** - * Tests für einen analogen Joystick. - */ -public class AnalogControllerTest extends DigitalControllerTest { - - /** - * Testet einen anlogen Controller. - */ - @Test - void testAnalogController() { - AnalogController c = new AnalogControllerImpl(); - testAnalogController(c); - } - - /** - * Interne Hilfsmethode zum Test von analogen Controllern. - * - * @param c Controller, der getestet wird - */ - protected void testAnalogController(AnalogController c) { - c.up(0.5); - assertPointEquals(0, 0, c.getPosition()); - c.up(0.5); - assertPointEquals(0, -1, c.getPosition()); - - c.left(0.3); - c.left(0.3); - c.left(0.3); - assertPointEquals(0, -1, c.getPosition()); - c.left(0.2); - assertPointEquals(-1, -1, c.getPosition()); - - c.down(1.0); - assertPointEquals(-1, 0, c.getPosition()); - - c.down(1.0); - assertPointEquals(-1, 1, c.getPosition()); - c.down(1.0); - assertPointEquals(-1, 2, c.getPosition()); - - c.right(0.5); - c.right(0.5); - c.right(0.5); - assertPointEquals(0, 2, c.getPosition()); - } -} diff --git a/solutions/src/main/java/pr2/interfaces/interfaces_s/test/DigitalControllerTest.java b/solutions/src/main/java/pr2/interfaces/interfaces_s/test/DigitalControllerTest.java deleted file mode 100644 index a533be7..0000000 --- a/solutions/src/main/java/pr2/interfaces/interfaces_s/test/DigitalControllerTest.java +++ /dev/null @@ -1,62 +0,0 @@ -package pr2.interfaces.interfaces_s.test; - -import org.junit.jupiter.api.Test; -import pr2.interfaces.interfaces_s.impl.DigitalControllerImpl; -import pr2.interfaces.interfaces_s.api.DigitalController; - -import java.awt.Point; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * Tests für einen digitalen Joystick. - */ -public class DigitalControllerTest { - - /** - * Testet einen digitalen Controller. - */ - @Test - void testDigitalController() { - DigitalController c = new DigitalControllerImpl(); - testDigitalController(c); - } - - /** - * Interne Hilfsmethode zum Test von digitalen Controllern. - * - * @param c Controller, der getestet wird - */ - protected void testDigitalController(DigitalController c) { - assertPointEquals(0, 0, c.getPosition()); - c.up(); - c.up(); - assertPointEquals(0, -2, c.getPosition()); - c.down(); - c.down(); - assertPointEquals(0, 0, c.getPosition()); - c.left(); - c.right(); - assertPointEquals(0, 0, c.getPosition()); - c.left(); - assertPointEquals(-1, 0, c.getPosition()); - c.left(); - assertPointEquals(-2, 0, c.getPosition()); - c.right(); - c.right(); - c.right(); - assertPointEquals(1, 0, c.getPosition()); - } - - /** - * Interne Hilfsmethode, um einen Punkt mit seinem x und - * y-Wert zu vergleichen. - * - * @param x x-Wert - * @param y y-Wert - * @param point Punkt, der verglichen werden soll - */ - protected void assertPointEquals(int x, int y, Point point) { - assertEquals(new Point(x, y), point); - } -} diff --git a/solutions/src/main/java/pr2/interfaces/interfaces_s/test/DualShock4Test.java b/solutions/src/main/java/pr2/interfaces/interfaces_s/test/DualShock4Test.java deleted file mode 100644 index 9f4bb3d..0000000 --- a/solutions/src/main/java/pr2/interfaces/interfaces_s/test/DualShock4Test.java +++ /dev/null @@ -1,45 +0,0 @@ -package pr2.interfaces.interfaces_s.test; - -import org.junit.jupiter.api.Test; -import pr2.interfaces.interfaces_s.api.AnalogController; -import pr2.interfaces.interfaces_s.api.DigitalController; -import pr2.interfaces.interfaces_s.impl.DualShock4; - - -/** - * Tests für einen analogen Joystick. - */ -public class DualShock4Test extends AnalogControllerTest { - - /** - * Testet einen DualShock4 Kombi-Controller. - */ - @Test - void testDualShock4() { - DigitalController cd = new DualShock4(); - testDigitalController(cd); - - AnalogController ca = new DualShock4(); - testAnalogController(ca); - - DualShock4 ds = new DualShock4(); - - ds.up(); - ds.up(1.0); - assertPointEquals(0, -2, ds.getPosition()); - - ds.left(); - ds.right(); - ds.right(0.5); - ds.right(0.5); - assertPointEquals(1, -2, ds.getPosition()); - - ds.down(); - ds.down(); - ds.down(0.3); - ds.down(0.3); - ds.down(0.3); - ds.down(0.1); - assertPointEquals(1, 1, ds.getPosition()); - } -} diff --git a/solutions/src/main/java/pr2/interfaces/stack/Stack.java b/solutions/src/main/java/pr2/interfaces/stack/Stack.java deleted file mode 100644 index f9e4e14..0000000 --- a/solutions/src/main/java/pr2/interfaces/stack/Stack.java +++ /dev/null @@ -1,12 +0,0 @@ -package pr2.interfaces.stack; - -public interface Stack { - - void push(Object o); - - Object pop(); - - Object peek(); - - int size(); -} diff --git a/solutions/src/main/java/pr2/interfaces/stack/StackImpl.java b/solutions/src/main/java/pr2/interfaces/stack/StackImpl.java deleted file mode 100644 index 2d286e0..0000000 --- a/solutions/src/main/java/pr2/interfaces/stack/StackImpl.java +++ /dev/null @@ -1,43 +0,0 @@ -package pr2.interfaces.stack; - -public class StackImpl implements Stack { - - private final Object[] puffer; - private int pos = -1; - - public StackImpl(int size) { - puffer = new Object[size]; - } - - @Override - public void push(Object o) { - if (pos < puffer.length - 1) { - puffer[++pos] = o; - } - } - - @Override - public Object pop() { - if (pos >= 0) { - return puffer[pos--]; - } - else { - return null; - } - } - - @Override - public Object peek() { - if (pos >= 0) { - return puffer[pos]; - } - else { - return null; - } - } - - @Override - public int size() { - return pos + 1; - } -} diff --git a/solutions/src/main/java/pr2/interfaces/stack/test/StackTest.java b/solutions/src/main/java/pr2/interfaces/stack/test/StackTest.java deleted file mode 100644 index 4c1534f..0000000 --- a/solutions/src/main/java/pr2/interfaces/stack/test/StackTest.java +++ /dev/null @@ -1,35 +0,0 @@ -package pr2.interfaces.stack.test; - -import org.junit.jupiter.api.Test; -import pr2.interfaces.stack.Stack; -import pr2.interfaces.stack.StackImpl; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; - -public class StackTest { - - @Test - void testStack() { - Stack s = new StackImpl(100); - - assertEquals(0, s.size()); - - s.push("Hallo"); - s.push("wie"); - s.push("gehts"); - - assertEquals(3, s.size()); - - assertEquals("gehts", s.peek()); - assertEquals("gehts", s.pop()); - - assertEquals("wie", s.peek()); - assertEquals("wie", s.pop()); - - assertEquals("Hallo", s.peek()); - assertEquals("Hallo", s.pop()); - - assertNull(s.pop()); - } -} diff --git a/solutions/src/main/java/pr2/interfaces/uebersetzer/Translator.java b/solutions/src/main/java/pr2/interfaces/uebersetzer/Translator.java deleted file mode 100644 index e65a2b2..0000000 --- a/solutions/src/main/java/pr2/interfaces/uebersetzer/Translator.java +++ /dev/null @@ -1,38 +0,0 @@ - -package pr2.interfaces.uebersetzer; - -public class Translator { - - public static void main(String[] args) { - if (args.length != 2) { - System.err.println("Bitte geben Sie genau zwei " - + "Optionen an: Zielsprache und zu " - + "übersetzendes Wort"); - System.exit(1); - } - - String sprache = args[0].toLowerCase(); - String wort = args[1]; - - Uebersetzer uebersetzer = null; - - if ("englisch".equals(sprache)) { - uebersetzer = new UebersetzerDeutschEnglisch(); - } else if ("spanisch".equals(sprache)) { - uebersetzer = new UebersetzerDeutschSpanisch(); - } else { - System.out.println("Unbekannte Sprache"); - System.exit(1); - } - - String uebersetzung = uebersetzer.uebersetze(wort); - - if (uebersetzung != null) { - System.out.printf("Übersetzung: deutsch -> " - + "%s%n%s -> %s%n", - sprache, wort, uebersetzung); - } else { - System.out.printf("Unbekanntes Wort: %s%n", wort); - } - } -} diff --git a/solutions/src/main/java/pr2/interfaces/uebersetzer/Uebersetzer.java b/solutions/src/main/java/pr2/interfaces/uebersetzer/Uebersetzer.java deleted file mode 100644 index 50cf30d..0000000 --- a/solutions/src/main/java/pr2/interfaces/uebersetzer/Uebersetzer.java +++ /dev/null @@ -1,13 +0,0 @@ -package pr2.interfaces.uebersetzer; - -public interface Uebersetzer { - - /** - * Übersetzt den gegebeben String. - * - * @param string String, der übersetzt werden soll - * @return die Übersetzung oder {@literal null}, wenn das Wort nicht - * bekannt ist - */ - public String uebersetze(String string); -} diff --git a/solutions/src/main/java/pr2/interfaces/uebersetzer/UebersetzerDeutschEnglisch.java b/solutions/src/main/java/pr2/interfaces/uebersetzer/UebersetzerDeutschEnglisch.java deleted file mode 100644 index e5d1ebc..0000000 --- a/solutions/src/main/java/pr2/interfaces/uebersetzer/UebersetzerDeutschEnglisch.java +++ /dev/null @@ -1,17 +0,0 @@ - -package pr2.interfaces.uebersetzer; - -public class UebersetzerDeutschEnglisch implements Uebersetzer { - - @Override - public String uebersetze(String string) { - - return switch (string) { - case "gehen" -> "go"; - case "schalfen" -> "sleep"; - case "tanzen" -> "dance"; - default -> null; - }; - - } -} diff --git a/solutions/src/main/java/pr2/interfaces/uebersetzer/UebersetzerDeutschSpanisch.java b/solutions/src/main/java/pr2/interfaces/uebersetzer/UebersetzerDeutschSpanisch.java deleted file mode 100644 index 9877392..0000000 --- a/solutions/src/main/java/pr2/interfaces/uebersetzer/UebersetzerDeutschSpanisch.java +++ /dev/null @@ -1,17 +0,0 @@ - -package pr2.interfaces.uebersetzer; - -public class UebersetzerDeutschSpanisch implements Uebersetzer { - - @Override - public String uebersetze(String string) { - - return switch (string) { - case "gehen" -> "ir"; - case "schalfen" -> "dormir"; - case "tanzen" -> "bailar"; - default -> null; - }; - - } -} diff --git a/solutions/src/main/java/pr2/intro/coding_standard/CodingStandard.java b/solutions/src/main/java/pr2/intro/coding_standard/CodingStandard.java deleted file mode 100644 index 64a8726..0000000 --- a/solutions/src/main/java/pr2/intro/coding_standard/CodingStandard.java +++ /dev/null @@ -1,54 +0,0 @@ -package pr2.intro.coding_standard; - -/** - * Klasse dient als Beispiel für den Coding-Standard und die Namenskonventionen - * bei Java-Programmen. - */ - -@SuppressWarnings("PMD.UnusedPrivateField") -public class CodingStandard { - - /** - * Konstante, die dem Rest der Welt etwas mitteilen soll. - */ - public static final int KONSTANTE_MIT_TOLLEM_WERT = 3; - - private int erstesFeld; - - private double zweitesFeld; - - /** - * Legt eine neue Instanz an. - * - * @param erstesFeld das erste Feld. - * @param zweitesFeld das zweite Feld. - */ - public CodingStandard(int erstesFeld, double zweitesFeld) { - this.erstesFeld = erstesFeld; - this.zweitesFeld = zweitesFeld; - } - - /** - * Methode, die etwas tut. - * - * @param parameter Eingabewert für die Methode. - * @return gibt einen Wert abhängig von {@code parameter} zurück. - */ - public int methodeDieWasTut(int parameter) { - - int result; - - if (parameter > KONSTANTE_MIT_TOLLEM_WERT) { - result = 12; - } - else { - result = 13; - } - - erstesFeld = result; - zweitesFeld = 2 * result; - - return result; - } -} - diff --git a/solutions/src/main/java/pr2/intro/javadoc/Waehrung.java b/solutions/src/main/java/pr2/intro/javadoc/Waehrung.java deleted file mode 100644 index 5cb7837..0000000 --- a/solutions/src/main/java/pr2/intro/javadoc/Waehrung.java +++ /dev/null @@ -1,142 +0,0 @@ -package pr2.intro.javadoc; - - -/** - * Objekte dieser Klasse repräsentieren eine Währung. Eine Währung zeichnet - * sich durch einen Namen (z.B. EURO), ein Kürzel (z.B. € oder EUR) und einen - * Umrechnungskurs zum US-Dollar aus. - *

- * Objekte dieser Klasse sind imutable, d.h. sie können nach der Erzeugung - * nicht mehr verändert werden. - */ - -public class Waehrung { - - /** - * Teiler für die Nachkommastellen. - */ - private static final long TEILER = 10000; - - /** - * Umrechnungskurs zum Dollar. - */ - private final int kurs; - - /** - * Langer Name der Währung. - */ - private final String name; - - /** - * Abkürzung zur Währung. - */ - private final String kuerzel; - - /** - * Erzeugt ein neues Objekt. - * - * @param name Name der Währung (z.B. EURO). - * @param kuerzel Kürzel der Währung (z.B. €). - * @param kurs Wechselkurs zum Dollar. - */ - public Waehrung(String name, String kuerzel, double kurs) { - this.kurs = (int) (kurs * TEILER); - this.name = name; - this.kuerzel = kuerzel; - } - - /** - * Rechnet einen Berag in der aktuellen Währung in eine andere Währung - * um. - * - * @param betrag Betrag der umgerechnet werden soll. - * @param toWaehrung die Zielwährung. - * @return Ergebnis der Umrechnung. - */ - public long umrechnen(long betrag, Waehrung toWaehrung) { - return betrag * kurs / toWaehrung.kurs; - } - - /** - * Gibt den Kurs der aktuellen Währung zurück. - * - * @return Wechselkurs bezogen auf den US-Dollar. - */ - public int getKurs() { - return kurs; - } - - /** - * Gibt den Namen der Währung zurück. - * - * @return Name der Währung (z.B. Euro oder Dollar). - */ - public String getName() { - return name; - } - - /** - * Gibt das Kürzel für die Währung zurück. - * - * @return Das Kürzel der Währung (z.B. EUR oder $) - */ - public String getKuerzel() { - return kuerzel; - } - - /** - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return String.format("%s [%s] 1 %s = %.4f %s", name, kuerzel, "$", - kurs / (double) TEILER, kuerzel); - } - - /** - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + kurs; - result = prime * result + ((kuerzel == null) ? 0 : kuerzel.hashCode()); - return result; - } - - /** - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Waehrung other = (Waehrung) obj; - if (name == null) { - if (other.name != null) { - return false; - } - } - else if (!name.equals(other.name)) { - return false; - } - if (kurs != other.kurs) { - return false; - } - if (kuerzel == null) { - return other.kuerzel == null; - } - else { - return kuerzel.equals(other.kuerzel); - } - } -} diff --git a/solutions/src/main/java/pr2/intro/junit_faculty/Fakultaet.java b/solutions/src/main/java/pr2/intro/junit_faculty/Fakultaet.java deleted file mode 100644 index 2f31efa..0000000 --- a/solutions/src/main/java/pr2/intro/junit_faculty/Fakultaet.java +++ /dev/null @@ -1,14 +0,0 @@ -package pr2.intro.junit_faculty; - -public class Fakultaet { - - /** - * Berechnet die Fakultät fuer die gegebene Zahl. - * - * @param n Zahl für die die Fakultät berechnet werden soll. - * @return die Fakultät - */ - public int fact(int n) { - return (n == 0) ? 1 : n * fact(n - 1); - } -} diff --git a/solutions/src/main/java/pr2/intro/junit_faculty/test/FakultaetTest.java b/solutions/src/main/java/pr2/intro/junit_faculty/test/FakultaetTest.java deleted file mode 100644 index 33f1df1..0000000 --- a/solutions/src/main/java/pr2/intro/junit_faculty/test/FakultaetTest.java +++ /dev/null @@ -1,20 +0,0 @@ -package pr2.intro.junit_faculty.test; - -import org.junit.jupiter.api.Test; -import pr2.intro.junit_faculty.Fakultaet; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class FakultaetTest { - - @Test - void testFact() { - Fakultaet f = new Fakultaet(); - assertEquals(1, f.fact(0)); - assertEquals(1, f.fact(1)); - assertEquals(2, f.fact(2)); - assertEquals(6, f.fact(3)); - assertEquals(24, f.fact(4)); - assertEquals(3628800, f.fact(10)); - } -} diff --git a/solutions/src/main/java/pr2/io/buffered_reader/LineNumberPrinter.java b/solutions/src/main/java/pr2/io/buffered_reader/LineNumberPrinter.java deleted file mode 100644 index 3b255c2..0000000 --- a/solutions/src/main/java/pr2/io/buffered_reader/LineNumberPrinter.java +++ /dev/null @@ -1,36 +0,0 @@ -package pr2.io.buffered_reader; - -import java.io.BufferedReader; -import java.io.FileReader; -import java.io.IOException; - -/** - * Liest eine Textdatei und gibt den Inhalt auf der Konsole aus. - */ -public class LineNumberPrinter { - - /** - * Hauptmethode. - * - * @param args Kommandozeilen-Argumente. - */ - public static void main(String[] args) { - - String filename = args.length == 1 - ? args[0] - : "pr2/io/reader_writer/kafka.txt"; - - try (BufferedReader r = new BufferedReader(new FileReader(filename))) { - - String line; - int count = 1; - - while ((line = r.readLine()) != null) { - System.out.printf("%3d: %s%n", count, line); - count++; - } - } catch (IOException e) { - System.err.println("IO-Problem: " + e); - } - } -} diff --git a/solutions/src/main/java/pr2/io/data_output/Board.java b/solutions/src/main/java/pr2/io/data_output/Board.java deleted file mode 100644 index 8433336..0000000 --- a/solutions/src/main/java/pr2/io/data_output/Board.java +++ /dev/null @@ -1,172 +0,0 @@ -package pr2.io.data_output; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; - -/** - * Ein Dame-Brett. - */ -public class Board { - - /** - * Belegung des Brettes. - */ - private final Color[][] brett = new Color[8][8]; - - /** - * Liest den Inhalt aus einer Datei. - * - * @param file Dateipfad. - * @return das gelesene Spielfeld - * @throws IOException IO-Probleme - */ - public static Board loadFromFile(String file) throws IOException { - - Board result = new Board(); - - DataInputStream dis = new DataInputStream(new FileInputStream(file)); - - String header = dis.readUTF(); - - if (!"Schachbrett".equals(header)) { - dis.close(); - throw new IOException("Falsches Dateiformat"); - } - - while (true) { - int x = dis.readByte(); - int y = dis.readByte(); - int ordinal = dis.readInt(); - - if (x == 0xff || y == 0xff || ordinal == -1) { - break; - } - - result.brett[x][y] = Color.values()[ordinal]; - } - - dis.close(); - - - return result; - } - - - /** - * Schreibt den Inhalt des Spielfeldes in eine Datei. - * - * @param file Dateiname. - * @throws IOException IO-Probleme - */ - public void writeToFile(String file) throws IOException { - - DataOutputStream dos = new DataOutputStream( - new FileOutputStream(file)); - - dos.writeUTF("Schachbrett"); - - for (int x = 0; x < brett.length; x++) { - for (int y = 0; y < brett[x].length; y++) { - - Color f = brett[x][y]; - - if (f != null) { - dos.writeByte(x); - dos.writeByte(y); - dos.writeInt(f.ordinal()); - } - } - } - - dos.writeByte(0xff); - dos.writeByte(0xff); - dos.writeInt(-1); - - dos.close(); - } - - /** - * Setzt einen Stein an die gegebene Koordinate. - * - * @param koordinate Koordinate in "a1"-Notation. - * @param farbe Fabe des Spielsteins. - */ - public void set(String koordinate, Color farbe) { - Tupel t = parseCoordinates(koordinate); - brett[t.x][t.y] = farbe; - } - - /** - * Wandelt textuelle Koordinaten in x- und y-Wert um. - * - * @param koordinate Koordinate als String. - * @return Koordinate als Integer-Tupel. - */ - private Tupel parseCoordinates(String koordinate) { - char buchstabe = koordinate.toLowerCase().charAt(0); - char zahl = koordinate.charAt(1); - - Tupel t = new Tupel(); - - t.y = buchstabe - 'a'; - t.x = zahl - '1'; - - if (t.x < 0 || t.x > 7) { - throw new IllegalArgumentException(); - } - - if (t.y < 0 || t.y > 7) { - throw new IllegalArgumentException(); - } - - return t; - } - - /** - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - - StringBuilder result = new StringBuilder(); - - char y = '1'; - - result.append(" "); - for (char c : "abcdefgh".toCharArray()) { - result.append(' ').append(c); - } - - result.append("\n"); - - for (Color[] figurs : brett) { - - result.append(y++); - - for (Color figur : figurs) { - if (figur != null) { - result.append(' ').append(figur); - } - else { - result.append(" "); - } - } - - result.append("\n"); - } - - return result.toString(); - } - - /** - * Tupel von zwei int-Werten. - */ - private static class Tupel { - int x; - - int y; - } -} diff --git a/solutions/src/main/java/pr2/io/data_output/Color.java b/solutions/src/main/java/pr2/io/data_output/Color.java deleted file mode 100644 index 63eb878..0000000 --- a/solutions/src/main/java/pr2/io/data_output/Color.java +++ /dev/null @@ -1,30 +0,0 @@ -package pr2.io.data_output; - -/** - * Farben der Spielsteine. - */ -public enum Color { - - /** - * Schwarzer Stein. - */ - BLACK, - - /** - * Weißer Stein. - */ - WHITE; - - /** - * @see java.lang.Enum#toString() - */ - @Override - public String toString() { - if (this == Color.BLACK) { - return "B"; - } - else { - return "W"; - } - } -} diff --git a/solutions/src/main/java/pr2/io/data_output/test/BoardTest.java b/solutions/src/main/java/pr2/io/data_output/test/BoardTest.java deleted file mode 100644 index 8643548..0000000 --- a/solutions/src/main/java/pr2/io/data_output/test/BoardTest.java +++ /dev/null @@ -1,63 +0,0 @@ -package pr2.io.data_output.test; - -import org.junit.jupiter.api.Test; -import pr2.io.data_output.Board; -import pr2.io.data_output.Color; - -import java.io.FileOutputStream; -import java.io.IOException; - -import static org.junit.jupiter.api.Assertions.assertEquals; - - -/** - * Test. - */ -public class BoardTest { - - private static final byte[] RESULT = new byte[] { - 0x00, 0x0B, 0x53, 0x63, 0x68, 0x61, 0x63, 0x68, 0x62, 0x72, 0x65, - 0x74, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x00, 0x00, 0x01, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, - 0x00, 0x00, 0x00, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x04, 0x00, 0x00, 0x00, 0x01, 0x04, 0x05, 0x00, 0x00, 0x00, 0x01, - 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x05, 0x00, 0x00, 0x00, - 0x00, (byte) 0xff, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, - (byte) 0xFF, (byte) 0xFF - }; - - /** - * Test für die Implementierung des Spielbrettes. - * - * @throws IOException Datei-Probleme. - */ - @Test - void testDame() throws IOException { - Board s = new Board(); - s.set("a1", Color.BLACK); - s.set("b1", Color.WHITE); - s.set("h1", Color.BLACK); - s.set("h2", Color.BLACK); - s.set("a8", Color.BLACK); - s.set("f8", Color.BLACK); - s.set("f5", Color.WHITE); - s.set("e3", Color.WHITE); - s.set("g2", Color.WHITE); - - String stringRepresentation = s.toString(); - - s.writeToFile("/tmp/daten.dat"); - - s = Board.loadFromFile("/tmp/daten.dat"); - - assertEquals(stringRepresentation, s.toString()); - - FileOutputStream fos = new FileOutputStream("/tmp/testdata.dat"); - fos.write(RESULT); - fos.close(); - - s = Board.loadFromFile("/tmp/testdata.dat"); - - assertEquals(stringRepresentation, s.toString()); - } -} diff --git a/solutions/src/main/java/pr2/io/datainputoutput_1/DateReader.java b/solutions/src/main/java/pr2/io/datainputoutput_1/DateReader.java deleted file mode 100644 index ca6b8b7..0000000 --- a/solutions/src/main/java/pr2/io/datainputoutput_1/DateReader.java +++ /dev/null @@ -1,43 +0,0 @@ -package pr2.io.datainputoutput_1; - -import java.io.DataInputStream; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; - -public class DateReader { - public static void main(String[] args) { - - DataInputStream dis = null; - - try { - DateFormat df = new SimpleDateFormat(DateWriter.FORMAT); - dis = new DataInputStream( - new FileInputStream(DateWriter.DATEINAME)); - - long time = dis.readLong(); - System.out.printf("Das Datum war: %s%n%n", - df.format(new Date(time))); - - } catch (FileNotFoundException e) { - System.err.printf("Datei %s kann nicht gelesen werden: %s%n%n", - DateWriter.DATEINAME, e.getMessage()); - System.exit(1); - } catch (IOException e) { - System.err.printf("Fehler beim Lesen der Datei %s:%s%n%n", - DateWriter.DATEINAME, e.getMessage()); - System.exit(1); - } finally { - if (dis != null) { - try { - dis.close(); - } catch (IOException e) { - // ignore - } - } - } - } -} diff --git a/solutions/src/main/java/pr2/io/datainputoutput_1/DateWriter.java b/solutions/src/main/java/pr2/io/datainputoutput_1/DateWriter.java deleted file mode 100644 index bc13dcb..0000000 --- a/solutions/src/main/java/pr2/io/datainputoutput_1/DateWriter.java +++ /dev/null @@ -1,63 +0,0 @@ -package pr2.io.datainputoutput_1; - -import java.io.DataOutputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; - -public class DateWriter { - - /** - * Dateiname mit den Testdaten. - */ - public static final String DATEINAME = "/tmp/test.data"; - - /** - * Datumsformat. - */ - public static final String FORMAT = "yyyy-MM-dd"; - - public static void main(String[] args) { - - if (args.length != 1) { - System.err.printf("Bitte eine Datum im Format %s angeben%n%n", - FORMAT); - System.exit(1); - } - - DataOutputStream dos = null; - - try { - DateFormat df = new SimpleDateFormat(FORMAT); - Date date = df.parse(args[0]); - dos = new DataOutputStream( - new FileOutputStream(DATEINAME)); - - dos.writeLong(date.getTime()); - } catch (ParseException e) { - System.err.printf("%s ist kein gültiges Datumsformat: %s%n%n", - args[0], FORMAT); - System.exit(1); - } catch (FileNotFoundException e) { - System.err.printf("Datei %s kann nicht geschrieben werden: %s%n%n", - DATEINAME, e.getMessage()); - System.exit(1); - } catch (IOException e) { - System.err.printf("Fehler beim Schreiben der Datei %s:%s%n%n", - DATEINAME, e.getMessage()); - System.exit(1); - } finally { - if (dos != null) { - try { - dos.close(); - } catch (IOException e) { - // ignore - } - } - } - } -} diff --git a/solutions/src/main/java/pr2/io/datainputoutput_2/DateReader.java b/solutions/src/main/java/pr2/io/datainputoutput_2/DateReader.java deleted file mode 100644 index a8ed6d6..0000000 --- a/solutions/src/main/java/pr2/io/datainputoutput_2/DateReader.java +++ /dev/null @@ -1,45 +0,0 @@ -package pr2.io.datainputoutput_2; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; - -public class DateReader { - - public static void main(String[] args) { - - ObjectInputStream ois = null; - - try { - DateFormat df = new SimpleDateFormat(DateWriter.FORMAT); - ois = new ObjectInputStream( - new FileInputStream(DateWriter.DATEINAME)); - - Date date = (Date) ois.readObject(); - System.out.printf("Das Datum war: %s%n%n", df.format(date)); - - } catch (FileNotFoundException e) { - System.err.printf("Datei %s kann nicht gelesen werden: %s%n%n", - DateWriter.DATEINAME, e.getMessage()); - System.exit(1); - } catch (IOException e) { - System.err.printf("Fehler beim Lesen der Datei %s:%s%n%n", - DateWriter.DATEINAME, e.getMessage()); - System.exit(1); - } catch (ClassNotFoundException e) { - // Date ist Teil der Library, ist immer vorhanden - } finally { - if (ois != null) { - try { - ois.close(); - } catch (IOException e) { - // ignore - } - } - } - } -} diff --git a/solutions/src/main/java/pr2/io/datainputoutput_2/DateWriter.java b/solutions/src/main/java/pr2/io/datainputoutput_2/DateWriter.java deleted file mode 100644 index a966e19..0000000 --- a/solutions/src/main/java/pr2/io/datainputoutput_2/DateWriter.java +++ /dev/null @@ -1,63 +0,0 @@ -package pr2.io.datainputoutput_2; - -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.ObjectOutputStream; -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; - -public class DateWriter { - - /** - * Dateiname mit den Testdaten. - */ - public static final String DATEINAME = "/tmp/test.ser"; - - /** - * Datumsformat. - */ - public static final String FORMAT = "yyyy-MM-dd"; - - public static void main(String[] args) { - - if (args.length != 1) { - System.err.printf("Bitte eine Datum im Format %s angeben%n%n", - FORMAT); - System.exit(1); - } - - ObjectOutputStream dos = null; - - try { - DateFormat df = new SimpleDateFormat(FORMAT); - Date date = df.parse(args[0]); - dos = new ObjectOutputStream( - new FileOutputStream(DATEINAME)); - - dos.writeObject(date); - } catch (ParseException e) { - System.err.printf("%s ist kein gültiges Datumsformat: %s%n%n", - args[0], FORMAT); - System.exit(1); - } catch (FileNotFoundException e) { - System.err.printf("Datei %s kann nicht geschrieben werden: %s%n%n", - DATEINAME, e.getMessage()); - System.exit(1); - } catch (IOException e) { - System.err.printf("Fehler beim Schreiben der Datei %s:%s%n%n", - DATEINAME, e.getMessage()); - System.exit(1); - } finally { - if (dos != null) { - try { - dos.close(); - } catch (IOException e) { - // ignore - } - } - } - } -} diff --git a/solutions/src/main/java/pr2/io/datei_lesen/ReadData.java b/solutions/src/main/java/pr2/io/datei_lesen/ReadData.java deleted file mode 100644 index b75a8dd..0000000 --- a/solutions/src/main/java/pr2/io/datei_lesen/ReadData.java +++ /dev/null @@ -1,33 +0,0 @@ -package pr2.io.datei_lesen; - -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; - -/** - * Daten aus einer Datei lesen. - */ -public class ReadData { - - /** - * Datei. - */ - private static final String FILE = "pr2/io/datei_lesen/daten.dat"; - - /** - * Hauptmethode. - * - * @param args Kommandozeilenargumente. - */ - public static void main(String[] args) { - - try (InputStream is = new FileInputStream(FILE)) { - int data; - while ((data = is.read()) != -1) { - System.out.print("0x" + Integer.toHexString(data) + " "); - } - } catch (IOException e) { - System.err.println("Problem mit Datei: " + e); - } - } -} diff --git a/solutions/src/main/java/pr2/io/datei_schreiben/WriteData.java b/solutions/src/main/java/pr2/io/datei_schreiben/WriteData.java deleted file mode 100644 index dbac0c5..0000000 --- a/solutions/src/main/java/pr2/io/datei_schreiben/WriteData.java +++ /dev/null @@ -1,33 +0,0 @@ -package pr2.io.datei_schreiben; - -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; - -/** - * Daten aus einer Datei lesen. - */ -public class WriteData { - - /** - * Datei. - */ - public static final String FILE = "pr2/io/datei_schreiben/daten.dat"; - - /** - * Hauptmethode. - * - * @param args Kommandozeilenargumente. - */ - public static void main(String[] args) { - - try (OutputStream os = new FileOutputStream(FILE)) { - - os.write(new byte[] {(byte) 0xca, (byte) 0xff, (byte) 0xfe, - (byte) 0xba, (byte) 0xbe, (byte) 0x00, (byte) 0xde, - (byte) 0xad, (byte) 0xbe, (byte) 0xef}); - } catch (IOException e) { - System.err.println("Problem mit Datei: " + e); - } - } -} diff --git a/solutions/src/main/java/pr2/io/datei_schreiben/test/DataTest.java b/solutions/src/main/java/pr2/io/datei_schreiben/test/DataTest.java deleted file mode 100644 index c4fc9fd..0000000 --- a/solutions/src/main/java/pr2/io/datei_schreiben/test/DataTest.java +++ /dev/null @@ -1,39 +0,0 @@ -package pr2.io.datei_schreiben.test; - -import org.junit.jupiter.api.Test; -import pr2.io.datei_schreiben.WriteData; - -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; - -import static org.junit.jupiter.api.Assertions.assertArrayEquals; -import static pr2.io.datei_schreiben.WriteData.FILE; - -/** - * Test für die geschriebenen Daten. - */ -public class DataTest { - - /** - * Geschriebene Daten testen. - * - * @throws IOException Datei-Probleme. - */ - @Test - void testData() throws IOException { - - WriteData.main(new String[0]); - - InputStream is = new FileInputStream(FILE); - - byte[] buffer = new byte[10]; - is.read(buffer); - assertArrayEquals( - new byte[] {(byte) 0xca, (byte) 0xff, (byte) 0xfe, (byte) 0xba, - (byte) 0xbe, (byte) 0x00, (byte) 0xde, (byte) 0xad, - (byte) 0xbe, (byte) 0xef}, buffer); - - is.close(); - } -} diff --git a/solutions/src/main/java/pr2/io/file/FilesystemWalker.java b/solutions/src/main/java/pr2/io/file/FilesystemWalker.java deleted file mode 100644 index d34770d..0000000 --- a/solutions/src/main/java/pr2/io/file/FilesystemWalker.java +++ /dev/null @@ -1,94 +0,0 @@ -package pr2.io.file; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.List; -import java.util.stream.Stream; - -/** - * Klasse, die das Dateisystem durchläuft und Informationen ausgibt. - */ -public class FilesystemWalker { - - /** - * Haupt-Methode. - * - * @param args Kommandozeilen-Argumente. - * @throws IOException IO-Probleme - */ - public static void main(String[] args) throws IOException { - - String path = args.length > 0 ? args[0] : "."; - - Path root = Path.of(path).normalize().toAbsolutePath(); - - System.out.println("Untersuche: " + root); - System.out.println(); - - long total = walk(root); - - System.out.println(); - System.out.println("Gesamtgröße: " + niceSize(total)); - } - - /** - * Rekursive Methode, um den Baum zu durchlaufen. - * - * @param startDir Verzeichnis, bei dem gestartet werden - * soll. - * @return die Größe des Verzeichnisses. - */ - private static long walk(Path startDir) { - - long size = 0; - - if (!Files.isDirectory(startDir)) { - throw new IllegalArgumentException( - startDir + " ist kein Verzeichnis."); - } - - try (Stream fileStream = Files.list(startDir)) { - List files = fileStream.toList(); - - for (Path file : files) { - - if (Files.isDirectory(file) - && Files.isReadable(file) - && Files.isExecutable(file) - && !Files.isSymbolicLink(file) - && Files.exists(file)) { - long dirSize = walk(file); - size += dirSize; - System.out.printf("%s - %s%n", niceSize(dirSize), file); - } - else if (Files.exists(file) && !Files.isSymbolicLink(file)) { - size += Files.size(file); - } - } - } catch (IOException e) { - throw new RuntimeException(e); - } - - return size; - } - - /** - * Wandelt die Größe in eine schönere Darstellung um. - * - * @param size Die Größe. - * @return Schönere Darstellung. - */ - private static String niceSize(long size) { - - if (size > 1000_000L) { - return String.format("%.1f MByte", size / 1024.0 / 1024.0); - } - else if (size > 1000L) { - return String.format("%.1f kByte", size / 1024.0); - } - else { - return String.format("%d Byte", size); - } - } -} diff --git a/solutions/src/main/java/pr2/io/filetest/FileInfo.java b/solutions/src/main/java/pr2/io/filetest/FileInfo.java deleted file mode 100644 index 6d3d875..0000000 --- a/solutions/src/main/java/pr2/io/filetest/FileInfo.java +++ /dev/null @@ -1,40 +0,0 @@ -package pr2.io.filetest; - -import java.nio.file.Files; -import java.io.IOException; -import java.nio.file.Path; - -public class FileInfo { - - public static void main(String[] args) throws IOException { - - if (args.length != 1) { - System.err.println( - "Bitte eine Datei oder ein Verzeichnis angeben"); - System.exit(1); - } - - Path path = Path.of(args[0]).normalize().toAbsolutePath(); - - if (Files.exists(path)) { - System.out.printf("%s existiert%n", path); - System.out.printf("%s ist %d Bytes groß%n", path, Files.size(path)); - } - - if (Files.isDirectory(path)) { - System.out.printf("%s ist ein Verzeichnis%n", path); - } - - if (Files.isRegularFile(path)) { - System.out.printf("%s ist ein normale Datei%n", path); - } - - if (Files.isReadable(path)) { - System.out.printf("%s darf gelesen werden%n", path); - } - - if (Files.isWritable(path)) { - System.out.printf("%s darf geschrieben werden%n", path); - } - } -} diff --git a/solutions/src/main/java/pr2/io/filter/UCaseReader.java b/solutions/src/main/java/pr2/io/filter/UCaseReader.java deleted file mode 100644 index 672e75e..0000000 --- a/solutions/src/main/java/pr2/io/filter/UCaseReader.java +++ /dev/null @@ -1,36 +0,0 @@ -package pr2.io.filter; - -import java.io.FilterReader; -import java.io.IOException; -import java.io.Reader; - -/** - * Filter-Reader, der den Inhalt in Großbuchstaben umwandelt. - */ -public class UCaseReader extends FilterReader { - - - /** - * Legt einen neuen Reader an. - * - * @param in Reader, von dem die Daten gelesen werden. - */ - public UCaseReader(Reader in) { - super(in); - } - - /** - * @see FilterReader#read(char[], int, int). - */ - @Override - public int read(char[] cbuf, int off, int len) throws IOException { - - int charsGelesen = super.read(cbuf, off, len); - - for (int i = 0; i < cbuf.length; i++) { - cbuf[i] = Character.toUpperCase(cbuf[i]); - } - - return charsGelesen; - } -} diff --git a/solutions/src/main/java/pr2/io/filter/test/UCaseReaderTest.java b/solutions/src/main/java/pr2/io/filter/test/UCaseReaderTest.java deleted file mode 100644 index 9546c4a..0000000 --- a/solutions/src/main/java/pr2/io/filter/test/UCaseReaderTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package pr2.io.filter.test; - -import org.junit.jupiter.api.Test; -import pr2.io.filter.UCaseReader; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.StringReader; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * Test für die Rot13 "Verschlüsselung". - */ -public class UCaseReaderTest { - - /** - * Testmethode. - * - * @throws IOException IO-Probleme - */ - @Test - void testReader() throws IOException { - - BufferedReader br = new BufferedReader( - new UCaseReader(new StringReader( - "Dies ist" + " ein Test für den UCASE-Reader."))); - - String line = br.readLine(); - assertEquals("DIES IST EIN TEST FÜR DEN UCASE-READER.", line); - - br.close(); - } -} diff --git a/solutions/src/main/java/pr2/io/konsole/ConsoleToFile.java b/solutions/src/main/java/pr2/io/konsole/ConsoleToFile.java deleted file mode 100644 index 20e6935..0000000 --- a/solutions/src/main/java/pr2/io/konsole/ConsoleToFile.java +++ /dev/null @@ -1,46 +0,0 @@ -package pr2.io.konsole; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.PrintStream; - -/** - * Liest einen Text von der Console und - * schreibt ihn dann in eine Datei. Allerdings - * erfolgt das Schreiben über eine Ausgabeumleitung - * und nicht über Dateioperationen. - */ -public class ConsoleToFile { - - /** - * Logfile für Ausgaben. - */ - private static final String LOGFILE = "console.log"; - - /** - * Hauptmethode. - * - * @param args Kommandozeile-Argumente. - */ - public static void main(String[] args) { - - try (BufferedReader br = new BufferedReader( - new InputStreamReader(System.in)); - - PrintStream ps = new PrintStream(LOGFILE)) { - - System.setOut(ps); - - String line; - int count = 1; - - while ((line = br.readLine()) != null) { - System.out.println(line); - System.err.println(count++); - } - } catch (IOException ex) { - System.err.println("Dateiproblem: " + ex); - } - } -} diff --git a/solutions/src/main/java/pr2/io/linecounter/LineCounter.java b/solutions/src/main/java/pr2/io/linecounter/LineCounter.java deleted file mode 100644 index 3c51768..0000000 --- a/solutions/src/main/java/pr2/io/linecounter/LineCounter.java +++ /dev/null @@ -1,29 +0,0 @@ -package pr2.io.linecounter; - -import java.io.BufferedReader; -import java.io.FileReader; -import java.io.IOException; - -public class LineCounter { - - public static void main(String[] args) throws IOException { - - int lines = 0; - - if (args.length != 1) { - System.err.println("Bitte eine Datei angeben"); - System.exit(1); - } - - BufferedReader br = new BufferedReader(new FileReader(args[0])); - - - while (br.readLine() != null) { - lines++; - } - - br.close(); - - System.out.printf("Datei: %s hat %d Zeilen%n", args[0], lines); - } -} diff --git a/solutions/src/main/java/pr2/io/random_access/FileSort.java b/solutions/src/main/java/pr2/io/random_access/FileSort.java deleted file mode 100644 index f35241c..0000000 --- a/solutions/src/main/java/pr2/io/random_access/FileSort.java +++ /dev/null @@ -1,58 +0,0 @@ -package pr2.io.random_access; - -import java.io.IOException; -import java.io.RandomAccessFile; - -/** - * Sortierung von Dateien (in place). - */ -public class FileSort { - - /** - * Sortiert die Datei von Byte-Werten per Bubble-Sort. - * - * @param filename Dateiname - * @throws IOException IO-Probleme - */ - public static void sortFile(String filename) throws IOException { - - RandomAccessFile rf = new RandomAccessFile(filename, "rw"); - - byte b1; // erstes Byte - byte b2; // zweites Byte - - long pos = 0; - boolean swap = false; - - while (true) { - // an die Position springen - rf.seek(pos); - - // zwei Bytes lesen - b1 = rf.readByte(); - b2 = rf.readByte(); - - if (b1 > b2) { - // erstes ist größer als zweites, austauschen - rf.seek(pos); - rf.write(b2); - rf.write(b1); - swap = true; - } - - pos++; - - if (pos >= rf.length() - 1) { - if (swap) { - pos = 0; - swap = false; - } - else { - break; - } - } - } - - rf.close(); - } -} diff --git a/solutions/src/main/java/pr2/io/random_access/test/FileSortTest.java b/solutions/src/main/java/pr2/io/random_access/test/FileSortTest.java deleted file mode 100644 index 9ffdc05..0000000 --- a/solutions/src/main/java/pr2/io/random_access/test/FileSortTest.java +++ /dev/null @@ -1,63 +0,0 @@ -package pr2.io.random_access.test; - -import org.junit.jupiter.api.Test; -import pr2.io.random_access.FileSort; - -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * Testet die Sortierung per Random-Access-File. - */ -public class FileSortTest { - - /** - * Kopiert die Datei f1 als Datei f2. - * - * @param f1 Quell-Datei - * @param f2 Ziel-Datei - * @throws IOException IO-Probleme - */ - private static void copyFile(String f1, String f2) throws IOException { - - FileInputStream fis = new FileInputStream(f1); - FileOutputStream fos = new FileOutputStream(f2); - - int b; - - while ((b = fis.read()) != -1) { - fos.write(b); - } - - fis.close(); - fos.close(); - } - - /** - * Testet die File-Sortierung. - * - * @throws IOException IO-Problem - */ - @Test - void testBubbleSort() throws IOException { - copyFile("assets/data.dat", "output/data.dat"); - FileSort.sortFile("output/data.dat"); - - InputStream is = new FileInputStream("output/data.dat"); - - int data; - byte lastByte = 0; - - while ((data = is.read()) >= 0) { - byte b = (byte) data; - assertTrue(b >= lastByte); - lastByte = b; - } - - is.close(); - } -} diff --git a/solutions/src/main/java/pr2/io/reader_writer/ReadAndPrintFile.java b/solutions/src/main/java/pr2/io/reader_writer/ReadAndPrintFile.java deleted file mode 100644 index 88818a3..0000000 --- a/solutions/src/main/java/pr2/io/reader_writer/ReadAndPrintFile.java +++ /dev/null @@ -1,34 +0,0 @@ -package pr2.io.reader_writer; - -import java.io.FileReader; -import java.io.IOException; -import java.io.Reader; - -/** - * Liest eine Textdatei und gibt den Inhalt auf der Konsole aus. - */ -public class ReadAndPrintFile { - - /** - * Hauptmethode. - * - * @param args Kommandozeilen-Argumente. - */ - public static void main(String[] args) { - - String filename = args.length == 1 - ? args[0] - : "pr2/io/reader_writer/kafka.txt"; - - try (Reader r = new FileReader(filename)) { - char[] buffer = new char[1024]; - int length; - - while ((length = r.read(buffer)) >= 0) { - System.out.print(new String(buffer, 0, length)); - } - } catch (IOException e) { - System.err.println("IO-Problem: " + e); - } - } -} diff --git a/solutions/src/main/java/pr2/io/rot13/Rot13.java b/solutions/src/main/java/pr2/io/rot13/Rot13.java deleted file mode 100644 index a0a3787..0000000 --- a/solutions/src/main/java/pr2/io/rot13/Rot13.java +++ /dev/null @@ -1,25 +0,0 @@ -package pr2.io.rot13; - -import java.io.BufferedReader; -import java.io.FileReader; -import java.io.IOException; - -public class Rot13 { - - public static void main(String[] args) throws IOException { - if (args.length != 1) { - System.err.println("Bitte eine Datei angeben"); - System.exit(1); - } - - BufferedReader br = new BufferedReader( - new Rot13Reader(new FileReader(args[0]))); - - String line; - while ((line = br.readLine()) != null) { - System.out.println(line); - } - - br.close(); - } -} diff --git a/solutions/src/main/java/pr2/io/rot13/Rot13Reader.java b/solutions/src/main/java/pr2/io/rot13/Rot13Reader.java deleted file mode 100644 index 04cb929..0000000 --- a/solutions/src/main/java/pr2/io/rot13/Rot13Reader.java +++ /dev/null @@ -1,24 +0,0 @@ -package pr2.io.rot13; - -import java.io.FilterReader; -import java.io.IOException; -import java.io.Reader; - -public class Rot13Reader extends FilterReader { - - public Rot13Reader(Reader in) { - super(in); - } - - @Override - public int read(char[] cbuf, int off, int len) throws IOException { - - int charsGelesen = super.read(cbuf, off, len); - - for (int i = 0; i < cbuf.length; i++) { - cbuf[i] = cbuf[i] != '\n' ? (char) (cbuf[i] + 13) : '\n'; - } - - return charsGelesen; - } -} diff --git a/solutions/src/main/java/pr2/io/scrambler/Scrambler.java b/solutions/src/main/java/pr2/io/scrambler/Scrambler.java deleted file mode 100644 index f045627..0000000 --- a/solutions/src/main/java/pr2/io/scrambler/Scrambler.java +++ /dev/null @@ -1,38 +0,0 @@ -package pr2.io.scrambler; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; - -public class Scrambler { - - public static void main(String[] args) throws IOException { - if (args.length != 1) { - System.err.println("Bitte eine Datei angeben"); - System.exit(1); - } - - FileInputStream fis; - - try { - fis = new FileInputStream(args[0]); - } catch (FileNotFoundException e) { - System.err.printf("Datei nicht gefunden: %s%n", args[0]); - System.exit(1); - return; // never reached - } - - int input; - int count = 0; - - while ((input = fis.read()) != -1) { - byte b = (byte) input; - - if (count++ % 2 == 0) { - System.out.write(b); - } - } - - fis.close(); - } -} diff --git a/solutions/src/main/java/pr2/io/serialisierung/Board.java b/solutions/src/main/java/pr2/io/serialisierung/Board.java deleted file mode 100644 index f40fa6b..0000000 --- a/solutions/src/main/java/pr2/io/serialisierung/Board.java +++ /dev/null @@ -1,139 +0,0 @@ -package pr2.io.serialisierung; - -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; - -/** - * Ein Dame-Brett. - */ -public class Board implements Serializable { - - /** - * Belegung des Brettes. - */ - private final Color[][] brett = new Color[8][8]; - - /** - * Liest den Inhalt aus einer Datei. - * - * @param file Dateipfad. - * @return das gelesene Spielfeld - * @throws IOException IO-Probleme - */ - public static Board loadFromFile(String file) throws IOException { - - ObjectInputStream ois = - new ObjectInputStream(new FileInputStream(file)); - - Board result; - - try { - result = (Board) ois.readObject(); - ois.close(); - } catch (ClassNotFoundException e) { - ois.close(); - throw new IOException("Serialization: Class not found", e); - } - - return result; - } - - /** - * Schreibt den Inhalt des Spielfeldes in eine Datei. - * - * @param file Dateiname. - * @throws IOException IO-Probleme - */ - public void writeToFile(String file) throws IOException { - ObjectOutputStream oos = - new ObjectOutputStream(new FileOutputStream(file)); - oos.writeObject(this); - oos.close(); - } - - /** - * Setzt einen Stein an die gegebene Koordinate. - * - * @param koordinate Koordinate in "a1"-Notation. - * @param farbe Fabe des Spielsteins. - */ - public void set(String koordinate, Color farbe) { - Tupel t = parseCoordinates(koordinate); - brett[t.x][t.y] = farbe; - } - - /** - * Wandelt textuelle Koordinaten in x- und y-Wert um. - * - * @param koordinate Koordinate als String. - * @return Koordinate als Integer-Tupel. - */ - private Tupel parseCoordinates(String koordinate) { - char buchstabe = koordinate.toLowerCase().charAt(0); - char zahl = koordinate.charAt(1); - - Tupel t = new Tupel(); - - t.y = buchstabe - 'a'; - t.x = zahl - '1'; - - if (t.x < 0 || t.x > 7) { - throw new IllegalArgumentException(); - } - - if (t.y < 0 || t.y > 7) { - throw new IllegalArgumentException(); - } - - return t; - } - - /** - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - - StringBuilder result = new StringBuilder(); - - char y = '1'; - - result.append(" "); - for (char c : "abcdefgh".toCharArray()) { - result.append(' ').append(c); - } - - result.append("\n"); - - for (Color[] figurs : brett) { - - result.append(y++); - - for (Color figur : figurs) { - if (figur != null) { - result.append(' ').append(figur); - } - else { - result.append(" "); - } - } - - result.append("\n"); - } - - return result.toString(); - } - - /** - * Tupel von zwei int-Werten. - */ - private static class Tupel { - int x; - - int y; - } -} diff --git a/solutions/src/main/java/pr2/io/serialisierung/Color.java b/solutions/src/main/java/pr2/io/serialisierung/Color.java deleted file mode 100644 index 7f8f76b..0000000 --- a/solutions/src/main/java/pr2/io/serialisierung/Color.java +++ /dev/null @@ -1,30 +0,0 @@ -package pr2.io.serialisierung; - -/** - * Farben der Spielsteine. - */ -public enum Color { - - /** - * Schwarzer Stein. - */ - BLACK, - - /** - * Weißer Stein. - */ - WHITE; - - /** - * @see java.lang.Enum#toString() - */ - @Override - public String toString() { - if (this == Color.BLACK) { - return "B"; - } - else { - return "W"; - } - } -} diff --git a/solutions/src/main/java/pr2/io/serialisierung/test/BoardTest.java b/solutions/src/main/java/pr2/io/serialisierung/test/BoardTest.java deleted file mode 100644 index c2ab936..0000000 --- a/solutions/src/main/java/pr2/io/serialisierung/test/BoardTest.java +++ /dev/null @@ -1,46 +0,0 @@ -package pr2.io.serialisierung.test; - -import org.junit.jupiter.api.Test; -import pr2.io.serialisierung.Board; -import pr2.io.serialisierung.Color; - -import java.io.IOException; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * Test. - */ -public class BoardTest { - - /** - * Test für die Implementierung des Spielbrettes. - * - * @throws IOException Datei-Probleme. - */ - @Test - void testDame() throws IOException { - Board s = new Board(); - s.set("a1", Color.BLACK); - s.set("b1", Color.WHITE); - s.set("h1", Color.BLACK); - s.set("h2", Color.BLACK); - s.set("a8", Color.BLACK); - s.set("f8", Color.BLACK); - s.set("f5", Color.WHITE); - s.set("e3", Color.WHITE); - s.set("g2", Color.WHITE); - - String stringRepresentation = s.toString(); - - s.writeToFile("/tmp/daten.dat"); - - s = Board.loadFromFile("/tmp/daten.dat"); - - assertEquals(stringRepresentation, s.toString()); - - s = Board.loadFromFile("pr2/io/serialisierung/testdata.dat"); - - assertEquals(stringRepresentation, s.toString()); - } -} diff --git a/solutions/src/main/java/pr2/lambda/anonymous/Alien.java b/solutions/src/main/java/pr2/lambda/anonymous/Alien.java deleted file mode 100644 index 15ab6ce..0000000 --- a/solutions/src/main/java/pr2/lambda/anonymous/Alien.java +++ /dev/null @@ -1,46 +0,0 @@ -package pr2.lambda.anonymous; - -import de.smits_net.games.framework.board.Board; -import de.smits_net.games.framework.image.AnimatedImage; -import de.smits_net.games.framework.image.ImagePack; -import de.smits_net.games.framework.image.StripedImage; -import de.smits_net.games.framework.sprite.AnimatedSprite; -import de.smits_net.games.framework.sprite.Direction; - -import java.awt.Point; - -/** - * Ein Alien. - */ -public class Alien extends AnimatedSprite { - - /** - * Geschwindigkeit des Aliens X-Richtung. - */ - private static final int ALIEN_SPEED = 2; - - /** - * Neues Alien anlegen. - * - * @param board das Spielfeld - * @param startPoint Start-Position - */ - public Alien(Board board, Point startPoint) { - super(board, startPoint, BoundaryPolicy.JUMP_BACK, - new AnimatedImage(50, - new ImagePack("pr2/lambda/anonymous/", - "ship01", "ship02", "ship03"))); - velocity.setVelocity(Direction.WEST, ALIEN_SPEED); - } - - /** - * Alien explodieren lassen. - */ - public void explode() { - setActive(false); - setImages(new AnimatedImage(20, - new StripedImage("pr2/lambda/anonymous/explosion_1" + ".png", - 43))); - setInvisibleAfterFrames(70); - } -} diff --git a/solutions/src/main/java/pr2/lambda/anonymous/GameBoard.java b/solutions/src/main/java/pr2/lambda/anonymous/GameBoard.java deleted file mode 100644 index b436c76..0000000 --- a/solutions/src/main/java/pr2/lambda/anonymous/GameBoard.java +++ /dev/null @@ -1,73 +0,0 @@ -package pr2.lambda.anonymous; - -import de.smits_net.games.framework.board.Board; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Point; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.Random; - -/** - * Spielfeld. - */ -public class GameBoard extends Board { - - /** - * Alien, das durch das Bild läuft. - */ - Alien alien; // nicht private wegen des Zugriffs aus der inneren Klasse - - /** - * Erzeugt ein neues Board. - */ - public GameBoard() { - // neues Spielfeld anlegen - super(10, new Dimension(800, 300), Color.BLACK); - - // Alien initialisieren - alien = new Alien(this, - new Point(800, 50 + new Random().nextInt(100))); - - // Event-Handler für Clicks. - addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - if (alien.intersects(e.getPoint())) { - alien.explode(); - } - else { - alien.setPosition(e.getPoint()); - } - } - }); - } - - /** - * Spielfeld neu zeichnen. Wird vom Framework aufgerufen. - */ - @Override - public void drawGame(Graphics g) { - // Alien zeichnen - alien.draw(g, this); - } - - /** - * Game-Over-Text anzeigen. Wird vom Framework aufgerufen. - */ - @Override - public void drawGameOver(Graphics g) { - centerText(g, "Das Spiel ist aus!"); - } - - /** - * Spielsituation updaten. Wird vom Framework aufgerufen. - */ - @Override - public boolean updateGame() { - alien.move(); - return alien.isVisible(); - } -} diff --git a/solutions/src/main/java/pr2/lambda/anonymous/GameMain.java b/solutions/src/main/java/pr2/lambda/anonymous/GameMain.java deleted file mode 100644 index 33056e6..0000000 --- a/solutions/src/main/java/pr2/lambda/anonymous/GameMain.java +++ /dev/null @@ -1,28 +0,0 @@ -package pr2.lambda.anonymous; - -import de.smits_net.games.framework.board.MainWindow; - -import java.awt.EventQueue; - -/** - * Hauptklasse des Spiels. - */ -public class GameMain extends MainWindow { - - /** - * Neues Spiel anlegen. - */ - public GameMain() { - super("Click Alien - (04) Anonymous Class", new GameBoard()); - - } - - /** - * Startpunkt. - * - * @param args command line arguments. - */ - public static void main(String[] args) { - EventQueue.invokeLater(GameMain::new); - } -} diff --git a/solutions/src/main/java/pr2/lambda/array_sorter/ReverseSort.java b/solutions/src/main/java/pr2/lambda/array_sorter/ReverseSort.java deleted file mode 100644 index 50ac85d..0000000 --- a/solutions/src/main/java/pr2/lambda/array_sorter/ReverseSort.java +++ /dev/null @@ -1,28 +0,0 @@ -package pr2.lambda.array_sorter; - -import java.util.Arrays; -import java.util.Comparator; -import java.util.Date; - -public class ReverseSort { - - public static void main(String[] args) { - Date[] dates = { - new Date(9200000000L), - new Date(9300000000L), - new Date(92100000000L), - new Date(9600000000L), - new Date(93300000000L) - }; - - Arrays.sort(dates, new Comparator() { - - @Override - public int compare(Date o1, Date o2) { - return o1.compareTo(o2) * -1; - } - }); - - System.out.println(Arrays.asList(dates)); - } -} diff --git a/solutions/src/main/java/pr2/lambda/callback/Main.java b/solutions/src/main/java/pr2/lambda/callback/Main.java deleted file mode 100644 index b493c8f..0000000 --- a/solutions/src/main/java/pr2/lambda/callback/Main.java +++ /dev/null @@ -1,46 +0,0 @@ -package pr2.lambda.callback; - -import java.util.Arrays; - -/** - * Hauptklasse. - */ -public class Main { - - private static final int[] ZAHLEN = - {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20}; - - /** - * Hauptmethode. - * - * @param args Kommandozeilenargumente. - */ - public static void main(String[] args) { - - NumberSelector s = new NumberSelector(); - - int[] gerade; - - gerade = s.filter(new Predicate() { - @Override - public boolean accept(Integer object) { - return object % 2 == 0; - } - }, ZAHLEN); - - System.out.println(Arrays.toString(gerade)); - - int[] ungerade; - - ungerade = s.filter(new Predicate() { - @Override - public boolean accept(Integer object) { - return object % 2 != 0; - } - }, ZAHLEN); - - System.out.println(Arrays.toString(ungerade)); - - } -} diff --git a/solutions/src/main/java/pr2/lambda/callback/NumberSelector.java b/solutions/src/main/java/pr2/lambda/callback/NumberSelector.java deleted file mode 100644 index bbce522..0000000 --- a/solutions/src/main/java/pr2/lambda/callback/NumberSelector.java +++ /dev/null @@ -1,30 +0,0 @@ -package pr2.lambda.callback; - -/** - * Auswählen von Zahlen mithilfe eines Callbacks. - */ -public class NumberSelector { - - /** - * Filtert die übergebenen Zahlen anhand des Prädikates. - * - * @param predicate Prädikat. - * @param numbers die zu filternden Zahlen. - * @return Das Ergebnis - */ - public int[] filter(Predicate predicate, int[] numbers) { - - int[] temp = new int[numbers.length]; - int count = 0; - - for (int i : numbers) { - if (predicate.accept(i)) { - temp[count++] = i; - } - } - - int[] result = new int[count]; - System.arraycopy(temp, 0, result, 0, count); - return result; - } -} diff --git a/solutions/src/main/java/pr2/lambda/callback/Predicate.java b/solutions/src/main/java/pr2/lambda/callback/Predicate.java deleted file mode 100644 index bf3f416..0000000 --- a/solutions/src/main/java/pr2/lambda/callback/Predicate.java +++ /dev/null @@ -1,20 +0,0 @@ -package pr2.lambda.callback; - -/** - * Interface, um Entscheidung über ein Objekt zu - * treffen. - * - * @param Typ des Objekts - */ -@FunctionalInterface -public interface Predicate { - - /** - * Entscheidet, ob ein Objekt akzeptiert wird oder nicht. - * - * @param object das zu untersuchende Objekt - * @return {@code true} wenn das Objekt akzeptiert wird, - * andernfalls {@code false}. - */ - boolean accept(T object); -} diff --git a/solutions/src/main/java/pr2/lambda/comparator/SortLambda.java b/solutions/src/main/java/pr2/lambda/comparator/SortLambda.java deleted file mode 100644 index 9a605d8..0000000 --- a/solutions/src/main/java/pr2/lambda/comparator/SortLambda.java +++ /dev/null @@ -1,12 +0,0 @@ -package pr2.lambda.comparator; - -import java.util.Arrays; - -public class SortLambda { - - public static void main(String[] args) { - Integer[] zahlen = {23, 42, 17, 9, 1, 5, 7, 88, 35}; - Arrays.sort(zahlen, (a, b) -> b - a); - System.out.println(Arrays.toString(zahlen)); - } -} diff --git a/solutions/src/main/java/pr2/lambda/lambdas/Main.java b/solutions/src/main/java/pr2/lambda/lambdas/Main.java deleted file mode 100644 index bbca68e..0000000 --- a/solutions/src/main/java/pr2/lambda/lambdas/Main.java +++ /dev/null @@ -1,31 +0,0 @@ -package pr2.lambda.lambdas; - -import java.util.Arrays; - -/** - * Hauptklasse. - */ -public class Main { - - private static final int[] ZAHLEN = - {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20}; - - /** - * Hauptmethode. - * - * @param args Kommandozeileargumente. - */ - public static void main(String[] args) { - - NumberSelector s = new NumberSelector(); - - int[] gerade = s.filter((i) -> i % 2 == 0, ZAHLEN); - - System.out.println(Arrays.toString(gerade)); - - int[] ungerade = s.filter((i) -> i % 2 != 0, ZAHLEN); - - System.out.println(Arrays.toString(ungerade)); - } -} diff --git a/solutions/src/main/java/pr2/lambda/lambdas/NumberSelector.java b/solutions/src/main/java/pr2/lambda/lambdas/NumberSelector.java deleted file mode 100644 index 16f974b..0000000 --- a/solutions/src/main/java/pr2/lambda/lambdas/NumberSelector.java +++ /dev/null @@ -1,30 +0,0 @@ -package pr2.lambda.lambdas; - -/** - * Auswählen von Zahlen mithilfe eines Callbacks. - */ -public class NumberSelector { - - /** - * Filtert die übergebenen Zahlen anhand des Prädikates. - * - * @param predicate Prädikat. - * @param numbers die zu filternden Zahlen. - * @return Das Ergebnis - */ - public int[] filter(Predicate predicate, int[] numbers) { - - int[] temp = new int[numbers.length]; - int count = 0; - - for (int i : numbers) { - if (predicate.accept(i)) { - temp[count++] = i; - } - } - - int[] result = new int[count]; - System.arraycopy(temp, 0, result, 0, count); - return result; - } -} diff --git a/solutions/src/main/java/pr2/lambda/lambdas/Predicate.java b/solutions/src/main/java/pr2/lambda/lambdas/Predicate.java deleted file mode 100644 index d8aa4ee..0000000 --- a/solutions/src/main/java/pr2/lambda/lambdas/Predicate.java +++ /dev/null @@ -1,20 +0,0 @@ -package pr2.lambda.lambdas; - -/** - * Interface, um Entscheidung über ein Objekt zu - * treffen. - * - * @param Typ des Objekts - */ -@FunctionalInterface -public interface Predicate { - - /** - * Entscheidet, ob ein Objekt akzeptiert wird oder nicht. - * - * @param object das zu untersuchende Objekt - * @return {@code true} wenn das Objekt akzeptiert wird, - * andernfalls {@code false}. - */ - boolean accept(T object); -} diff --git a/solutions/src/main/java/pr2/lambda/local/Alien.java b/solutions/src/main/java/pr2/lambda/local/Alien.java deleted file mode 100644 index 0a83b03..0000000 --- a/solutions/src/main/java/pr2/lambda/local/Alien.java +++ /dev/null @@ -1,46 +0,0 @@ -package pr2.lambda.local; - -import de.smits_net.games.framework.board.Board; -import de.smits_net.games.framework.image.AnimatedImage; -import de.smits_net.games.framework.image.ImagePack; -import de.smits_net.games.framework.image.StripedImage; -import de.smits_net.games.framework.sprite.AnimatedSprite; -import de.smits_net.games.framework.sprite.Direction; - -import java.awt.Point; - -/** - * Ein Alien. - */ -public class Alien extends AnimatedSprite { - - /** - * Geschwindigkeit des Aliens X-Richtung. - */ - private static final int ALIEN_SPEED = 2; - - /** - * Neues Alien anlegen. - * - * @param board das Spielfeld - * @param startPoint Start-Position - */ - public Alien(Board board, Point startPoint) { - super(board, startPoint, BoundaryPolicy.JUMP_BACK, - new AnimatedImage(50, - new ImagePack("pr2/lambda/local/", - "ship01", "ship02", "ship03"))); - velocity.setVelocity(Direction.WEST, ALIEN_SPEED); - } - - /** - * Alien explodieren lassen. - */ - public void explode() { - setActive(false); - setImages(new AnimatedImage(20, - new StripedImage("pr2/lambda/local/explosion_1" + ".png", - 43))); - setInvisibleAfterFrames(70); - } -} diff --git a/solutions/src/main/java/pr2/lambda/local/GameBoard.java b/solutions/src/main/java/pr2/lambda/local/GameBoard.java deleted file mode 100644 index 52cb76d..0000000 --- a/solutions/src/main/java/pr2/lambda/local/GameBoard.java +++ /dev/null @@ -1,72 +0,0 @@ -package pr2.lambda.local; - -import de.smits_net.games.framework.board.Board; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Point; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.Random; - -/** - * Spielfeld. - */ -public class GameBoard extends Board { - - /** - * Alien, das durch das Bild läuft. - */ - Alien alien; // nicht private wegen Zugriff aus innerer Klasse - - /** - * Erzeugt ein neues Board. - */ - public GameBoard() { - // neues Spielfeld anlegen - super(10, new Dimension(800, 300), Color.BLACK); - - // Alien initialisieren - alien = new Alien(this, - new Point(800, 50 + new Random().nextInt(100))); - - /* Event-Handler für Clicks. */ - class AlienExploder extends MouseAdapter { - @Override - public void mousePressed(MouseEvent e) { - if (alien.intersects(e.getPoint())) { - alien.explode(); - } - } - } - - addMouseListener(new AlienExploder()); - } - - /** - * Spielfeld neu zeichnen. Wird vom Framework aufgerufen. - */ - @Override - public void drawGame(Graphics g) { - // Alien zeichnen - alien.draw(g, this); - } - - /** - * Game-Over-Text anzeigen. Wird vom Framework aufgerufen. - */ - @Override - public void drawGameOver(Graphics g) { - centerText(g, "Das Spiel ist aus!"); - } - - /** - * Spielsituation updaten. Wird vom Framework aufgerufen. - */ - @Override - public boolean updateGame() { - alien.move(); - return alien.isVisible(); - } -} diff --git a/solutions/src/main/java/pr2/lambda/local/GameMain.java b/solutions/src/main/java/pr2/lambda/local/GameMain.java deleted file mode 100644 index ec4aab1..0000000 --- a/solutions/src/main/java/pr2/lambda/local/GameMain.java +++ /dev/null @@ -1,28 +0,0 @@ -package pr2.lambda.local; - -import de.smits_net.games.framework.board.MainWindow; - -import java.awt.EventQueue; - -/** - * Hauptklasse des Spiels. - */ -public class GameMain extends MainWindow { - - /** - * Neues Spiel anlegen. - */ - public GameMain() { - super("Click Alien - (03) Local Class", new GameBoard()); - - } - - /** - * Startpunkt. - * - * @param args command line arguments. - */ - public static void main(String[] args) { - EventQueue.invokeLater(GameMain::new); - } -} diff --git a/solutions/src/main/java/pr2/lambda/matrixsuche/MatrixSuche.java b/solutions/src/main/java/pr2/lambda/matrixsuche/MatrixSuche.java deleted file mode 100644 index 21b2d88..0000000 --- a/solutions/src/main/java/pr2/lambda/matrixsuche/MatrixSuche.java +++ /dev/null @@ -1,39 +0,0 @@ -package pr2.lambda.matrixsuche; - -public class MatrixSuche { - - public static class Position { - private final int xPos; - private final int yPos; - - public Position(int xPos, int yPos) { - this.xPos = xPos; - this.yPos = yPos; - } - - public int getxPos() { - return xPos; - } - - public int getyPos() { - return yPos; - } - - @Override - public String toString() { - return String.format("(%d, %d)", xPos, yPos); - } - } - - public static Position findEntry(int[][] matrix, int wert) { - for (int i = 0; i < matrix.length; i++) { - for (int k = 0; k < matrix[i].length; k++) { - if (matrix[i][k] == wert) { - return new Position(i, k); - } - } - } - - return null; - } -} diff --git a/solutions/src/main/java/pr2/lambda/matrixsuche/test/MatrixSucheTest.java b/solutions/src/main/java/pr2/lambda/matrixsuche/test/MatrixSucheTest.java deleted file mode 100644 index f481817..0000000 --- a/solutions/src/main/java/pr2/lambda/matrixsuche/test/MatrixSucheTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package pr2.lambda.matrixsuche.test; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import pr2.lambda.matrixsuche.MatrixSuche; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; - -public class MatrixSucheTest { - - @Test - void testSuche() { - - int[][] matrix = { - {3, 5, 6, 7, 8}, - {10, 12, 14, 16, 18}, - {23, 25, 26, 27, 28} - }; - - Assertions.assertEquals("(0, 1)", - MatrixSuche.findEntry(matrix, 5).toString()); - assertEquals("(2, 0)", - MatrixSuche.findEntry(matrix, 23).toString()); - assertEquals("(1, 2)", - MatrixSuche.findEntry(matrix, 14).toString()); - assertEquals("(0, 4)", - MatrixSuche.findEntry(matrix, 8).toString()); - assertNull( - MatrixSuche.findEntry(matrix, 99)); - } -} diff --git a/solutions/src/main/java/pr2/lambda/mogrifier_1/StringFunction.java b/solutions/src/main/java/pr2/lambda/mogrifier_1/StringFunction.java deleted file mode 100644 index 9d98357..0000000 --- a/solutions/src/main/java/pr2/lambda/mogrifier_1/StringFunction.java +++ /dev/null @@ -1,6 +0,0 @@ -package pr2.lambda.mogrifier_1; - -@FunctionalInterface -public interface StringFunction { - String apply(String s); -} diff --git a/solutions/src/main/java/pr2/lambda/mogrifier_1/StringTransmogrifier.java b/solutions/src/main/java/pr2/lambda/mogrifier_1/StringTransmogrifier.java deleted file mode 100644 index 21d976a..0000000 --- a/solutions/src/main/java/pr2/lambda/mogrifier_1/StringTransmogrifier.java +++ /dev/null @@ -1,14 +0,0 @@ -package pr2.lambda.mogrifier_1; - -public class StringTransmogrifier { - - public static String[] transmogrify(String[] elements, StringFunction t) { - String[] result = new String[elements.length]; - - for (int i = 0; i < elements.length; i++) { - result[i] = t.apply(elements[i]); - } - - return result; - } -} diff --git a/solutions/src/main/java/pr2/lambda/mogrifier_1/test/StringTransmogrifierTest.java b/solutions/src/main/java/pr2/lambda/mogrifier_1/test/StringTransmogrifierTest.java deleted file mode 100644 index 8b3bb4d..0000000 --- a/solutions/src/main/java/pr2/lambda/mogrifier_1/test/StringTransmogrifierTest.java +++ /dev/null @@ -1,33 +0,0 @@ -package pr2.lambda.mogrifier_1.test; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import pr2.lambda.mogrifier_1.StringTransmogrifier; - -import static org.junit.jupiter.api.Assertions.assertArrayEquals; - -public class StringTransmogrifierTest { - - @Test - void testMogrification() { - String[] elements = {"Hello", "World"}; - - Assertions.assertArrayEquals(new String[] { "hello", "world"}, - StringTransmogrifier.transmogrify(elements, - String::toLowerCase)); - - assertArrayEquals(new String[] { "HELLO", "WORLD"}, - StringTransmogrifier.transmogrify(elements, - String::toUpperCase)); - - assertArrayEquals(new String[] { "Ifmmp", "Xpsme"}, - StringTransmogrifier.transmogrify(elements, - s -> { - char[] c = s.toCharArray(); - for (int i = 0; i < c.length; i++) { - c[i] = (char) (c[i] + 1); - } - return new String(c); - })); - } -} diff --git a/solutions/src/main/java/pr2/lambda/mogrifier_2/StringFunction.java b/solutions/src/main/java/pr2/lambda/mogrifier_2/StringFunction.java deleted file mode 100644 index 070ee01..0000000 --- a/solutions/src/main/java/pr2/lambda/mogrifier_2/StringFunction.java +++ /dev/null @@ -1,18 +0,0 @@ -package pr2.lambda.mogrifier_2; - -@FunctionalInterface -public interface StringFunction { - static StringFunction caesar(final int shift) { - return (s) -> shiftCharacters(s, shift); - } - - static String shiftCharacters(String s, int shift) { - char[] c = s.toCharArray(); - for (int i = 0; i < c.length; i++) { - c[i] = (char) (c[i] + shift); - } - return new String(c); - } - - String apply(String s); -} diff --git a/solutions/src/main/java/pr2/lambda/mogrifier_2/StringTransmogrifier.java b/solutions/src/main/java/pr2/lambda/mogrifier_2/StringTransmogrifier.java deleted file mode 100644 index 79b64a4..0000000 --- a/solutions/src/main/java/pr2/lambda/mogrifier_2/StringTransmogrifier.java +++ /dev/null @@ -1,14 +0,0 @@ -package pr2.lambda.mogrifier_2; - -public class StringTransmogrifier { - - public static String[] transmogrify(String[] elements, StringFunction t) { - String[] result = new String[elements.length]; - - for (int i = 0; i < elements.length; i++) { - result[i] = t.apply(elements[i]); - } - - return result; - } -} diff --git a/solutions/src/main/java/pr2/lambda/mogrifier_2/test/StringTransmogrifierTest.java b/solutions/src/main/java/pr2/lambda/mogrifier_2/test/StringTransmogrifierTest.java deleted file mode 100644 index b842940..0000000 --- a/solutions/src/main/java/pr2/lambda/mogrifier_2/test/StringTransmogrifierTest.java +++ /dev/null @@ -1,43 +0,0 @@ -package pr2.lambda.mogrifier_2.test; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import pr2.lambda.mogrifier_2.StringFunction; -import pr2.lambda.mogrifier_2.StringTransmogrifier; - -import static org.junit.jupiter.api.Assertions.assertArrayEquals; - -public class StringTransmogrifierTest { - - static final String[] ELEMENTS = {"Hello", "World"}; - - @Test - void testMogrification() { - - - Assertions.assertArrayEquals(new String[] {"hello", "world"}, - StringTransmogrifier.transmogrify(ELEMENTS, - String::toLowerCase)); - - assertArrayEquals(new String[] {"HELLO", "WORLD"}, - StringTransmogrifier.transmogrify(ELEMENTS, - String::toUpperCase)); - - assertArrayEquals(new String[] {"Ifmmp", "Xpsme"}, - StringTransmogrifier.transmogrify(ELEMENTS, - s -> { - char[] c = s.toCharArray(); - for (int i = 0; i < c.length; i++) { - c[i] = (char) (c[i] + 1); - } - return new String(c); - })); - } - - @Test - void testCaesar() { - assertArrayEquals(new String[] {"Khoor", "Zruog"}, - StringTransmogrifier.transmogrify(ELEMENTS, - StringFunction.caesar(3))); - } -} diff --git a/solutions/src/main/java/pr2/lambda/nonstatic/Alien.java b/solutions/src/main/java/pr2/lambda/nonstatic/Alien.java deleted file mode 100644 index ca7ba90..0000000 --- a/solutions/src/main/java/pr2/lambda/nonstatic/Alien.java +++ /dev/null @@ -1,54 +0,0 @@ -package pr2.lambda.nonstatic; - -import de.smits_net.games.framework.board.Board; -import de.smits_net.games.framework.image.AnimatedImage; -import de.smits_net.games.framework.image.ImagePack; -import de.smits_net.games.framework.image.StripedImage; -import de.smits_net.games.framework.sprite.AnimatedSprite; -import de.smits_net.games.framework.sprite.Direction; - -import java.awt.Point; - -/** - * Ein Alien. - */ -public class Alien extends AnimatedSprite { - - /** - * Geschwindigkeit des Aliens X-Richtung. - */ - private static final int ALIEN_SPEED = 2; - - /** - * Neues Alien anlegen. - * - * @param board das Spielfeld - * @param startPoint Start-Position - */ - public Alien(Board board, Point startPoint) { - super(board, startPoint, BoundaryPolicy.JUMP_BACK, - new AnimatedImage(50, - new ImagePack("pr2/lambda/static_member", - "ship01", "ship02", "ship03"))); - velocity.setVelocity(Direction.WEST, ALIEN_SPEED); - } - - /** - * Alien explodieren lassen. - */ - public void explode() { - setActive(false); - setImages(new AnimatedImage(20, - new StripedImage("pr2/lambda/static_member/explosion_1.png", - 43))); - setInvisibleAfterFrames(70); - } - - /** - * Klick auf das Alien lässt es explodieren. - */ - @Override - public void mousePressed() { - explode(); - } -} diff --git a/solutions/src/main/java/pr2/lambda/nonstatic/GameBoard.java b/solutions/src/main/java/pr2/lambda/nonstatic/GameBoard.java deleted file mode 100644 index a8ce053..0000000 --- a/solutions/src/main/java/pr2/lambda/nonstatic/GameBoard.java +++ /dev/null @@ -1,108 +0,0 @@ -package pr2.lambda.nonstatic; - -import de.smits_net.games.framework.board.Board; -import de.smits_net.games.framework.image.AnimatedImage; -import de.smits_net.games.framework.image.ImagePack; -import de.smits_net.games.framework.image.StripedImage; -import de.smits_net.games.framework.sprite.AnimatedSprite; -import de.smits_net.games.framework.sprite.Direction; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Point; -import java.util.Random; - -/** - * Spielfeld. - */ -public class GameBoard extends Board { - - /** - * Alien, das durch das Bild läuft. - */ - private final Alien alien; - - /** - * Erzeugt ein neues Board. - */ - public GameBoard() { - // neues Spielfeld anlegen - super(10, new Dimension(800, 300), Color.BLACK); - - // Alien initialisieren - alien = new Alien(new Point(800, 50 + new Random().nextInt(100))); - - } - - /** - * Spielfeld neu zeichnen. Wird vom Framework aufgerufen. - */ - @Override - public void drawGame(Graphics g) { - // Alien zeichnen - alien.draw(g, this); - } - - /** - * Game-Over-Text anzeigen. Wird vom Framework aufgerufen. - */ - @Override - public void drawGameOver(Graphics g) { - centerText(g, "Das Spiel ist aus!"); - } - - /** - * Spielsituation updaten. Wird vom Framework aufgerufen. - */ - @Override - public boolean updateGame() { - alien.move(); - return alien.isVisible(); - } - - - /** - * Ein Alien. - */ - public class Alien extends AnimatedSprite { - - /** - * Geschwindigkeit des Alien X-Richtung. - */ - private static final int ALIEN_SPEED = 2; - - /** - * Neues Alien anlegen. - * - * @param startPoint Start-Position - */ - public Alien(Point startPoint) { - super(GameBoard.this, startPoint, BoundaryPolicy.JUMP_BACK, - new AnimatedImage(50, - new ImagePack("assets", "ship01", "ship02", - "ship03"))); - velocity.setVelocity(Direction.WEST, ALIEN_SPEED); - - GameBoard.this.addMouseListener(this); - } - - /** - * Alien explodieren lassen. - */ - public void explode() { - setActive(false); - setImages(new AnimatedImage(20, - new StripedImage("assets" + "/explosion_1.png", 43))); - setInvisibleAfterFrames(70); - } - - /** - * Klick auf das Alien lässt es explodieren. - */ - @Override - public void mousePressed() { - explode(); - } - } -} diff --git a/solutions/src/main/java/pr2/lambda/nonstatic/GameMain.java b/solutions/src/main/java/pr2/lambda/nonstatic/GameMain.java deleted file mode 100644 index d4a3d5a..0000000 --- a/solutions/src/main/java/pr2/lambda/nonstatic/GameMain.java +++ /dev/null @@ -1,27 +0,0 @@ -package pr2.lambda.nonstatic; - -import de.smits_net.games.framework.board.MainWindow; - -import java.awt.EventQueue; - -/** - * Hauptklasse des Spiels. - */ -public class GameMain extends MainWindow { - - /** - * Neues Spiel anlegen. - */ - public GameMain() { - super("Click Alien - (02) Nonstatic Member", new GameBoard()); - } - - /** - * Startpunkt. - * - * @param args command line arguments. - */ - public static void main(String[] args) { - EventQueue.invokeLater(GameMain::new); - } -} diff --git a/solutions/src/main/java/pr2/lambda/static_member/Alien.java b/solutions/src/main/java/pr2/lambda/static_member/Alien.java deleted file mode 100644 index 21722ee..0000000 --- a/solutions/src/main/java/pr2/lambda/static_member/Alien.java +++ /dev/null @@ -1,54 +0,0 @@ -package pr2.lambda.static_member; - -import de.smits_net.games.framework.board.Board; -import de.smits_net.games.framework.image.AnimatedImage; -import de.smits_net.games.framework.image.ImagePack; -import de.smits_net.games.framework.image.StripedImage; -import de.smits_net.games.framework.sprite.AnimatedSprite; -import de.smits_net.games.framework.sprite.Direction; - -import java.awt.Point; - -/** - * Ein Alien. - */ -public class Alien extends AnimatedSprite { - - /** - * Geschwindigkeit des Aliens X-Richtung. - */ - private static final int ALIEN_SPEED = 2; - - /** - * Neues Alien anlegen. - * - * @param board das Spielfeld - * @param startPoint Start-Position - */ - public Alien(Board board, Point startPoint) { - super(board, startPoint, BoundaryPolicy.JUMP_BACK, - new AnimatedImage(50, - new ImagePack("pr2/lambda/static_member", - "ship01", "ship02", "ship03"))); - velocity.setVelocity(Direction.WEST, ALIEN_SPEED); - } - - /** - * Alien explodieren lassen. - */ - public void explode() { - setActive(false); - setImages(new AnimatedImage(20, - new StripedImage("pr2/lambda/static_member/explosion_1.png", - 43))); - setInvisibleAfterFrames(70); - } - - /** - * Klick auf das Alien lässt es explodieren. - */ - @Override - public void mousePressed() { - explode(); - } -} diff --git a/solutions/src/main/java/pr2/lambda/static_member/GameBoard.java b/solutions/src/main/java/pr2/lambda/static_member/GameBoard.java deleted file mode 100644 index c1985ff..0000000 --- a/solutions/src/main/java/pr2/lambda/static_member/GameBoard.java +++ /dev/null @@ -1,111 +0,0 @@ -package pr2.lambda.static_member; - -import de.smits_net.games.framework.board.Board; -import de.smits_net.games.framework.image.AnimatedImage; -import de.smits_net.games.framework.image.ImagePack; -import de.smits_net.games.framework.image.StripedImage; -import de.smits_net.games.framework.sprite.AnimatedSprite; -import de.smits_net.games.framework.sprite.Direction; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Point; -import java.util.Random; - -/** - * Spielfeld. - */ -public class GameBoard extends Board { - - /** - * Alien, das durch das Bild läuft. - */ - private final Alien alien; - - /** - * Erzeugt ein neues Board. - */ - public GameBoard() { - // neues Spielfeld anlegen - super(10, new Dimension(800, 300), Color.BLACK); - - // Alien initialisieren - alien = new Alien(this, - new Point(800, 50 + new Random().nextInt(100))); - - // Alien soll auf Maus-Klicks reagieren - addMouseListener(alien); - } - - /** - * Spielfeld neu zeichnen. Wird vom Framework aufgerufen. - */ - @Override - public void drawGame(Graphics g) { - // Alien zeichnen - alien.draw(g, this); - } - - /** - * Game-Over-Text anzeigen. Wird vom Framework aufgerufen. - */ - @Override - public void drawGameOver(Graphics g) { - centerText(g, "Das Spiel ist aus!"); - } - - /** - * Spielsituation updaten. Wird vom Framework aufgerufen. - */ - @Override - public boolean updateGame() { - alien.move(); - return alien.isVisible(); - } - - - /** - * Ein Alien. - */ - public static class Alien extends AnimatedSprite { - - /** - * Geschwindigkeit des Aliens X-Richtung. - */ - private static final int ALIEN_SPEED = 2; - - /** - * Neues Alien anlegen. - * - * @param board das Spielfeld - * @param startPoint Start-Position - */ - public Alien(Board board, Point startPoint) { - super(board, startPoint, BoundaryPolicy.JUMP_BACK, - new AnimatedImage(50, - new ImagePack("pr2/lambda/static_member", - "ship01", "ship02", "ship03"))); - velocity.setVelocity(Direction.WEST, ALIEN_SPEED); - } - - /** - * Alien explodieren lassen. - */ - public void explode() { - setActive(false); - setImages(new AnimatedImage(20, - new StripedImage("pr2/lambda/static_member" - + "/explosion_1.png", 43))); - setInvisibleAfterFrames(70); - } - - /** - * Klick auf das Alien lässt es explodieren. - */ - @Override - public void mousePressed() { - explode(); - } - } -} diff --git a/solutions/src/main/java/pr2/lambda/static_member/GameMain.java b/solutions/src/main/java/pr2/lambda/static_member/GameMain.java deleted file mode 100644 index 1011145..0000000 --- a/solutions/src/main/java/pr2/lambda/static_member/GameMain.java +++ /dev/null @@ -1,27 +0,0 @@ -package pr2.lambda.static_member; - -import de.smits_net.games.framework.board.MainWindow; - -import java.awt.EventQueue; - -/** - * Hauptklasse des Spiels. - */ -public class GameMain extends MainWindow { - - /** - * Neues Spiel anlegen. - */ - public GameMain() { - super("Click Alien - (01) Static Member", new GameBoard()); - } - - /** - * Startpunkt. - * - * @param args command line arguments. - */ - public static void main(String[] args) { - EventQueue.invokeLater(GameMain::new); - } -} diff --git a/solutions/src/main/java/pr2/object/clone_alien/Alien.java b/solutions/src/main/java/pr2/object/clone_alien/Alien.java deleted file mode 100644 index b993a4a..0000000 --- a/solutions/src/main/java/pr2/object/clone_alien/Alien.java +++ /dev/null @@ -1,100 +0,0 @@ -package pr2.object.clone_alien; - -/** - * Ein Alien. - */ -public class Alien implements Cloneable { - - /** - * Name des Aliens. - */ - private final String name; - - /** - * Raumanzug des Aliens. - */ - private Raumanzug raumanzug; - - /** - * Erzeugt ein neues Alien. - * - * @param name Name des Aliens. - * @param raumanzug Anzug. - */ - public Alien(String name, Raumanzug raumanzug) { - this.name = name; - this.raumanzug = raumanzug; - } - - /** - * Gibt den Namen des Aliens zurück. - * - * @return Name des Aliens. - */ - public String getName() { - return name; - } - - /** - * Gibt den Anzug zurück. - * - * @return der Anzug. - */ - public Raumanzug getAnzug() { - return raumanzug; - } - - /** - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((raumanzug - == null) ? 0 : raumanzug.hashCode()); - return result; - } - - /** - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Alien other = (Alien) obj; - if (name == null) { - if (other.name != null) { - return false; - } - } - else if (!name.equals(other.name)) { - return false; - } - if (raumanzug == null) { - return other.raumanzug == null; - } - else { - return raumanzug.equals(other.raumanzug); - } - } - - /** - * @see java.lang.Object#clone() - */ - @Override - public Object clone() throws CloneNotSupportedException { - Alien o = (Alien) super.clone(); - o.raumanzug = (Raumanzug) raumanzug.clone(); - return o; - } -} diff --git a/solutions/src/main/java/pr2/object/clone_alien/Raumanzug.java b/solutions/src/main/java/pr2/object/clone_alien/Raumanzug.java deleted file mode 100644 index ae4171e..0000000 --- a/solutions/src/main/java/pr2/object/clone_alien/Raumanzug.java +++ /dev/null @@ -1,75 +0,0 @@ -package pr2.object.clone_alien; - -/** - * Ein Raumanzug. - */ -public class Raumanzug implements Cloneable { - - /** - * Sauerstoffvorrat, der noch im Raumanzug ist. - */ - private double sauerstoffVorrat; - - /** - * Ertzeugt einen neuen Raumanzug. - */ - public Raumanzug() { - sauerstoffVorrat = Math.random(); - } - - /** - * Sauerstoffvorrat im Anzug. - * - * @return Vorrat in % (0.0-1.0) - */ - public double getSauerstoffVorrat() { - return sauerstoffVorrat; - } - - /** - * Tankt den Anzug auf. - */ - public void auftanken() { - sauerstoffVorrat = 1.0; - } - - /** - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - long temp; - temp = Double.doubleToLongBits(sauerstoffVorrat); - result = prime * result + (int) (temp ^ (temp >>> 32)); - return result; - } - - /** - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Raumanzug other = (Raumanzug) obj; - return Double.doubleToLongBits(sauerstoffVorrat) - == Double.doubleToLongBits(other.sauerstoffVorrat); - } - - /** - * @see java.lang.Object#clone() - */ - @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } -} diff --git a/solutions/src/main/java/pr2/object/clone_alien/test/AlienCloneTest.java b/solutions/src/main/java/pr2/object/clone_alien/test/AlienCloneTest.java deleted file mode 100644 index 4248732..0000000 --- a/solutions/src/main/java/pr2/object/clone_alien/test/AlienCloneTest.java +++ /dev/null @@ -1,37 +0,0 @@ -package pr2.object.clone_alien.test; - -import org.junit.jupiter.api.Test; -import pr2.object.clone_alien.Alien; -import pr2.object.clone_alien.Raumanzug; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotSame; - -/** - * Test für die Clone-Methoden. - */ -public class AlienCloneTest { - - /** - * Test-Methode. - * - * @throws CloneNotSupportedException wird geworfen, wenn clone_alien - * nicht korrekt implementiert wurde. - */ - @Test - void testClone() throws CloneNotSupportedException { - Raumanzug r1 = new Raumanzug(); - Alien a1 = new Alien("Predator", r1); - - Alien a2 = (Alien) a1.clone(); - Raumanzug r2 = a2.getAnzug(); - - assertNotSame(a1, a2); - assertNotSame(r1, r2); - - assertEquals(a1, a2); - assertEquals(r1, r2); - assertEquals(r1.getSauerstoffVorrat(), r2.getSauerstoffVorrat(), - 0.0001); - } -} diff --git a/solutions/src/main/java/pr2/object/clone_person/Person.java b/solutions/src/main/java/pr2/object/clone_person/Person.java deleted file mode 100644 index 8f69899..0000000 --- a/solutions/src/main/java/pr2/object/clone_person/Person.java +++ /dev/null @@ -1,34 +0,0 @@ -package pr2.object.clone_person; - -import java.util.Date; - -public class Person implements Cloneable { - - private final String vorname = ""; - private final String nachname = ""; - private Date geburtsdatum = new Date(); - - @Override - public Object clone() { - Person clone; - try { - clone = (Person) super.clone(); - clone.geburtsdatum = (Date) geburtsdatum.clone(); - return clone; - } - catch (CloneNotSupportedException e) { - // cannot happen - return null; - } - } - - - @Override - public String toString() { - return "Person{" - + "vorname='" + vorname + '\'' - + ", nachname='" + nachname + '\'' - + ", geburtsdatum=" + geburtsdatum - + '}'; - } -} diff --git a/solutions/src/main/java/pr2/object/equals_hashcode/Ork.java b/solutions/src/main/java/pr2/object/equals_hashcode/Ork.java deleted file mode 100644 index abae1a9..0000000 --- a/solutions/src/main/java/pr2/object/equals_hashcode/Ork.java +++ /dev/null @@ -1,57 +0,0 @@ -package pr2.object.equals_hashcode; - -/** - * Ork. - */ -public class Ork extends Wesen { - - /** - * Stärke der Orks. - */ - private static final int ORK_STAERKE = 17; - - /** - * Zeigt an, ob der Ork gut oder böse ist. - */ - private final boolean boese; - - /** - * Legt einen neuen Ork an. - * - * @param name Name des Orks. - * @param boese zeigt an, ob der Ork gut oder böse ist - */ - public Ork(String name, boolean boese) { - super(name, ORK_STAERKE); - this.boese = boese; - } - - /** - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + (boese ? 1231 : 1237); - return result; - } - - /** - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Ork other = (Ork) obj; - return boese == other.boese; - } -} diff --git a/solutions/src/main/java/pr2/object/equals_hashcode/Wesen.java b/solutions/src/main/java/pr2/object/equals_hashcode/Wesen.java deleted file mode 100644 index 424641c..0000000 --- a/solutions/src/main/java/pr2/object/equals_hashcode/Wesen.java +++ /dev/null @@ -1,66 +0,0 @@ -package pr2.object.equals_hashcode; - -/** - * Ein Wesen in der Spielwelt. - */ -public class Wesen { - - /** - * Name des Wesens. - */ - private final String name; - - /** - * Stärke des Wesens. - */ - private final int staerke; - - /** - * Legt ein neues Wesen an. - * - * @param name Name des Wesens. - * @param staerke Stärke des Wesens. - */ - public Wesen(String name, int staerke) { - this.name = name; - this.staerke = staerke; - } - - /** - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + staerke; - return result; - } - - /** - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Wesen other = (Wesen) obj; - if (name == null) { - if (other.name != null) { - return false; - } - } - else if (!name.equals(other.name)) { - return false; - } - return staerke == other.staerke; - } -} diff --git a/solutions/src/main/java/pr2/object/equals_hashcode/test/WesenTest.java b/solutions/src/main/java/pr2/object/equals_hashcode/test/WesenTest.java deleted file mode 100644 index bdbe397..0000000 --- a/solutions/src/main/java/pr2/object/equals_hashcode/test/WesenTest.java +++ /dev/null @@ -1,87 +0,0 @@ -package pr2.object.equals_hashcode.test; - -import org.junit.jupiter.api.Test; -import pr2.object.equals_hashcode.Ork; -import pr2.object.equals_hashcode.Wesen; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertNotSame; - -/** - * Testklasse für die Wesen. - */ -public class WesenTest { - - /** - * Testet equals und hashCode von Wesen. - */ - @Test - void testWesen() { - Wesen w1 = new Wesen("Azok", 30); - Wesen w2 = new Wesen("Azok", 30); - Wesen w3 = new Wesen("Azok", 31); - Wesen w4 = new Wesen("Gorrok", 30); - Wesen w5 = new Wesen("Gorrok", 31); - - assertNotSame(w1, w2); - assertEquals(w1, w2); - - assertNotSame(w1, w3); - assertNotEquals(w1, w3); - - assertNotSame(w1, w4); - assertNotEquals(w1, w4); - - assertNotSame(w1, w5); - assertNotEquals(w1, w5); - - assertEquals(w1.hashCode(), w2.hashCode()); - } - - /** - * Testet equals und hashCode von Ork. - */ - @Test - void testOrk() { - Ork o1 = new Ork("Snagas", true); - Ork o2 = new Ork("Snagas", true); - Ork o3 = new Ork("Snagas", false); - Ork o4 = new Ork("Berg-Ork", false); - Ork o5 = new Ork("Berg-Ork", true); - Ork o6 = new Ork("Berg-Ork", false); - Wesen w = new Wesen("Snagas", 17); - - assertNotSame(o1, o2); - assertEquals(o1, o2); - - assertNotSame(o1, o3); - assertNotEquals(o1, o3); - - assertNotSame(o1, o4); - assertNotEquals(o1, o4); - - assertNotSame(o1, o5); - assertNotEquals(o1, o5); - - assertEquals(o1.hashCode(), o2.hashCode()); - assertEquals(o4.hashCode(), o6.hashCode()); - - assertNotEquals(w, o1); - assertNotEquals(w, o2); - assertNotEquals(w, o3); - assertNotEquals(null, o1); - assertNotEquals("Hugo", o1); - assertEquals(o1, o1); - - // Diese Tests muss nicht zwangsweise funktionieren, da - // ungleiche Objekte einen identischen Hashcode haben können. - // Wir gehen hier aber davon aus, dass eine Hashkollision - // sehr selten ist und machen daher aus didaktischen Gründen - // diesen Test. - assertNotEquals(o1.hashCode(), o3.hashCode()); - assertNotEquals(o1.hashCode(), o4.hashCode()); - assertNotEquals(o1.hashCode(), o5.hashCode()); - assertNotEquals(o4.hashCode(), o5.hashCode()); - } -} diff --git a/solutions/src/main/java/pr2/object/equals_person/Person.java b/solutions/src/main/java/pr2/object/equals_person/Person.java deleted file mode 100644 index b45948d..0000000 --- a/solutions/src/main/java/pr2/object/equals_person/Person.java +++ /dev/null @@ -1,54 +0,0 @@ -package pr2.object.equals_person; - -public class Person { - - private String vorname; - private String nachname; - private int alter; - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + alter; - result = prime * result - + ((nachname == null) ? 0 : nachname.hashCode()); - result = prime * result - + ((vorname == null) ? 0 : vorname.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (this == obj) { - return true; - } - if (getClass() != obj.getClass()) { - return false; - } - - Person other = (Person) obj; - - if (alter != other.alter) { - return false; - } - - if (nachname == null) { - if (other.nachname != null) { - return false; - } - } - else if (!nachname.equals(other.nachname)) { - return false; - } - if (vorname == null) { - return other.vorname == null; - } - else { - return vorname.equals(other.vorname); - } - } -} diff --git a/solutions/src/main/java/pr2/object/tostring/Alien.java b/solutions/src/main/java/pr2/object/tostring/Alien.java deleted file mode 100644 index 0a18c04..0000000 --- a/solutions/src/main/java/pr2/object/tostring/Alien.java +++ /dev/null @@ -1,56 +0,0 @@ -package pr2.object.tostring; - -/** - * Ein Alien. - */ -public class Alien implements Cloneable { - - /** - * Name des Aliens. - */ - private final String name; - - /** - * Raumanzug des Aliens. - */ - private final Raumanzug raumanzug; - - /** - * Erzeugt ein neues Alien. - * - * @param name Name des Aliens. - * @param raumanzug Anzug. - */ - public Alien(String name, Raumanzug raumanzug) { - this.name = name; - this.raumanzug = raumanzug; - } - - /** - * Gibt den Namen des Aliens zurück. - * - * @return Name des Aliens. - */ - public String getName() { - return name; - } - - /** - * Gibt den Anzug zurück. - * - * @return der Anzug. - */ - public Raumanzug getAnzug() { - return raumanzug; - } - - /** - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return String.format( - "Ich bin ein Alien und heiße '%s'. Ich trage " + "einen %s.", - name, raumanzug); - } -} diff --git a/solutions/src/main/java/pr2/object/tostring/Ausgabe.java b/solutions/src/main/java/pr2/object/tostring/Ausgabe.java deleted file mode 100644 index 637f3c6..0000000 --- a/solutions/src/main/java/pr2/object/tostring/Ausgabe.java +++ /dev/null @@ -1,24 +0,0 @@ -package pr2.object.tostring; - -/** - * Ausgabe. - */ -public final class Ausgabe { - - /** - * Konstruktor. - */ - private Ausgabe() { - // keine Objekte. - } - - /** - * Einstiegspunkt in das Programm. - * - * @param args Kommandozeilenargumente. - */ - public static void main(String[] args) { - Alien alien = new Alien("E.T.", new Raumanzug("Spaceman 2000")); - System.out.println(alien); - } -} diff --git a/solutions/src/main/java/pr2/object/tostring/Raumanzug.java b/solutions/src/main/java/pr2/object/tostring/Raumanzug.java deleted file mode 100644 index 795e95e..0000000 --- a/solutions/src/main/java/pr2/object/tostring/Raumanzug.java +++ /dev/null @@ -1,52 +0,0 @@ -package pr2.object.tostring; - -/** - * Ein Raumanzug. - */ -public class Raumanzug implements Cloneable { - - /** - * Hersteller des Raumanzuges. - */ - private final String hersteller; - - /** - * Sauerstoffvorrat, der noch im Raumanzug ist. - */ - private double sauerstoffVorrat; - - /** - * Ertzeugt einen neuen Raumanzug. - * - * @param hersteller Hersteller des Anzuges. - */ - public Raumanzug(String hersteller) { - this.hersteller = hersteller; - sauerstoffVorrat = Math.random(); - } - - /** - * Sauerstoffvorrat im Anzug. - * - * @return Vorrat in % (0.0-1.0) - */ - public double getSauerstoffVorrat() { - return sauerstoffVorrat; - } - - /** - * Tankt den Anzug auf. - */ - public void auftanken() { - sauerstoffVorrat = 1.0; - } - - /** - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return String.format("Raumanzug von %s (Füllstand %d%%)", hersteller, - (int) (sauerstoffVorrat * 100)); - } -} diff --git a/solutions/src/main/java/pr2/object/wrapper_boxsearch/BoxSearcher.java b/solutions/src/main/java/pr2/object/wrapper_boxsearch/BoxSearcher.java deleted file mode 100644 index 7370cda..0000000 --- a/solutions/src/main/java/pr2/object/wrapper_boxsearch/BoxSearcher.java +++ /dev/null @@ -1,18 +0,0 @@ -package pr2.object.wrapper_boxsearch; - -public class BoxSearcher { - - public static void main(String[] args) { - Integer[] array = new Integer[200]; - - for (int i = 0; i < array.length; i++) { - array[i] = i; - } - - for (Integer element : array) { - boolean identisch = (element == Integer.valueOf( - element.intValue())); - System.out.printf("%d: %s%n", element, identisch); - } - } -} diff --git a/solutions/src/main/java/pr2/object/wrapper_umwandler/Umwandler.java b/solutions/src/main/java/pr2/object/wrapper_umwandler/Umwandler.java deleted file mode 100644 index 53090d4..0000000 --- a/solutions/src/main/java/pr2/object/wrapper_umwandler/Umwandler.java +++ /dev/null @@ -1,47 +0,0 @@ -package pr2.object.wrapper_umwandler; - -/** - * Enthält Methoden, um Integer-Zahlen umzuwandeln. - */ -public final class Umwandler { - - /** - * Konstruktor. - */ - private Umwandler() { - // keine Instanzen - } - - /** - * Wandelt eine Zahl in meherer Formate um. - * - * @param i die Zahl. - * @return String mit mehreren Formaten. - */ - public static String toString(int i) { - return "Dezimal: " + i + "\n" + "Hex : " + Integer.toHexString(i) - + "\n" + "Oktal : " + Integer.toOctalString(i) + "\n" - + "Binär : " + Integer.toBinaryString(i); - } - - /** - * Wandelt einen String (zur Basis 10) in eine Zahl um. - * - * @param s String, der umgewandelt werden soll - * @return Umgewandelte Zahl - */ - public static int fromString(String s) { - return Integer.parseInt(s); - } - - /** - * Einstiegspunkt in das Programm. - * - * @param args Kommandozeilenargumente. - */ - public static void main(String[] args) { - String s = "17871"; - int i = fromString(s); - System.out.println(toString(i)); - } -} diff --git a/solutions/src/main/java/pr2/strukturierung/information_hiding/Rechner.java b/solutions/src/main/java/pr2/strukturierung/information_hiding/Rechner.java deleted file mode 100644 index b85b71d..0000000 --- a/solutions/src/main/java/pr2/strukturierung/information_hiding/Rechner.java +++ /dev/null @@ -1,6 +0,0 @@ -package pr2.strukturierung.information_hiding; - -/** - * Ein einfacher Taschenrechner. - */ -public class Rechner { diff --git a/solutions/src/main/java/pr2/strukturierung/information_hiding/test/RechnerTest.java b/solutions/src/main/java/pr2/strukturierung/information_hiding/test/RechnerTest.java deleted file mode 100644 index 264712f..0000000 --- a/solutions/src/main/java/pr2/strukturierung/information_hiding/test/RechnerTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package pr2.strukturierung.information_hiding.test; - -import org.junit.jupiter.api.Test; -import pr2.strukturierung.information_hiding.Rechner; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * Unit-Test für den Rechner. - */ -public class RechnerTest { - - /** - * Testet alle Grundoperationen des Rechners. - */ - @Test - void testRechner() { - Rechner r = new Rechner(); - - // 2 + 2 = 4 - assertEquals(4.0, r.addiere(2.0, 2.0), 0.0001); - - // 3 - 1 = 2 - assertEquals(2.0, r.subtrahiere(3, 1), 0.0001); - - // 3 * 3 = 9 - assertEquals(9.0, r.multipliziere(3, 3), 0.0001); - - // 2 + 2 * 2 = 6 - r.setSpeicher(r.multipliziere(2, 2)); - assertEquals(6.0, r.addiere(2, r.getSpeicher()), 0.0001); -// // 2 + 2 = 4 -// r.addiere(2.0, 2.0); -// assertEquals(4.0, r.wert, 0.0001); -// -// // 3 - 1 = 2 -// r.subtrahiere(3, 1); -// assertEquals(2.0, r.wert, 0.0001); -// -// // 3 * 3 = 9 -// r.multipliziere(3, 3); -// assertEquals(9.0, r.wert, 0.0001); -// -// // 2 + 2 * 2 = 6 -// r.multipliziere(2, 2); -// r.speichern(); -// r.addiere(2, r.speicher); -// assertEquals(6.0, r.wert, 0.0001); - } -} diff --git a/solutions/src/main/java/pr2/vererbung/finals/A.java b/solutions/src/main/java/pr2/vererbung/finals/A.java deleted file mode 100644 index c698cd3..0000000 --- a/solutions/src/main/java/pr2/vererbung/finals/A.java +++ /dev/null @@ -1,32 +0,0 @@ -package pr2.vererbung.finals; - -/** - * A-Klasse. - */ -public class A { - - /** - * Konstante für die Vorzeichenumkehr. - */ - public static final int KONSTANTE = 100; - - /** - * Addiert zwei Zahlen. Wenn das Ergebnis größer ist als - * der Wert von KONSTANTE, dann wird das - * Vorzeichen umgekehrt. - * - * @param a erster Wert - * @param b zweiter Wert - * @return Ergebnis - */ - public final int add(final int a, final int b) { - final int result = a + b; - - if (result > KONSTANTE) { - return result * -1; - } - else { - return result; - } - } -} diff --git a/solutions/src/main/java/pr2/vererbung/finals/B.java b/solutions/src/main/java/pr2/vererbung/finals/B.java deleted file mode 100644 index 4abf03b..0000000 --- a/solutions/src/main/java/pr2/vererbung/finals/B.java +++ /dev/null @@ -1,22 +0,0 @@ -package pr2.vererbung.finals; - -/** - * B-Klasse. - */ -public final class B extends A { - - /** - * Subtrahiert zwei Zahlen. Wenn das Ergebnis kleiner ist als - * der Wert von KONSTANTE, dann wird das - * Vorzeichen umgekehrt. - * - * @param a erster Wert - * @param b zweiter Wert - * @return Ergebnis - */ - public static int sub(final int a, final int b) { - final int result = a + b; - - return (result < KONSTANTE) ? (result * -1) : (result); - } -} diff --git a/solutions/src/main/java/pr2/vererbung/geometrie1/Figur.java b/solutions/src/main/java/pr2/vererbung/geometrie1/Figur.java deleted file mode 100644 index 193626a..0000000 --- a/solutions/src/main/java/pr2/vererbung/geometrie1/Figur.java +++ /dev/null @@ -1,14 +0,0 @@ -package pr2.vererbung.geometrie1; - -public class Figur { - - protected int flaeche; - - protected Figur() { - /* nichts zu tun */ - } - - public int getFlaeche() { - return flaeche; - } -} diff --git a/solutions/src/main/java/pr2/vererbung/geometrie1/Main.java b/solutions/src/main/java/pr2/vererbung/geometrie1/Main.java deleted file mode 100644 index 803774b..0000000 --- a/solutions/src/main/java/pr2/vererbung/geometrie1/Main.java +++ /dev/null @@ -1,12 +0,0 @@ -package pr2.vererbung.geometrie1; - -public class Main { - - public static void main(String[] args) { - Figur f1 = new Rechteck(10, 10); - Figur f2 = new Rechteck(5, 10); - - System.out.println(f1.getFlaeche()); - System.out.println(f2.getFlaeche()); - } -} diff --git a/solutions/src/main/java/pr2/vererbung/geometrie1/Rechteck.java b/solutions/src/main/java/pr2/vererbung/geometrie1/Rechteck.java deleted file mode 100644 index b86cbaf..0000000 --- a/solutions/src/main/java/pr2/vererbung/geometrie1/Rechteck.java +++ /dev/null @@ -1,8 +0,0 @@ -package pr2.vererbung.geometrie1; - -public class Rechteck extends Figur { - - public Rechteck(int breite, int hoehe) { - flaeche = breite * hoehe; - } -} diff --git a/solutions/src/main/java/pr2/vererbung/geometrie2/Figur.java b/solutions/src/main/java/pr2/vererbung/geometrie2/Figur.java deleted file mode 100644 index 395ecc7..0000000 --- a/solutions/src/main/java/pr2/vererbung/geometrie2/Figur.java +++ /dev/null @@ -1,14 +0,0 @@ -package pr2.vererbung.geometrie2; - -public class Figur { - - private final int flaeche; - - protected Figur(int flaeche) { - this.flaeche = flaeche; - } - - public int getFlaeche() { - return flaeche; - } -} diff --git a/solutions/src/main/java/pr2/vererbung/geometrie2/Main.java b/solutions/src/main/java/pr2/vererbung/geometrie2/Main.java deleted file mode 100644 index bf3ee32..0000000 --- a/solutions/src/main/java/pr2/vererbung/geometrie2/Main.java +++ /dev/null @@ -1,12 +0,0 @@ -package pr2.vererbung.geometrie2; - -public class Main { - - public static void main(String[] args) { - Figur f1 = new Rechteck(10, 10); - Figur f2 = new Rechteck(5, 10); - - System.out.println(f1.getFlaeche()); - System.out.println(f2.getFlaeche()); - } -} diff --git a/solutions/src/main/java/pr2/vererbung/geometrie2/Rechteck.java b/solutions/src/main/java/pr2/vererbung/geometrie2/Rechteck.java deleted file mode 100644 index cb1dba6..0000000 --- a/solutions/src/main/java/pr2/vererbung/geometrie2/Rechteck.java +++ /dev/null @@ -1,9 +0,0 @@ -package pr2.vererbung.geometrie2; - - -public class Rechteck extends Figur { - - public Rechteck(int breite, int hoehe) { - super(breite * hoehe); - } -} diff --git a/solutions/src/main/java/pr2/vererbung/geometrie3/Dreieck.java b/solutions/src/main/java/pr2/vererbung/geometrie3/Dreieck.java deleted file mode 100644 index 9a1a5bf..0000000 --- a/solutions/src/main/java/pr2/vererbung/geometrie3/Dreieck.java +++ /dev/null @@ -1,8 +0,0 @@ -package pr2.vererbung.geometrie3; - -public class Dreieck extends Figur { - - public Dreieck(int grundseite, int hoehe) { - super(grundseite * hoehe / 2); - } -} diff --git a/solutions/src/main/java/pr2/vererbung/geometrie3/Figur.java b/solutions/src/main/java/pr2/vererbung/geometrie3/Figur.java deleted file mode 100644 index 71df9f6..0000000 --- a/solutions/src/main/java/pr2/vererbung/geometrie3/Figur.java +++ /dev/null @@ -1,18 +0,0 @@ -package pr2.vererbung.geometrie3; - -public class Figur { - - private int flaeche; - - protected Figur() { - /* leer */ - } - - protected Figur(int flaeche) { - this.flaeche = flaeche; - } - - public int getFlaeche() { - return flaeche; - } -} diff --git a/solutions/src/main/java/pr2/vererbung/geometrie3/Gerade.java b/solutions/src/main/java/pr2/vererbung/geometrie3/Gerade.java deleted file mode 100644 index 58f2461..0000000 --- a/solutions/src/main/java/pr2/vererbung/geometrie3/Gerade.java +++ /dev/null @@ -1,17 +0,0 @@ -package pr2.vererbung.geometrie3; - -public class Gerade extends Figur { - - private final int laenge; - - public Gerade(int laenge) { - this.laenge = laenge; - } - - @Override - public String toString() { - return "Gerade{" - + "laenge=" + laenge - + '}'; - } -} diff --git a/solutions/src/main/java/pr2/vererbung/geometrie3/Main.java b/solutions/src/main/java/pr2/vererbung/geometrie3/Main.java deleted file mode 100644 index ef073b9..0000000 --- a/solutions/src/main/java/pr2/vererbung/geometrie3/Main.java +++ /dev/null @@ -1,12 +0,0 @@ -package pr2.vererbung.geometrie3; - -public class Main { - - public static void main(String[] args) { - Figur f1 = new Gerade(10); - Figur f2 = new Gerade(5); - - System.out.println(f1.getFlaeche()); - System.out.println(f2.getFlaeche()); - } -} diff --git a/solutions/src/main/java/pr2/vererbung/geometrie3/Quadrat.java b/solutions/src/main/java/pr2/vererbung/geometrie3/Quadrat.java deleted file mode 100644 index bc20fa0..0000000 --- a/solutions/src/main/java/pr2/vererbung/geometrie3/Quadrat.java +++ /dev/null @@ -1,8 +0,0 @@ -package pr2.vererbung.geometrie3; - -public class Quadrat extends Rechteck { - - public Quadrat(int seitenlaenge) { - super(seitenlaenge, seitenlaenge); - } -} diff --git a/solutions/src/main/java/pr2/vererbung/geometrie3/Rechteck.java b/solutions/src/main/java/pr2/vererbung/geometrie3/Rechteck.java deleted file mode 100644 index dbb593e..0000000 --- a/solutions/src/main/java/pr2/vererbung/geometrie3/Rechteck.java +++ /dev/null @@ -1,9 +0,0 @@ -package pr2.vererbung.geometrie3; - - -public class Rechteck extends Figur { - - public Rechteck(int breite, int hoehe) { - super(breite * hoehe); - } -} diff --git a/solutions/src/main/java/pr2/vererbung/konstruktoren/Nachtelf.java b/solutions/src/main/java/pr2/vererbung/konstruktoren/Nachtelf.java deleted file mode 100644 index 852640b..0000000 --- a/solutions/src/main/java/pr2/vererbung/konstruktoren/Nachtelf.java +++ /dev/null @@ -1,47 +0,0 @@ -package pr2.vererbung.konstruktoren; - -/** - * Nachtelf aus der Allianz. - */ -public class Nachtelf extends Wesen { - - /** - * Standardmäßige Stärke der Fähigkeit Naturwiderstand. - */ - public static final int STANDARD_NATURWIDERSTAND = 5; - - /** - * Fähigkeit zum Widerstand gegen Naturmagie. - */ - private int naturwiderstand; - - /** - * Legt einen neuen Nachtelf an. - * - * @param name Name der Figur. - * @param naturwiderstand Stärke der Fähigkeit Naturwiderstand. - */ - public Nachtelf(String name, int naturwiderstand) { - super(name); - this.naturwiderstand = naturwiderstand; - } - - /** - * Legt einen neuen Nachtelf an. Die Stärke des Naturwiderstandes entspricht - * dem Standardwert. - * - * @param name Name der Figur. - */ - public Nachtelf(String name) { - this(name, STANDARD_NATURWIDERSTAND); - } - - /** - * Stärke des Naturwiderstandes. - * - * @return the naturwiderstand - */ - public int getNaturwiderstand() { - return naturwiderstand; - } -} diff --git a/solutions/src/main/java/pr2/vererbung/konstruktoren/Untoter.java b/solutions/src/main/java/pr2/vererbung/konstruktoren/Untoter.java deleted file mode 100644 index 7505875..0000000 --- a/solutions/src/main/java/pr2/vererbung/konstruktoren/Untoter.java +++ /dev/null @@ -1,47 +0,0 @@ -package pr2.vererbung.konstruktoren; - -/** - * Untoter aus der Horde. - */ -public class Untoter extends Wesen { - - /** - * Standardmäßige Stärke der Fähigkeit zur Unterwasseratmung. - */ - public static final int STANDARD_UNTERWASSERATMUNG = 10; - - /** - * Fähigkeit zur Atmung unter Wasser. - */ - private int unterwasseratmung; - - /** - * Legt einen neuen Untoten an. - * - * @param name Name der Figur. - * @param unterwasseratmung Stärke der Fähigkeit zur Unterwasseratmung. - */ - public Untoter(String name, int unterwasseratmung) { - super(name); - this.unterwasseratmung = unterwasseratmung; - } - - /** - * Legt einen neuen Untoten an. Die Stärke der Unterwasseratmung entspricht - * dem Standardwert. - * - * @param name Name der Figur. - */ - public Untoter(String name) { - this(name, STANDARD_UNTERWASSERATMUNG); - } - - /** - * Fähigkeit zur Unterwasseratmnung. - * - * @return the Stärke der Fähigkeit. - */ - public int getUnterwasseratmung() { - return unterwasseratmung; - } -} diff --git a/solutions/src/main/java/pr2/vererbung/konstruktoren/Wesen.java b/solutions/src/main/java/pr2/vererbung/konstruktoren/Wesen.java deleted file mode 100644 index 0287b62..0000000 --- a/solutions/src/main/java/pr2/vererbung/konstruktoren/Wesen.java +++ /dev/null @@ -1,30 +0,0 @@ -package pr2.vererbung.konstruktoren; - -/** - * Basisklasse für Spielfiguren. - */ -public class Wesen { - - /** - * Name der Spielfigur. - */ - private final String name; - - /** - * Legt eine neue Spielfigur an. - * - * @param name Name der Figur. - */ - public Wesen(String name) { - this.name = name; - } - - /** - * Gibt den Namen der Spielfigur zurück. - * - * @return Name der Spielfigur. - */ - public String getName() { - return name; - } -} diff --git a/solutions/src/main/java/pr2/vererbung/konstruktoren/test/WesenTest.java b/solutions/src/main/java/pr2/vererbung/konstruktoren/test/WesenTest.java deleted file mode 100644 index 3587cf9..0000000 --- a/solutions/src/main/java/pr2/vererbung/konstruktoren/test/WesenTest.java +++ /dev/null @@ -1,47 +0,0 @@ -package pr2.vererbung.konstruktoren.test; - -import org.junit.jupiter.api.Test; -import pr2.vererbung.konstruktoren.Nachtelf; -import pr2.vererbung.konstruktoren.Untoter; -import pr2.vererbung.konstruktoren.Wesen; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * Test für die Aufgabe. - */ -public class WesenTest { - - /** - * Testet den Nachtelf. - */ - @Test - void testNachtelf() { - assertTrue(new Nachtelf("") instanceof Wesen, - "Nachtelf erbt nicht " + "von Wesen"); - - assertEquals(Nachtelf.STANDARD_NATURWIDERSTAND, - new Nachtelf("").getNaturwiderstand()); - - assertEquals(120, new Nachtelf("", 120).getNaturwiderstand()); - - assertEquals("Hugo", new Nachtelf("Hugo").getName()); - } - - /** - * Testet den Untoten. - */ - @Test - void testUntoten() { - assertTrue(new Untoter("") instanceof Wesen, - "Untoter erbt nicht von " + "Wesen"); - - assertEquals(Untoter.STANDARD_UNTERWASSERATMUNG, - new Untoter("").getUnterwasseratmung()); - - assertEquals(120, new Untoter("", 120).getUnterwasseratmung()); - - assertEquals("Hugo", new Untoter("Hugo").getName()); - } -} diff --git a/solutions/src/main/java/pr2/vererbung/polymorphie/Affe.java b/solutions/src/main/java/pr2/vererbung/polymorphie/Affe.java deleted file mode 100644 index 612e4ee..0000000 --- a/solutions/src/main/java/pr2/vererbung/polymorphie/Affe.java +++ /dev/null @@ -1,16 +0,0 @@ -package pr2.vererbung.polymorphie; - -/** - * Ein Affe im Zoo. - */ -public class Affe extends ZooTier { - - /** - * Legt einen neuen Affen an. - * - * @param name Name des Affen. - */ - public Affe(String name) { - super(name); - } -} diff --git a/solutions/src/main/java/pr2/vererbung/polymorphie/Futterstelle.java b/solutions/src/main/java/pr2/vererbung/polymorphie/Futterstelle.java deleted file mode 100644 index a378303..0000000 --- a/solutions/src/main/java/pr2/vererbung/polymorphie/Futterstelle.java +++ /dev/null @@ -1,16 +0,0 @@ -package pr2.vererbung.polymorphie; - -/** - * Fütterung der Tiere. - */ -public class Futterstelle { - - /** - * Füttert das Tier. - * - * @param tier Tier, das gefüttert werden soll. - */ - public void gibFutter(ZooTier tier) { - tier.fuettern(); - } - diff --git a/solutions/src/main/java/pr2/vererbung/polymorphie/Giraffe.java b/solutions/src/main/java/pr2/vererbung/polymorphie/Giraffe.java deleted file mode 100644 index 1c4cf69..0000000 --- a/solutions/src/main/java/pr2/vererbung/polymorphie/Giraffe.java +++ /dev/null @@ -1,16 +0,0 @@ -package pr2.vererbung.polymorphie; - -/** - * Eine Giraffe im Zoo. - */ -public class Giraffe extends ZooTier { - - /** - * Legt einen neue Giraffe an. - * - * @param name Name der Giraffe. - */ - public Giraffe(String name) { - super(name); - } -} diff --git a/solutions/src/main/java/pr2/vererbung/polymorphie/Gorilla.java b/solutions/src/main/java/pr2/vererbung/polymorphie/Gorilla.java deleted file mode 100644 index fd6f23d..0000000 --- a/solutions/src/main/java/pr2/vererbung/polymorphie/Gorilla.java +++ /dev/null @@ -1,16 +0,0 @@ -package pr2.vererbung.polymorphie; - -/** - * Ein Gorilla. - */ -public class Gorilla extends Affe { - - /** - * Legt einen neuen Gorilla an. - * - * @param name Name des Gorilla. - */ - public Gorilla(String name) { - super(name); - } -} diff --git a/solutions/src/main/java/pr2/vererbung/polymorphie/ZooSimulation.java b/solutions/src/main/java/pr2/vererbung/polymorphie/ZooSimulation.java deleted file mode 100644 index 11db908..0000000 --- a/solutions/src/main/java/pr2/vererbung/polymorphie/ZooSimulation.java +++ /dev/null @@ -1,39 +0,0 @@ -package pr2.vererbung.polymorphie; - -/** - * Simulationsklasse. - */ -public final class ZooSimulation { - - /** - * Konstruktor. - */ - private ZooSimulation() { - // keine Objekte benötigt - } - - /** - * Main-Methode. - * - * @param args Kommandozeilen-Argumente. - */ - public static void main(String[] args) { - Futterstelle futterstelle = new Futterstelle(); - - ZooTier[] tiere = {new Affe("Charlie"), new Gorilla("Buck"), - new Giraffe("Debbie")}; - - for (ZooTier tier : tiere) { - System.out.println(tier); - } - - System.out.println("Fütterung..."); - - for (ZooTier tier : tiere) { - futterstelle.gibFutter(tier); - } - - for (ZooTier tier : tiere) { - System.out.println(tier); - } - } diff --git a/solutions/src/main/java/pr2/vererbung/polymorphie/ZooTier.java b/solutions/src/main/java/pr2/vererbung/polymorphie/ZooTier.java deleted file mode 100644 index ff9edf9..0000000 --- a/solutions/src/main/java/pr2/vererbung/polymorphie/ZooTier.java +++ /dev/null @@ -1,41 +0,0 @@ -package pr2.vererbung.polymorphie; - -/** - * Ein Tier im Zoo. - */ -public class ZooTier { - - /** - * Name des Tiers. - */ - private final String name; - - /** - * Zeigt an, ob das Tier hungrig ist. - */ - private boolean hungrig = true; - - /** - * Legt ein neues Zootier an. - * - * @param name Name des Tiers - */ - public ZooTier(String name) { - this.name = name; - } - - /** - * Gibt dem Tier futter. - */ - public void fuettern() { - hungrig = false; - } - - /** - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return name + ": Ich bin " + (hungrig ? "hungrig" : "satt") + "!"; - } -} diff --git a/solutions/src/main/java/pr2/vererbung/singleton_einfach/Singleton.java b/solutions/src/main/java/pr2/vererbung/singleton_einfach/Singleton.java deleted file mode 100644 index f471b44..0000000 --- a/solutions/src/main/java/pr2/vererbung/singleton_einfach/Singleton.java +++ /dev/null @@ -1,12 +0,0 @@ -package pr2.vererbung.singleton_einfach; - -public final class Singleton { - - private static final Singleton INSTANCE = new Singleton(); - - private Singleton() { /* leer */ } - - public static Singleton getInstance() { - return INSTANCE; - } -} diff --git a/solutions/src/main/java/pr2/vererbung/statics/Spiel.java b/solutions/src/main/java/pr2/vererbung/statics/Spiel.java deleted file mode 100644 index afa174a..0000000 --- a/solutions/src/main/java/pr2/vererbung/statics/Spiel.java +++ /dev/null @@ -1,33 +0,0 @@ -package pr2.vererbung.statics; - -/** - * Spiel mit den Würfeln. - */ -public final class Spiel { - - /** - * Keine Objekte. - */ - private Spiel() { - // leer - } - - /** - * Programm-Einstieg. - * - * @param args Kommandozeilen-Argumente. - */ - public static void main(String[] args) { - Wuerfel wuerfel1 = new Wuerfel(); - Wuerfel wuerfel2 = new Wuerfel(); - - // 1000 Mal würfeln - for (int i = 0; i < 1000; i++) { - wuerfel1.wuerfele(); - wuerfel2.wuerfele(); - } - - // Statistik ausgeben - System.out.println("Statistik für alle Würfel"); - System.out.println(Wuerfel.statistik()); - System.out.println(); diff --git a/solutions/src/main/java/pr2/vererbung/statics/Wuerfel.java b/solutions/src/main/java/pr2/vererbung/statics/Wuerfel.java deleted file mode 100644 index 98856c1..0000000 --- a/solutions/src/main/java/pr2/vererbung/statics/Wuerfel.java +++ /dev/null @@ -1,52 +0,0 @@ -package pr2.vererbung.statics; - -import java.util.Random; - -/** - * Ein einfacher Würfel. - */ -public class Wuerfel { - - /** Häufigkeit der Werte. */ - private static final int[] HAEUFIGKEIT = new int[6]; - - /** Anzahl der Würfe mit dem Würfel. */ - private static int wuerfe = 0; - - /** Zufallsgenerator. */ - private final Random random = new Random(); - - /** - * Bestimmt den nächsten Wurf. - * - * @return der Wurf. - */ - public int wuerfele() { - int wert = random.nextInt(6); - HAEUFIGKEIT[wert]++; - wuerfe++; - return wert + 1; - } - - /** - * Gibt die Häufigkeit der Würfe zurück. - * - * @return die Statistik mit der Häufigkeit. - */ - public static String statistik() { - StringBuilder result = new StringBuilder(); - - for (int i = 0; i < HAEUFIGKEIT.length; i++) { - result.append(i + 1) - .append(": ") - .append(String.format("%.2f %%", - ((double) HAEUFIGKEIT[i] / wuerfe) * 100)) - .append("\n"); - } - - result.append("Summe: ") - .append(wuerfe) - .append("\n"); - - return result.toString(); - } diff --git a/solutions/src/main/java/pr2/vererbung/ueberladen_summe/Summator.java b/solutions/src/main/java/pr2/vererbung/ueberladen_summe/Summator.java deleted file mode 100644 index 7f0bfa1..0000000 --- a/solutions/src/main/java/pr2/vererbung/ueberladen_summe/Summator.java +++ /dev/null @@ -1,20 +0,0 @@ -package pr2.vererbung.ueberladen_summe; - -public class Summator { - - public int sum(int a, int b) { - return a + b; - } - - public int sum(int a, int b, int c) { - return a + b + c; - } - - public int sum(int a, int b, int c, int d) { - return a + b + c + d; - } - - public int sum(int a, int b, int c, int d, int e) { - return a + b + c + d + e; - } -} diff --git a/solutions/src/main/java/pr2/vererbung/ueberladen_summe/test/SummatorTest.java b/solutions/src/main/java/pr2/vererbung/ueberladen_summe/test/SummatorTest.java deleted file mode 100644 index d20882e..0000000 --- a/solutions/src/main/java/pr2/vererbung/ueberladen_summe/test/SummatorTest.java +++ /dev/null @@ -1,22 +0,0 @@ -package pr2.vererbung.ueberladen_summe.test; - -import org.junit.jupiter.api.Test; -import pr2.vererbung.ueberladen_summe.Summator; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class SummatorTest { - - @Test - void testSum() { - Summator s = new Summator(); - assertEquals(3, s.sum(1, 2)); - assertEquals(1, s.sum(-1, 2)); - assertEquals(6, s.sum(1, 2, 3)); - assertEquals(0, s.sum(1, 2, -3)); - assertEquals(10, s.sum(1, 2, 3, 4)); - assertEquals(2, s.sum(1, 2, 3, -4)); - assertEquals(15, s.sum(1, 2, 3, 4, 5)); - assertEquals(5, s.sum(1, 2, 3, 4, -5)); - } -} diff --git a/solutions/src/main/java/pr2/vererbung/ueberschreiben_lebewesen/Amoebe.java b/solutions/src/main/java/pr2/vererbung/ueberschreiben_lebewesen/Amoebe.java deleted file mode 100644 index 86dcc48..0000000 --- a/solutions/src/main/java/pr2/vererbung/ueberschreiben_lebewesen/Amoebe.java +++ /dev/null @@ -1,9 +0,0 @@ -package pr2.vererbung.ueberschreiben_lebewesen; - -public class Amoebe extends Lebewesen { - - @Override - public void bewegen() { - System.out.println("Schleimen"); - } -} diff --git a/solutions/src/main/java/pr2/vererbung/ueberschreiben_lebewesen/Dackel.java b/solutions/src/main/java/pr2/vererbung/ueberschreiben_lebewesen/Dackel.java deleted file mode 100644 index 89aeb8d..0000000 --- a/solutions/src/main/java/pr2/vererbung/ueberschreiben_lebewesen/Dackel.java +++ /dev/null @@ -1,13 +0,0 @@ -package pr2.vererbung.ueberschreiben_lebewesen; - -public class Dackel extends Lebewesen { - - @Override - public void bewegen() { - System.out.println("Auf kurzen Beinen vorwärts wackeln"); - } - - public void bellen() { - System.out.println("Wau wau wau"); - } -} diff --git a/solutions/src/main/java/pr2/vererbung/ueberschreiben_lebewesen/Lebewesen.java b/solutions/src/main/java/pr2/vererbung/ueberschreiben_lebewesen/Lebewesen.java deleted file mode 100644 index 85ebef2..0000000 --- a/solutions/src/main/java/pr2/vererbung/ueberschreiben_lebewesen/Lebewesen.java +++ /dev/null @@ -1,8 +0,0 @@ -package pr2.vererbung.ueberschreiben_lebewesen; - -public class Lebewesen { - - public void bewegen() { - /* nichts machen */ - } -} diff --git a/solutions/src/main/java/pr2/vererbung/ueberschreiben_lebewesen/Main.java b/solutions/src/main/java/pr2/vererbung/ueberschreiben_lebewesen/Main.java deleted file mode 100644 index e535a17..0000000 --- a/solutions/src/main/java/pr2/vererbung/ueberschreiben_lebewesen/Main.java +++ /dev/null @@ -1,16 +0,0 @@ -package pr2.vererbung.ueberschreiben_lebewesen; - -public class Main { - - public static void main(String[] args) { - Lebewesen l1 = new Dackel(); - Lebewesen l2 = new Amoebe(); - - l1.bewegen(); - l2.bewegen(); - - if (l1 instanceof Dackel) { - ((Dackel) l1).bellen(); - } - } -} diff --git a/solutions/src/main/java/pr2/vererbung/vararg_summe/Summator.java b/solutions/src/main/java/pr2/vererbung/vararg_summe/Summator.java deleted file mode 100644 index 6457e2a..0000000 --- a/solutions/src/main/java/pr2/vererbung/vararg_summe/Summator.java +++ /dev/null @@ -1,22 +0,0 @@ -package pr2.vererbung.vararg_summe; - -public class Summator { - - public int sum(int a, int b) { - return a + b; - } - - public int sum(int a, int b, int c) { - return a + b + c; - } - - public int sum(int a, int b, int c, int... as) { - int sum = a + b + c; - - for (int i : as) { - sum += i; - } - - return sum; - } -} diff --git a/solutions/src/main/java/pr2/vererbung/vararg_summe/test/SummatorTest.java b/solutions/src/main/java/pr2/vererbung/vararg_summe/test/SummatorTest.java deleted file mode 100644 index 93aba84..0000000 --- a/solutions/src/main/java/pr2/vererbung/vararg_summe/test/SummatorTest.java +++ /dev/null @@ -1,23 +0,0 @@ -package pr2.vererbung.vararg_summe.test; - -import org.junit.jupiter.api.Test; -import pr2.vererbung.vararg_summe.Summator; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class SummatorTest { - - @Test - void testSum() { - Summator s = new Summator(); - assertEquals(3, s.sum(1, 2)); - assertEquals(1, s.sum(-1, 2)); - assertEquals(6, s.sum(1, 2, 3)); - assertEquals(0, s.sum(1, 2, -3)); - assertEquals(10, s.sum(1, 2, 3, 4)); - assertEquals(2, s.sum(1, 2, 3, -4)); - assertEquals(15, s.sum(1, 2, 3, 4, 5)); - assertEquals(5, s.sum(1, 2, 3, 4, -5)); - assertEquals(36, s.sum(1, 2, 3, 4, 5, 6, 7, 8)); - } -} diff --git a/solutions/src/main/java/pr2/vererbung/vererbung_geometrie/Dreieck.java b/solutions/src/main/java/pr2/vererbung/vererbung_geometrie/Dreieck.java deleted file mode 100644 index 70162b9..0000000 --- a/solutions/src/main/java/pr2/vererbung/vererbung_geometrie/Dreieck.java +++ /dev/null @@ -1,17 +0,0 @@ -package pr2.vererbung.vererbung_geometrie; - -/** - * Ein Dreieck. - */ -public class Dreieck extends Figur { - - /** - * Erzeugt ein neues Dreieck mit den gegebenen Daten. - * - * @param grundseite Grundseite des Dreiecks. - * @param hoehe Höhe des Dreiecks. - */ - public Dreieck(double grundseite, double hoehe) { - super(grundseite * hoehe / 2); - } -} diff --git a/solutions/src/main/java/pr2/vererbung/vererbung_geometrie/Figur.java b/solutions/src/main/java/pr2/vererbung/vererbung_geometrie/Figur.java deleted file mode 100644 index ebe5383..0000000 --- a/solutions/src/main/java/pr2/vererbung/vererbung_geometrie/Figur.java +++ /dev/null @@ -1,37 +0,0 @@ -package pr2.vererbung.vererbung_geometrie; - -/** - * Basisklasse für geometrische Formen. - */ -public class Figur { - - /** - * Fläche der Figur. - */ - private double flaeche; - - /** - * Legt eine neue Figur mit der Fläche 0 an. - */ - protected Figur() { - /* leer */ - } - - /** - * Legt eine neue Figur mit der gegebenen Fläche an. - * - * @param flaeche Fläche der Figur. - */ - protected Figur(double flaeche) { - this.flaeche = flaeche; - } - - /** - * Liefert die Fläche der Figur. - * - * @return die Fläche. - */ - public double getFlaeche() { - return flaeche; - } -} diff --git a/solutions/src/main/java/pr2/vererbung/vererbung_geometrie/Gerade.java b/solutions/src/main/java/pr2/vererbung/vererbung_geometrie/Gerade.java deleted file mode 100644 index 55dbcf3..0000000 --- a/solutions/src/main/java/pr2/vererbung/vererbung_geometrie/Gerade.java +++ /dev/null @@ -1,31 +0,0 @@ -package pr2.vererbung.vererbung_geometrie; - -/** - * Eine Gerade. - */ -public class Gerade extends Figur { - - /** - * Länge der Geraden. - */ - private double laenge; - - /** - * Legt eine neue Gerade mit der gegebenen Länge an. - * - * @param laenge Länge der Geraden. - */ - public Gerade(double laenge) { - super(); - this.laenge = laenge; - } - - /** - * Liefert die Länge der Geraden. - * - * @return die Länge. - */ - public double getLaenge() { - return laenge; - } -} diff --git a/solutions/src/main/java/pr2/vererbung/vererbung_geometrie/Quadrat.java b/solutions/src/main/java/pr2/vererbung/vererbung_geometrie/Quadrat.java deleted file mode 100644 index 5e0626f..0000000 --- a/solutions/src/main/java/pr2/vererbung/vererbung_geometrie/Quadrat.java +++ /dev/null @@ -1,16 +0,0 @@ -package pr2.vererbung.vererbung_geometrie; - -/** - * Qudrat. - */ -public class Quadrat extends Rechteck { //*** replace(public class Quadrat {) - - /** - * Legt ein neues Quadrat an. - * - * @param seitenlaenge Länge der Seiten des Quadrates. - */ - public Quadrat(double seitenlaenge) { - super(seitenlaenge, seitenlaenge); - } -} diff --git a/solutions/src/main/java/pr2/vererbung/vererbung_geometrie/Rechteck.java b/solutions/src/main/java/pr2/vererbung/vererbung_geometrie/Rechteck.java deleted file mode 100644 index e1dd8dc..0000000 --- a/solutions/src/main/java/pr2/vererbung/vererbung_geometrie/Rechteck.java +++ /dev/null @@ -1,17 +0,0 @@ -package pr2.vererbung.vererbung_geometrie; - -/** - * Rechteck. - */ -public class Rechteck extends Figur { - - /** - * Legt ein neues Rechteck an. - * - * @param breite Breite. - * @param hoehe Höhe. - */ - public Rechteck(double breite, double hoehe) { - super(breite * hoehe); - } -} diff --git a/solutions/src/main/java/pr2/vererbung/vererbung_geometrie/test/FigurenTest.java b/solutions/src/main/java/pr2/vererbung/vererbung_geometrie/test/FigurenTest.java deleted file mode 100644 index 446402d..0000000 --- a/solutions/src/main/java/pr2/vererbung/vererbung_geometrie/test/FigurenTest.java +++ /dev/null @@ -1,67 +0,0 @@ -package pr2.vererbung.vererbung_geometrie.test; - -import org.junit.jupiter.api.Test; -import pr2.vererbung.vererbung_geometrie.Dreieck; -import pr2.vererbung.vererbung_geometrie.Gerade; -import pr2.vererbung.vererbung_geometrie.Quadrat; -import pr2.vererbung.vererbung_geometrie.Rechteck; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * Tests für die Figuren. - */ -public class FigurenTest { - - private static final double PRECISION = 0.0001; - - /** - * Rechteck. - */ - @Test - void testReckteck() { - Rechteck r1 = new Rechteck(4.0, 5.0); - Rechteck r2 = new Rechteck(0.0, 3.0); - assertEquals(20.0, r1.getFlaeche(), PRECISION); - assertEquals(0.0, r2.getFlaeche(), PRECISION); - } - - /** - * Dreieck. - */ - @Test - void testDreieck() { - Dreieck d1 = new Dreieck(6.0, 3.5); - assertEquals(10.5, d1.getFlaeche(), PRECISION); - } - - /** - * Gerade. - */ - @Test - void testGerade() { - Gerade g1 = new Gerade(8.0); - assertEquals(8.0, g1.getLaenge(), PRECISION); - assertEquals(0.0, g1.getFlaeche(), PRECISION); - - g1 = new Gerade(0.0); - assertEquals(0.0, g1.getLaenge(), PRECISION); - assertEquals(0.0, g1.getFlaeche(), PRECISION); - } - - /** - * Quadrat. - */ - @Test - void testQuadrat() { - Quadrat q1 = new Quadrat(3.0); - assertEquals(9.0, q1.getFlaeche(), PRECISION); - - Rechteck r1 = new Rechteck(5.0, 5.0); - Quadrat q2 = new Quadrat(5.0); - assertEquals(r1.getFlaeche(), q2.getFlaeche(), PRECISION); - - q1 = new Quadrat(0.0); - assertEquals(0.0, q1.getFlaeche(), PRECISION); - } -}