Initial commit

This commit is contained in:
AlexBa16
2024-11-19 08:47:16 +01:00
commit 5c6877fe23
43 changed files with 57679 additions and 0 deletions

29
.gitignore vendored Normal file
View File

@@ -0,0 +1,29 @@
### IntelliJ IDEA ###
out/
!**/src/main/**/out/
!**/src/test/**/out/
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

8
.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

5
.idea/codeStyles/codeStyleConfig.xml generated Normal file
View File

@@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>

54745
.idea/icon.svg generated Normal file

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 3.2 MiB

View File

@@ -0,0 +1,10 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="CommentedOutCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="minLines" value="7" />
</inspection_tool>
<inspection_tool class="RegExpAnonymousGroup" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="RegExpEscapedMetaCharacter" enabled="false" level="INFORMATION" enabled_by_default="false" />
</profile>
</component>

10
.idea/libraries/lib.xml generated Normal file
View File

@@ -0,0 +1,10 @@
<component name="libraryTable">
<library name="lib">
<CLASSES>
<root url="file://$PATH_TO_FX$" />
</CLASSES>
<JAVADOC />
<SOURCES />
<jarDirectory url="file://$PATH_TO_FX$" recursive="false" />
</library>
</component>

6
.idea/misc.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_22" project-jdk-name="20" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
.idea/modules.xml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/SEW_Bachinger_2024.25.iml" filepath="$PROJECT_DIR$/SEW_Bachinger_2024.25.iml" />
</modules>
</component>
</project>

124
.idea/uiDesigner.xml generated Normal file
View File

@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

76
SEW_Bachinger_2024.25.iml Normal file
View File

@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library name="JUnit5.8.1">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter/5.8.1/junit-jupiter-5.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-api/5.8.1/junit-jupiter-api-5.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/1.8.1/junit-platform-commons-1.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-params/5.8.1/junit-jupiter-params-5.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-engine/5.8.1/junit-jupiter-engine-5.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-engine/1.8.1/junit-platform-engine-1.8.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="JUnit5.8.1">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter/5.8.1/junit-jupiter-5.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-api/5.8.1/junit-jupiter-api-5.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/1.8.1/junit-platform-commons-1.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-params/5.8.1/junit-jupiter-params-5.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-engine/5.8.1/junit-jupiter-engine-5.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-engine/1.8.1/junit-platform-engine-1.8.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="JUnit5.8.1">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter/5.8.1/junit-jupiter-5.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-api/5.8.1/junit-jupiter-api-5.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/1.8.1/junit-platform-commons-1.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-params/5.8.1/junit-jupiter-params-5.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-engine/5.8.1/junit-jupiter-engine-5.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-engine/1.8.1/junit-platform-engine-1.8.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="JUnit5.8.1">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter/5.8.1/junit-jupiter-5.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-api/5.8.1/junit-jupiter-api-5.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/1.8.1/junit-platform-commons-1.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-params/5.8.1/junit-jupiter-params-5.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-engine/5.8.1/junit-jupiter-engine-5.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-engine/1.8.1/junit-platform-engine-1.8.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" name="lib" level="project" />
</component>
</module>

View File

@@ -0,0 +1,54 @@
package UE00_Other.MEDT;
import java.util.ArrayList;
import java.util.List;
public class Plakat_CODING_Contest {
static final String participation_fee = "20€";
static final String grand_prize = "Macbook Pro M4";
public static List<Integer> generateFibonacci(int length) {
List<Integer> sequence = new ArrayList<>();
int a = 0, b = 1;
while (sequence.size() < length) {
sequence.add(a);
int temp = a;
a = b;
b = temp + b;
}
return sequence;
}
public static List<Integer> generateRandomNumbers(int count) {
List<Integer> numbers = new ArrayList<>();
for (int i = 0; i < count; i++) numbers.add((int) (Math.random() * 100) + 1);
return numbers;
}
public static int sumPrimes(List<Integer> numbers) {
int sum = 0;
for (int number : numbers) if (isPrime(number)) sum += number;
return sum;
}
public static boolean isPrime(int number) {
if (number <= 1) return false;
for (int i = 2; i <= Math.sqrt(number); i++) if (number % i == 0) return false;
return true;
}
static void depthFirstSearch(Node node, List<Node> visited) {
if (node == null || visited.contains(node)) return;
System.out.println("Visited: " + node.name);
visited.add(node);
for (Node neighbor : node.neighbors) depthFirstSearch(neighbor, visited);
}
static class Node {
String name;
List<Node> neighbors;
Node(String name) {
this.name = name;
this.neighbors = new ArrayList<>();
}
void addNeighbor(Node neighbor) {
neighbors.add(neighbor);
}
}
}

View File

@@ -0,0 +1,115 @@
package UE01_030924_Wiederholung;
import static org.junit.jupiter.api.Assertions.*;
public class BankwesenTest {
public static void main(String[] args) {
Girokonto girokonto = new Girokonto("AlexArm", 5);
Girokonto girokonto1 = new Girokonto("AlexReich", 1000, -5);
Girokonto girokonto2 = new Girokonto(null, -100, 0);
Kreditkonto kreditkonto = new Kreditkonto("AlexArm", 5, -1000);
Kreditkonto kreditkonto1 = new Kreditkonto("AlexReich", 5, 1000);
Kreditkonto kreditkonto2 = new Kreditkonto(null, -5, 0);
Sparbuch sparbuch = new Sparbuch(1000, 2);
Sparbuch sparbuch1 = new Sparbuch(-1000, 5);
Sparbuch sparbuch2 = new Sparbuch(5);
testGirokonto(girokonto, girokonto1, girokonto2);
System.out.println("Girokonto Tests erfolgreich!");
testKreditkonto(kreditkonto, kreditkonto1, kreditkonto2);
System.out.println("Kreditkonto Tests erfolgreich!");
testSparbuch(sparbuch, sparbuch1, sparbuch2);
System.out.println("Sparbuch Tests erfolgreich!");
girokonto.speichereKontoauszug();
girokonto1.speichereKontoauszug();
girokonto2.speichereKontoauszug();
kreditkonto.speichereKontoauszug();
kreditkonto1.speichereKontoauszug();
kreditkonto2.speichereKontoauszug();
sparbuch.speichereKontoauszug();
sparbuch1.speichereKontoauszug();
sparbuch2.speichereKontoauszug();
System.out.println("\nGesamt Summe: " + berechneSumme(girokonto, girokonto1, girokonto2, kreditkonto, kreditkonto1, kreditkonto2, sparbuch, sparbuch1, sparbuch2));
}
public static void testGirokonto(Girokonto girokonto, Girokonto girokonto1, Girokonto girokonto2) {
assertEquals(girokonto.einzahlung(-100), 0);
assertEquals(girokonto.getKontostand(), 0);
assertEquals(girokonto.einzahlung(100), 100);
assertEquals(girokonto.getKontostand(), 100);
assertFalse(girokonto.auszahlung(2000));
assertEquals(girokonto.getKontostand(), 100);
assertTrue(girokonto1.auszahlung(200));
assertEquals(girokonto1.getKontostand(), 800);
assertEquals(girokonto1.getKontostand(), 800);
assertEquals(girokonto.getKontostand(), 100);
assertEquals(girokonto1.ueberweisung(girokonto, 50), 50);
assertEquals(girokonto1.getKontostand(), 750);
assertEquals(girokonto.getKontostand(), 150);
assertEquals(girokonto1.ueberweisung(girokonto, 5000), 0);
assertEquals(girokonto1.getKontostand(), 750);
assertEquals(girokonto.getKontostand(), 150);
assertEquals(girokonto1.ueberweisung(girokonto, -100), 0);
assertEquals(girokonto1.getKontostand(), 750);
assertEquals(girokonto.getKontostand(), 150);
assertEquals(girokonto.toString(), "000001 - Girokonto von AlexArm: Zinssatz: 5.0%, Kontostand: 150.0");
assertEquals(girokonto1.toString(), "000002 - Girokonto von AlexReich: Zinssatz: -5.0%, Kontostand: 750.0");
assertEquals(girokonto2.toString(), "000003 - Girokonto von undefined: Zinssatz: 0.0%, Kontostand: -100.0");
girokonto.verrechneZinsen();
girokonto1.verrechneZinsen();
girokonto2.verrechneZinsen();
assertEquals(girokonto.toString(), "000001 - Girokonto von AlexArm: Zinssatz: 5.0%, Kontostand: 157.5");
assertEquals(girokonto1.toString(), "000002 - Girokonto von AlexReich: Zinssatz: -5.0%, Kontostand: 712.5");
assertEquals(girokonto2.toString(), "000003 - Girokonto von undefined: Zinssatz: 0.0%, Kontostand: -100.0");
}
public static void testKreditkonto(Kreditkonto kreditkonto, Kreditkonto kreditkonto1, Kreditkonto kreditkonto2) {
assertEquals(kreditkonto.einzahlung(-100), 0);
assertEquals(kreditkonto.getKontostand(), -1000);
assertEquals(kreditkonto.einzahlung(100), 100);
assertEquals(kreditkonto.getKontostand(), -900);
assertEquals(kreditkonto1.einzahlung(-100), 0);
assertEquals(kreditkonto1.getKontostand(), -1000);
assertEquals(kreditkonto1.einzahlung(100), 100);
assertEquals(kreditkonto1.getKontostand(), -900);
assertEquals(kreditkonto.toString(), "000004 - Kreditkonto von AlexArm: Zinssatz: 5.0%, Kontostand: -900.0");
assertEquals(kreditkonto1.toString(), "000005 - Kreditkonto von AlexReich: Zinssatz: 5.0%, Kontostand: -900.0");
assertEquals(kreditkonto2.toString(), "000006 - Kreditkonto von undefined: Zinssatz: -5.0%, Kontostand: -0.0");
assertEquals(kreditkonto.einzahlung(900), 900);
assertEquals(kreditkonto.getKontostand(), 0);
assertEquals(kreditkonto1.einzahlung(1000), 900);
assertEquals(kreditkonto1.getKontostand(), 0);
}
public static void testSparbuch(Sparbuch sparbuch, Sparbuch sparbuch1, Sparbuch sparbuch2) {
assertEquals(sparbuch.einzahlung(-100), 0);
assertEquals(sparbuch.getKontostand(), 1000);
assertEquals(sparbuch.einzahlung(100), 100);
assertEquals(sparbuch.getKontostand(), 1100);
assertTrue(sparbuch.auszahlung(100));
assertEquals(sparbuch.getKontostand(), 1000);
assertFalse(sparbuch1.auszahlung(200));
assertEquals(sparbuch1.getKontostand(), -1000);
assertEquals(sparbuch.toString(), "000007 - Sparbuch: Zinssatz: 2.0%, Kontostand: 1000.0");
assertEquals(sparbuch1.toString(), "000008 - Sparbuch: Zinssatz: 5.0%, Kontostand: -1000.0");
assertEquals(sparbuch2.toString(), "000009 - Sparbuch: Zinssatz: 5.0%, Kontostand: 0.0");
}
public static double berechneSumme(Konto... kontos) {
double summe = 0;
for (Konto konto : kontos) summe += konto.getKontostand();
return summe;
}
}

View File

@@ -0,0 +1,41 @@
package UE01_030924_Wiederholung;
public class Girokonto extends Konto {
String name = "undefined";
public Girokonto(String name, double betrag, double zinssatz) {
super(betrag, zinssatz, "Girokonto");
if (name != null) this.name = name;
}
public Girokonto(String name, double zinssatz) {
super(zinssatz, "Girokonto");
this.name = name;
}
public double einzahlung(double betrag) {
if (betrag < 0) return 0;
this.kontostand += betrag;
this.buchungsvorgaenge.add("Einzahlung: " + betrag);
return betrag;
}
public boolean auszahlung(double betrag) {
if (this.kontostand - betrag < 0) return false;
this.kontostand -= betrag;
this.buchungsvorgaenge.add("Auszahlung: " + betrag);
return true;
}
public double ueberweisung(Konto empfaenger, double betrag) {
if (betrag < 0 || !auszahlung(betrag)) return 0;
empfaenger.einzahlung(betrag);
this.buchungsvorgaenge.add("Überweisung an " + kontonummer(empfaenger.kontonummer) + ": " + betrag);
return betrag;
}
@Override
public String toString() {
return kontonummer(this.kontonummer) + " - " + this.kontoTyp + " von " + this.name + ": Zinssatz: " + this.zinssatz + "%, Kontostand: " + this.kontostand;
}
}

View File

@@ -0,0 +1,62 @@
package UE01_030924_Wiederholung;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
public abstract class Konto {
private static int kontonummerCounter = 0;
protected int kontonummer;
protected double kontostand;
protected double zinssatz;
protected ArrayList<String> buchungsvorgaenge = new ArrayList<>();
String kontoTyp;
public Konto(double betrag, double zinssatz, String typ) {
if (kontonummerCounter >= 999999) throw new RuntimeException("Zu viele Konten");
this.kontostand = betrag;
this.zinssatz = zinssatz;
this.kontonummer = ++kontonummerCounter;
this.kontoTyp = typ;
this.buchungsvorgaenge.add("Kontoeröffnung: Betrag = " + this.kontostand + ", Zinssatz = " + this.zinssatz + "%");
}
public Konto(double zinssatz, String typ) {
if (kontonummerCounter >= 999999) throw new RuntimeException("Zu viele Konten");
this.kontostand = 0;
this.zinssatz = zinssatz;
this.kontonummer = ++kontonummerCounter;
this.kontoTyp = typ;
this.buchungsvorgaenge.add("Kontoeröffnung: Betrag = " + this.kontostand + ", Zinssatz = " + this.zinssatz + "%");
}
@Override
public String toString() {
return kontonummer(this.kontonummer) + " - " + this.kontoTyp + ": Zinssatz: " + this.zinssatz + "%, Kontostand: " + this.kontostand;
}
public void verrechneZinsen() {
double zins = this.kontostand * (this.zinssatz / 100);
this.buchungsvorgaenge.add("Zinsen verrechnet: " + zins);
this.kontostand += zins;
}
public void speichereKontoauszug() {
try {
Files.write(Paths.get("src/UE01_030924_Wiederholung/auszuege/auszug" + kontonummer(this.kontonummer) + ".txt"), this.buchungsvorgaenge);
} catch (IOException e) {
e.getStackTrace();
}
}
public String kontonummer(int kontonummer) {
return ("000000" + kontonummer).substring(("000000" + kontonummer).length() - 6);
}
public abstract double einzahlung(double betrag);
public double getKontostand() {
return this.kontostand;
}
}

View File

@@ -0,0 +1,28 @@
package UE01_030924_Wiederholung;
public class Kreditkonto extends Konto {
String name = "undefined";
public Kreditkonto(String name, double zinssatz, double betrag) {
super((betrag < 0 ? betrag : betrag * -1), zinssatz, "Kreditkonto");
if (name != null) this.name = name;
}
public double einzahlung(double betrag) {
if (betrag < 0) return 0;
double overflow = this.kontostand;
this.kontostand += betrag;
if (this.kontostand > 0) {
this.kontostand = 0;
this.buchungsvorgaenge.add("Einzahlung: " + (-overflow));
return Math.abs(overflow);
}
this.buchungsvorgaenge.add("Einzahlung: " + betrag);
return betrag;
}
@Override
public String toString() {
return kontonummer(this.kontonummer) + " - " + this.kontoTyp + " von " + this.name + ": Zinssatz: " + this.zinssatz + "%, Kontostand: " + this.kontostand;
}
}

View File

@@ -0,0 +1,25 @@
package UE01_030924_Wiederholung;
public class Sparbuch extends Konto {
public Sparbuch(double betrag, double zinssatz) {
super(betrag, zinssatz, "Sparbuch");
}
public Sparbuch(double zinssatz) {
super(zinssatz, "Sparbuch");
}
public double einzahlung(double betrag) {
if (betrag < 0) return 0;
this.kontostand += betrag;
this.buchungsvorgaenge.add("Einzahlung: " + betrag);
return betrag;
}
public boolean auszahlung(double betrag) {
if (this.kontostand - betrag < 0) return false;
this.kontostand -= betrag;
this.buchungsvorgaenge.add("Auszahlung: " + betrag);
return true;
}
}

View File

@@ -0,0 +1,26 @@
package UE02_100924_Collections_TreeSet;
public class Buch implements Comparable<Buch> {
String title;
String autor;
int price;
public Buch(String title, String autor, int price) {
this.title = title;
this.autor = autor;
this.price = price;
}
@Override
public String toString() {
return "Buch{" + "title='" + title + '\'' + ", autor='" + autor + '\'' + ", price=" + price + '}';
}
@Override
public int compareTo(Buch o) {
if (this.price != o.price) return Integer.compare(this.price, o.price);
int compare = this.title.compareTo(o.title);
if (compare != 0) return compare;
return this.autor.compareTo(o.autor);
}
}

View File

@@ -0,0 +1,23 @@
package UE02_100924_Collections_TreeSet;
public class Person implements Comparable<Person> {
public String vorname;
public String famname;
public Person(String vn, String fn) {
this.vorname = vn.trim();
this.famname = fn.trim();
}
@Override
public String toString() {
return "Person{" + "vorname='" + vorname + '\'' + ", famname='" + famname + '\'' + '}';
}
@Override
public int compareTo(Person o) {
int compare = this.famname.compareToIgnoreCase(o.famname);
if (compare != 0) return compare;
return this.vorname.compareToIgnoreCase(o.vorname);
}
}

View File

@@ -0,0 +1,26 @@
package UE02_100924_Collections_TreeSet;
public class Punkt implements Comparable<Punkt> {
int pointX;
int pointY;
public Punkt(int x, int y) {
this.pointX = x;
this.pointY = y;
}
@Override
public String toString() {
return "(" + pointX + "|" + pointY + ")";
}
@Override
public int compareTo(Punkt o) {
//Origin of the Sorting of the Points is the left lower corner.
double vector = Math.sqrt(this.pointX * this.pointX + this.pointY * this.pointY);
double objectVector = Math.sqrt(o.pointX * o.pointX + o.pointY * o.pointY);
if (vector != objectVector) return Double.compare(vector, objectVector);
if (this.pointX != o.pointX) return Integer.compare(this.pointX, o.pointX);
return Integer.compare(this.pointY, o.pointY);
}
}

View File

@@ -0,0 +1,67 @@
package UE02_100924_Collections_TreeSet;
import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;
public class UE02_Main {
public static void main(String[] args) {
testPerson();
testPunkt();
testBuch();
}
public static void testPerson() {
// Comparator<Person> personComp = (o1, o2) -> {
// int compare = o1.famname.compareToIgnoreCase(o2.famname);
// if (compare != 0) return compare;
// return o1.vorname.compareToIgnoreCase(o2.vorname);
// };
// Set<Person> persons = new TreeSet<>(personComp);
Set<Person> persons = new TreeSet<>();
persons.add(new Person("Tom", "Human"));
persons.add(new Person("Benton", "Mensch"));
persons.add(new Person("Anton", "Mensch"));
persons.add(new Person("Anton", "Mensch"));
System.out.println(persons);
}
public static void testPunkt() {
Set<Punkt> points = new TreeSet<>();
points.add(new Punkt(1, 1));
points.add(new Punkt(3, 3));
points.add(new Punkt(4, 4));
points.add(new Punkt(-1, -1));
points.add(new Punkt(1, -1));
points.add(new Punkt(-1, 1));
System.out.println(points);
}
public static void testBuch() {
Set<Buch> books = new TreeSet<>();
books.add(new Buch("Book", "AntonZ", 10));
books.add(new Buch("Book", "Anton", 10));
books.add(new Buch("Anaconda", "Anton", 10));
books.add(new Buch("Book", "Tom", 40));
books.add(new Buch("Book", "Tom", 10));
books.add(new Buch("Book", "Tom", 20));
books.add(new Buch("Book", "Tom", 10));
books.add(new Buch("Book", "Tom", 10));
System.out.println(books);
Comparator<Buch> buchComp = (o1, o2) -> {
if (!o1.title.equals(o2.title)) return o1.title.compareToIgnoreCase(o2.title);
if (!o1.autor.equals(o2.autor)) return o1.autor.compareToIgnoreCase(o2.autor);
return Integer.compare(o1.price, o2.price);
};
Set<Buch> compBooks = new TreeSet<>(buchComp);
System.out.println(compBooks);
}
}

View File

@@ -0,0 +1,41 @@
package UE02_100924_Collections_TreeSet.theorie;
public class Mensch {
String vor;
String nach;
int alter;
public Mensch(String vor, String nach, int alter) {
this.vor = vor;
this.nach = nach;
this.alter = alter;
}
@Override
public String toString() {
return "Mensch{" +
"vor='" + vor + '\'' +
", nach='" + nach + '\'' +
", alter=" + alter +
'}';
}
public int compareToXXXX(Mensch o) {
//liefert : positive Zahl, wenn this größer als o
// negative Zahl, wenn this kleiner als o
// 0 , wenn beide gleich
// erstes Kriterium: Vorname
int vergleich = this.vor.compareTo(o.vor);
if (vergleich != 0)
return vergleich;
//zweites Kriterium: Nachname
vergleich = this.nach.compareTo(o.nach);
if (vergleich != 0)
return vergleich;
vergleich = this.alter-o.alter;
return vergleich;
}
}

View File

@@ -0,0 +1,57 @@
package UE02_100924_Collections_TreeSet.theorie;
import java.util.*;
public class Set_Main {
public static void main(String[] args) {
List<String> names1 = new ArrayList<>();
names1.add("Karl");
names1.add("Karl");
names1.add("Karl");
names1.add("Karl");
names1.add("Franz");
System.out.println(names1);
//Ein Set verhindert Duplikate
//TreeSet sortiert Einträge nach ihrer natürlichen Ordnung
Set<String> names2 = new TreeSet<>(names1);
//names2.addAll(names1);
System.out.println(names2);
//Zugriff auf Elemente - kein Index
names2.remove("Otto");
System.out.println(names2);
for (String s:names2) {
System.out.println(s.hashCode());
}
Comparator <Mensch> mComp = new Comparator<Mensch>() {
@Override
public int compare(Mensch o1, Mensch o2) {
int vergleich = o1.vor.compareTo(o2.vor);
if (vergleich != 0)
return vergleich;
//zweites Kriterium: Nachname
vergleich = o1.nach.compareTo(o2.nach);
if (vergleich != 0)
return vergleich;
vergleich = o1.alter-o2.alter;
return vergleich;
}
};
Set <Mensch> people = new TreeSet<>(mComp);
people.add(new Mensch("Max","Mustermann", 22));
people.add(new Mensch("Max","Mustermann", 23));
people.add(new Mensch("Christian","Klein", 99));
System.out.println(people);
}
}

View File

@@ -0,0 +1,44 @@
package UE03_170924_Map_Birthdays;
public class Birthday implements Comparable {
private int day;
private int month;
private int year;
public Birthday(String date) {
if (date.length() != 10) return;
for (int i = 0; i < 10; i++) {
if ((i == 2 || i == 5) && date.charAt(i) == '.') continue;
if (Character.isDigit(date.charAt(i))) continue;
return;
}
this.day = Integer.parseInt(date.substring(0, 2));
this.month = Integer.parseInt(date.substring(3, 5));
this.year = Integer.parseInt(date.substring(6, 10));
}
public int getYear() {
return year;
}
public int getMonth() {
return month;
}
public int getDay() {
return day;
}
@Override
public String toString() {
return "Birthday{" + "day=" + day + ", month=" + month + ", year=" + year + '}';
}
@Override
public int compareTo(Object object) {
Birthday o = (Birthday) object;
if (this.day != o.getDay()) return Integer.compare(this.day, o.getDay());
if (this.month != o.getMonth()) return Integer.compare(this.month, o.getMonth());
return Integer.compare(this.year, o.getYear());
}
}

View File

@@ -0,0 +1,145 @@
package UE03_170924_Map_Birthdays;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.LocalDate;
import java.util.*;
public class BirthdayDatamining {
List<Birthday> birthdays;
public BirthdayDatamining(Path datei) {
if (datei == null) return;
List<Birthday> tempBirthdays = new ArrayList<>();
try {
for (String line : Files.readAllLines(datei)) {
while (line.length() >= 11) {
tempBirthdays.add(new Birthday(line.substring(0, 10)));
if (line.length() > 11) line = line.substring(11);
if (line.length() == 10) tempBirthdays.add(new Birthday(line.substring(0, 10)));
}
}
} catch (IOException e) {
return;
}
birthdays = new ArrayList<>(tempBirthdays);
}
public static String formatedDate(int date) {
return date < 10 ? "0" + date : String.valueOf(date);
}
public double arithmeticMiddle() {
double output = 0;
for (Birthday birthday : birthdays) output += birthday.getYear();
return output / birthdays.size();
}
public int mostCommonYear() {
int mostCommonYear = 0;
int counter = 0;
Map<Integer, Integer> statistic = new HashMap<>();
for (Birthday birthday : birthdays)
statistic.put(birthday.getYear(), statistic.getOrDefault(birthday.getYear(), 0) + 1);
// int happen = 0;
for (Map.Entry<Integer, Integer> entry : statistic.entrySet())
if (entry.getValue() > counter) {
counter = entry.getValue();
mostCommonYear = entry.getKey();
// happen = counter;
}
// System.out.println(happen);
return mostCommonYear;
}
public Map<Integer, Integer> birthdaysPerMonth() {
Map<Integer, Integer> statistic = new TreeMap<>();
for (Birthday birthday : birthdays)
statistic.put(birthday.getMonth(), statistic.getOrDefault(birthday.getMonth(), 0) + 1);
return statistic;
}
public int birthdaysOnDate(int day, int month) {
int counter = 0;
for (Birthday birthday : birthdays)
if (birthday.getDay() == day && birthday.getMonth() == month) counter++;
return counter;
}
public int leapYear() {
int counter = 0;
for (Birthday birthday : birthdays)
if ((birthday.getYear() % 4 == 0 && birthday.getYear() % 100 != 0) || (birthday.getYear() % 400 == 0))
counter++;
return counter;
}
public Birthday youngestBirthday() {
LocalDate latestDate = LocalDate.MIN;
for (Birthday birthday : birthdays) {
LocalDate currentDate;
try {
currentDate = LocalDate.of(birthday.getYear(), birthday.getMonth(), birthday.getDay());
} catch (Exception e) {
System.out.println("Fehlerhaftes Datum.");
return new Birthday("00.00.0000");
}
if (currentDate.isAfter(latestDate)) latestDate = currentDate;
}
return new Birthday(formatedDate(latestDate.getDayOfMonth()) + '.' + formatedDate(latestDate.getMonthValue()) + '.' + latestDate.getYear());
}
public Birthday oldestBirthday() {
LocalDate latestDate = LocalDate.MAX;
for (Birthday birthday : birthdays) {
LocalDate currentDate;
try {
currentDate = LocalDate.of(birthday.getYear(), birthday.getMonth(), birthday.getDay());
} catch (Exception e) {
System.out.println("Fehlerhaftes Datum.");
return new Birthday("00.00.0000");
}
if (currentDate.isBefore(latestDate)) latestDate = currentDate;
}
return new Birthday(formatedDate(latestDate.getDayOfMonth()) + '.' + formatedDate(latestDate.getMonthValue()) + '.' + latestDate.getYear());
}
public int youngestTeacherYear() {
Set<Integer> birthdayYear = new TreeSet<>();
for (Birthday birthday : birthdays) birthdayYear.add(birthday.getYear());
List<Integer> years = new ArrayList<>(birthdayYear);
for (int i = 1; i < years.size(); i++)
if (years.get(i - 1) + 4 <= years.get(i)) return years.get(i - 1);
return 0;
}
public int howManyTeacher() {
int output = 0;
for (Birthday birthday : birthdays) if (birthday.getYear() <= youngestTeacherYear()) output++;
return output;
}
public List<Birthday> teacherList() {
List<Birthday> teacherList = new ArrayList<>();
for (Birthday birthday : birthdays) if (birthday.getYear() <= youngestTeacherYear()) teacherList.add(birthday);
return teacherList;
}
public List<Birthday> studentList() {
List<Birthday> studentList = new ArrayList<>();
for (Birthday birthday : birthdays) if (birthday.getYear() > youngestTeacherYear()) studentList.add(birthday);
return studentList;
}
public int sameBirthday() {
Map<Birthday, Integer> birthdayCounter = new TreeMap<>();
for (Birthday birthday : birthdays) {
Birthday date = new Birthday(formatedDate(birthday.getDay()) + "." + formatedDate(birthday.getMonth()) + ".2000");
birthdayCounter.put(date, birthdayCounter.getOrDefault(date, 0) + 1);
}
// for (Map.Entry<Birthday, Integer> entry : birthdayCounter.entrySet()) if (entry.getValue() > 1) counter += entry.getValue();
// return counter;
return birthdayCounter.values().stream().filter(v -> v > 1).mapToInt(Integer::intValue).sum(); //Alternative (erstellt von ChatGPT) original darüber.
}
}

View File

@@ -0,0 +1,64 @@
package UE03_170924_Map_Birthdays;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
public class UE03_Birthdays {
public static void main(String[] args) {
Path datei = Path.of("src/UE03_170924_Map_Birthdays/birthdays.txt");
BirthdayDatamining birthdayDatamining = new BirthdayDatamining(datei);
System.out.println("In \"HelloWorld!2\" sind folgende Zeichen" + new HashMap<>(zeichenStatistik("HelloWorld!2")));
System.out.println("In der Datei \"birthdays.txt\" sind folgende Zeichen" + new HashMap<>(zeichenStatistik(datei)));
testBirthday();
System.out.println("Der Mittelwert ist: " + birthdayDatamining.arithmeticMiddle());
System.out.println("Das häufigste Jahr ist: " + birthdayDatamining.mostCommonYear());
System.out.println("Anzahl Geburtstage pro Monat" + birthdayDatamining.birthdaysPerMonth());
System.out.println("Am 22. Mai haben " + birthdayDatamining.birthdaysOnDate(22, 5) + " Geburtstag");
System.out.println("Am 24. Dezember haben " + birthdayDatamining.birthdaysOnDate(24, 12) + " Geburtstag");
System.out.println("In einem Schaltjahr geboren: " + birthdayDatamining.leapYear());
System.out.println("Der Jüngste hat Geburtstag am: " + birthdayDatamining.youngestBirthday());
System.out.println("Der Älteste hat Geburtstag am: " + birthdayDatamining.oldestBirthday());
System.out.println("Geburtstag des jüngsten Lehrers: " + birthdayDatamining.youngestTeacherYear());
System.out.println("Es gibt " + birthdayDatamining.howManyTeacher() + " Lehrer");
System.out.println("Der erste und Letzte Lehrer-Geburtstag ist: " + birthdayDatamining.teacherList().getFirst() + ", " + birthdayDatamining.teacherList().getLast());
System.out.println("Der erste und Letzte Schüler-Geburtstag ist: " + birthdayDatamining.studentList().getFirst() + ", " + birthdayDatamining.studentList().getLast());
System.out.println("Anzahl der Personen die sich einen Geburtstag teilen: " + birthdayDatamining.sameBirthday());
}
public static Map<Character, Double> zeichenStatistik(String text) {
if (text == null) return new HashMap<>();
Map<Character, Double> statistic = new HashMap<>();
for (char letter : text.toCharArray()) statistic.put(letter, statistic.getOrDefault(letter, 0.0) + 1);
return statistic;
}
public static Map<Character, Double> zeichenStatistik(Path datei) {
if (datei == null) return new HashMap<>();
Map<Character, Double> statistic = new HashMap<>();
try {
for (String line : Files.readAllLines(datei))
for (char letter : line.toCharArray()) statistic.put(letter, statistic.getOrDefault(letter, 0.0) + 1);
} catch (IOException e) {
return new HashMap<>();
}
return statistic;
}
public static void testBirthday() {
Set<Birthday> test = new TreeSet<>();
Birthday test0 = new Birthday("01.02.3000");
Birthday test1 = new Birthday("02.02.3000");
Birthday test2 = new Birthday("02.02.3000");
Birthday test3 = new Birthday("01.02.4000");
test.add(test0);
test.add(test1);
test.add(test2);
test.add(test3);
System.out.println("Test von Sortieren: " + test);
}
}

View File

@@ -0,0 +1,162 @@
05.07.1997,07.05.1999,11.10.1998,25.08.1999,04.05.1996,03.06.1993,28.01.1997,27.09.1997
28.07.1999,27.12.1997,14.04.1998,31.05.1961,19.12.1997,04.05.1995,15.03.1996,27.01.1997
21.04.1996,19.11.1996,04.07.1974,29.05.1995,01.10.1998,25.07.1996,11.05.1995,26.01.1998
14.04.1995,13.05.1996,30.05.1995,18.04.1995,19.06.1996,18.08.1998,20.04.1998,09.05.1997
09.08.1994,21.04.1996,12.10.1998,13.09.1994,25.05.1993,14.10.1996,16.01.1998,11.05.1998
25.01.1995,23.10.1995,27.12.1993,30.07.1997,04.02.1996,07.05.1998,20.10.1995,01.05.1996
28.05.1999,13.11.1994,25.11.1996,10.02.1997,30.10.1998,07.04.1998,05.12.1952,29.08.1996
18.07.1995,01.10.1997,25.04.1994,11.01.1997,23.04.1997,31.07.1999,18.02.1998,05.11.1998
17.02.1978,07.01.1999,25.11.1996,03.04.1999,30.01.1997,13.01.1998,30.04.1999,04.11.1997
22.12.1998,11.09.1992,18.01.1997,02.09.1996,01.04.1998,18.02.1999,08.04.1999,19.09.1996
28.03.1999,17.05.1998,26.12.1995,03.03.1971,05.04.1995,07.05.1996,31.07.1997,22.10.1995
01.07.1998,14.01.1995,15.06.1996,11.07.1966,05.08.1999,17.01.1997,27.01.1996,15.06.1998
18.09.1996,30.10.1995,09.09.1998,15.06.1997,08.07.1963,25.12.1994,26.08.1995,14.08.1995
21.01.1996,25.05.1996,22.08.1995,05.03.1995,16.01.1995,19.10.1965,03.08.1999,15.01.1995
12.04.1996,23.02.1997,19.08.1998,26.11.1994,26.10.1997,09.05.1994,10.10.1993,28.07.1997
10.05.1995,24.05.1995,27.11.1996,25.11.1997,29.11.1998,19.12.1997,04.07.1967,03.11.1998
12.11.1998,07.11.1997,03.09.1994,15.04.1996,12.04.1996,06.01.1995,14.05.1998,14.10.1994
20.01.1999,10.02.1995,30.01.1998,06.02.1996,04.04.1998,26.12.1994,11.02.1996,06.05.1998
01.05.1997,17.08.1997,14.10.1994,06.03.1968,25.02.1998,11.05.1994,11.05.1999,11.02.1998
02.06.1995,12.04.1997,28.10.1998,02.09.1998,19.03.1998,29.07.1998,31.10.1996,08.05.1999
24.08.1998,29.01.1999,22.03.1999,20.06.1997,04.10.1994,20.02.1997,11.05.1998,09.05.1996
17.03.1999,26.01.1995,07.09.1996,25.08.1997,14.02.1996,29.05.1999,27.11.1998,18.06.1995
17.06.1995,26.01.1998,03.01.1999,23.09.1996,16.10.1996,12.02.1996,23.07.1999,22.04.1996
19.12.1998,14.05.1995,18.12.1997,06.06.1994,11.04.1996,06.05.1999,28.12.1998,28.03.1997
05.02.1999,28.12.1995,18.05.1994,03.03.1996,21.10.1996,26.02.1997,01.10.1997,21.12.1996
24.02.1996,17.02.1999,06.03.1996,16.09.1995,27.04.1999,27.04.1997,03.03.1999,31.01.1999
13.08.1996,17.02.1974,09.03.1996,01.04.1995,22.04.1996,16.12.1963,11.12.1998,03.02.1998
13.03.1997,23.06.1997,09.08.1998,29.09.1996,08.07.1994,23.02.1997,24.08.1994,02.06.1998
18.02.1998,07.03.1996,06.10.1998,27.12.1998,16.04.1995,28.01.1998,07.09.1998,15.05.1994
27.07.1995,09.07.1999,18.06.1998,24.04.1998,29.04.1997,25.01.1998,14.09.1997,04.11.1996
24.07.1991,20.08.1997,01.04.1995,02.10.1994,10.04.1999,16.02.1996,23.01.1951,05.04.1999
13.02.1998,25.05.1952,04.04.1998,13.11.1970,18.11.1967,21.10.1995,04.10.1996,29.04.1999
09.05.1998,03.01.1998,10.08.1995,16.12.1995,21.02.1999,16.08.1997,18.09.1994,18.05.1997
31.10.1995,07.07.1995,14.07.1997,03.05.1997,02.01.1995,23.10.1995,01.06.1995,21.10.1997
14.03.1997,13.11.1997,31.12.1995,20.10.1996,30.04.1998,15.11.1995,18.03.1998,20.12.1996
30.03.1994,20.09.1997,10.04.1997,24.06.1997,11.05.1999,30.03.1994,30.03.1996,04.07.1994
20.07.1996,18.11.1996,04.12.1996,04.03.1996,17.12.1997,02.02.1996,10.05.1963,04.06.1968
30.11.1998,19.08.1996,14.09.1998,24.11.1998,03.12.1997,19.09.1997,13.01.1998,29.12.1997
13.12.1994,16.09.1997,24.04.1998,06.02.1999,14.03.1950,08.09.1994,24.10.1978,24.12.1998
01.11.1996,26.02.1996,07.08.1997,02.08.1996,27.05.1995,28.06.1999,24.09.1998,06.10.1987
27.11.1995,20.05.1997,29.05.1998,26.10.1979,24.03.1998,29.10.1995,25.09.1995,22.08.1996
18.05.1995,05.04.1995,28.01.1999,06.09.1997,12.02.1995,09.05.1995,29.06.1999,26.09.1951
22.11.1997,05.09.1996,29.01.1996,12.01.1995,28.02.1999,22.12.1997,13.05.1997,13.02.1997
09.06.1998,23.05.1999,18.04.1997,02.08.1956,27.02.1997,18.04.1973,30.12.1997,01.01.1998
23.11.1957,17.01.1998,14.03.1999,28.04.1995,19.10.1998,13.03.1995,30.09.1997,19.08.1998
15.11.1996,04.08.1969,12.08.1998,03.07.1997,11.06.1958,24.05.1995,19.05.1963,22.06.1999
22.07.1999,20.02.1996,23.10.1996,18.08.1975,30.06.1994,26.01.1996,25.11.1998,21.09.1996
31.12.1996,02.10.1995,20.01.1997,21.10.1997,16.02.1995,24.08.1994,18.01.1998,27.11.1996
01.05.1996,25.07.1966,30.10.1997,10.03.1999,26.11.1997,21.08.1997,26.06.1999,27.12.1993
02.09.1997,21.12.1994,14.12.1995,18.06.1999,21.07.1997,06.12.1981,02.08.1955,28.07.1998
29.10.1997,20.04.1998,14.02.1997,08.05.1998,15.10.1996,22.08.1997,24.04.1992,16.04.1999
23.01.1995,06.11.1998,22.11.1995,28.01.1997,17.09.1999,07.10.1998,08.05.1996,23.09.1992
21.06.1996,02.07.1994,05.09.1995,09.03.1996,08.04.1995,27.06.1996,22.05.1966,11.09.1997
01.02.1999,22.08.1998,21.05.1993,13.02.1998,22.02.1999,19.09.1996,09.02.1998,30.07.1996
21.03.1999,04.09.1994,19.12.1995,21.04.1999,27.01.1996,23.01.1998,26.09.1998,31.05.1995
22.05.1999,13.06.1997,16.04.1995,08.02.1996,04.04.1997,02.09.1996,27.01.1995,19.11.1996
12.05.1994,04.04.1997,13.05.1996,12.08.1998,20.03.1957,04.01.1995,12.02.1998,05.06.1997
12.01.1994,29.03.1999,16.02.1999,21.04.1998,19.11.1997,17.02.1996,27.05.1997,12.07.1997
28.08.1996,20.02.1997,19.08.1996,19.06.1995,29.02.1996,22.02.1999,01.02.1997,17.01.1997
16.11.1994,22.12.1994,12.10.1972,12.02.1998,29.04.1994,11.10.1995,18.04.1971,12.09.1997
16.06.1999,03.07.1998,19.07.1994,16.07.1994,06.03.1995,20.04.1999,26.07.1999,29.06.1994
07.04.1995,07.05.1997,16.06.1998,01.11.1977,11.05.1960,17.08.1998,30.09.1996,07.08.1998
20.09.1995,23.04.1996,23.08.1996,01.11.1997,12.03.1999,09.01.1998,27.09.1997,21.08.1999
30.07.1999,14.10.1996,01.01.1995,17.03.1981,18.11.1995,25.05.1999,22.12.1993,01.12.1995
07.10.1998,20.10.1965,09.06.1995,13.05.1996,08.08.1996,29.02.1996,25.03.1997,07.11.1996
12.12.1996,18.11.1997,26.09.1994,12.05.1998,19.12.1997,10.09.1997,14.08.1996,09.01.1997
12.09.1962,08.07.1998,11.06.1997,16.03.1995,11.12.1996,29.04.1997,11.04.1996,07.01.1996
21.05.1998,02.04.1997,12.08.1995,25.06.1996,31.01.1995,18.03.1999,25.02.1997,12.06.1993
06.09.1997,04.10.1998,02.02.1967,04.10.1998,07.10.1998,29.09.1996,07.11.1994,15.01.1995
21.08.1999,05.08.1999,07.10.1994,18.10.1999,05.07.1995,20.11.1998,01.08.1991,09.02.1997
25.06.1996,05.11.1996,12.05.1999,06.03.1969,08.03.1996,21.05.1997,11.08.1995,09.06.1995
12.07.1995,12.06.1997,20.02.1997,07.08.1996,25.03.1998,02.12.1994,18.04.1997,16.02.1995
06.03.1999,21.12.1995,18.02.1998,13.10.1997,11.06.1997,04.11.1994,18.11.1995,31.10.1998
06.06.1997,19.01.1996,25.06.1997,05.06.1998,13.02.1999,12.04.1999,04.02.1997,08.09.1998
28.03.1995,08.07.1998,26.08.1996,01.11.1998,02.11.1993,19.03.1995,14.04.1998,06.10.1998
19.05.1995,16.03.1998,17.09.1996,02.04.1996,23.07.1964,16.06.1994,16.02.1996,21.07.1964
07.10.1994,01.11.1994,13.01.1999,08.11.1996,28.11.1996,02.06.1996,07.01.1999,11.02.1998
20.02.1997,22.05.1999,18.01.1995,10.08.1999,10.02.1969,28.07.1997,22.06.1968,30.07.1993
01.06.1997,24.01.1999,11.12.1997,09.06.1995,07.03.1997,08.06.1995,15.02.1997,04.05.1995
03.11.1998,20.03.1997,17.04.1995,13.10.1997,08.03.1996,22.10.1995,14.09.1996,10.10.1972
08.03.1999,15.07.1997,21.03.1995,20.01.1999,04.07.1998,08.02.1998,15.11.1998,05.01.1996
14.02.1996,11.09.1996,25.04.1997,05.01.1999,22.04.1998,21.10.1995,09.09.1999,24.08.1999
14.10.1996,05.05.1997,19.04.1996,28.03.1998,13.06.1995,15.10.1996,22.02.1999,14.03.1998
05.02.1956,03.02.1998,13.11.1996,17.12.1996,01.08.1991,26.08.1998,21.02.1999,06.01.1999
04.06.1997,01.12.1973,02.02.1997,06.11.1998,14.06.1995,26.05.1996,30.04.1996,23.01.1999
19.09.1996,20.10.1960,11.11.1994,09.10.1954,01.08.1997,11.10.1964,23.01.1969,07.09.1964
03.02.1998,20.07.1993,21.06.1951,07.12.1997,03.08.1998,23.03.1996,23.04.1963,09.05.1995
11.03.1997,28.01.1998,21.09.1994,06.05.1999,03.05.1994,03.01.1996,14.09.1997,31.12.1994
18.11.1963,12.03.1999,20.09.1998,16.11.1997,05.09.1996,08.08.1998,04.05.1996,13.08.1996
14.12.1994,19.09.1996,16.08.1998,01.01.1998,14.11.1996,27.12.1996,20.06.1993,14.12.1997
10.03.1995,20.12.1998,16.09.1998,14.11.1997,20.09.1997,12.05.1995,02.10.1995,07.10.1974
05.12.1996,17.09.1994,20.07.1997,10.08.1998,25.10.1996,21.04.1996,22.09.1994,23.09.1994
11.08.1996,05.10.1995,29.01.1995,05.09.1994,15.04.1999,04.07.1998,16.01.1996,24.10.1996
31.07.1994,10.02.1996,08.06.1996,18.10.1998,30.06.1995,08.08.1996,19.02.1995,21.01.1998
07.12.1998,11.01.1996,05.06.1994,23.10.1995,31.08.1997,30.05.1965,03.08.1999,29.06.1997
16.12.1998,07.04.1995,22.10.1997,12.08.1997,13.09.1998,28.02.1965,17.12.1997,15.02.1998
16.07.1994,23.08.1998,03.08.1995,24.10.1982,23.05.1998,07.12.1996,01.04.1998,25.12.1993
15.01.1999,28.04.1998,04.02.1999,24.12.1997,14.07.1994,03.10.1994,08.02.1997,12.02.1994
18.02.1994,01.12.1998,02.05.1996,27.11.1996,19.11.1994,27.01.1996,09.10.1998,14.12.1996
26.08.1996,11.10.1970,07.06.1975,14.09.1997,12.07.1994,17.03.1995,06.12.1996,15.04.1996
17.02.1972,03.03.1999,16.01.1997,16.04.1998,18.11.1993,25.09.1998,29.05.1998,03.06.1998
27.03.1996,12.06.1994,07.09.1996,25.07.1997,04.04.1999,29.11.1995,06.09.1977,13.11.1998
13.09.1997,14.08.1994,20.10.1996,10.10.1995,22.03.1996,14.09.1970,13.06.1996,20.04.1996
09.11.1995,07.02.1996,15.12.1997,27.09.1998,26.01.1999,04.01.1996,13.05.1971,24.09.1997
31.03.1999,22.06.1996,04.01.1997,02.03.1992,05.11.1994,03.05.1974,30.08.1978,04.03.1996
21.10.1994,26.06.1998,26.12.1994,06.03.1999,01.01.1995,11.04.1974,10.07.1973,28.06.1997
05.01.1995,09.04.1992,20.07.1995,28.03.1969,08.05.1999,25.11.1954,30.03.1998,05.03.1998
29.08.1999,24.11.1995,02.11.1996,01.07.1996,09.11.1960,25.07.1996,22.04.1997,25.04.1995
18.03.1996,19.07.1999,13.02.1996,11.01.1968,24.11.1995,08.07.1998,29.05.1996,22.08.1998
09.07.1998,23.01.1998,22.04.1995,05.09.1997,16.04.1999,11.02.1997,15.09.1999,24.11.1995
28.01.1995,17.05.1958,25.05.1999,28.02.1998,08.11.1995,18.11.1995,10.08.1995,23.04.1995
05.12.1993,31.01.1998,06.05.1998,22.08.1997,06.05.1995,27.10.1962,10.06.1999,17.10.1997
04.10.1996,17.10.1995,05.04.1997,02.10.1994,17.01.1997,16.08.1996,08.09.1997,08.01.1997
23.05.1994,28.08.1996,21.11.1994,21.02.1995,11.02.1971,01.10.1997,17.05.1959,26.11.1997
21.09.1999,16.11.1996,13.07.1996,05.08.1998,12.02.1999,30.10.1997,04.06.1996,10.08.1996
07.09.1999,06.10.1994,06.08.1998,12.03.1997,09.10.1995,13.09.1980,25.08.1996,09.06.1997
07.02.1996,11.01.1996,18.06.1998,28.10.1999,24.10.1994,19.06.1996,13.12.1995,16.10.1997
20.02.1995,05.07.1996,16.12.1995,11.02.1998,08.01.1996,23.01.1997,02.11.1998,31.08.1995
28.11.1996,26.11.1998,04.01.1996,10.03.1999,15.05.1995,16.10.1996,14.04.1969,06.05.1998
27.12.1995,20.08.1994,06.08.1966,28.07.1995,09.09.1993,09.08.1995,14.05.1998,26.09.1997
16.06.1953,28.05.1997,22.10.1998,15.07.1999,12.02.1997,09.07.1997,01.10.1997,02.09.1994
13.08.1996,19.12.1996,21.03.1999,17.12.1994,03.08.1995,12.04.1997,06.08.1996,29.11.1998
16.05.1959,23.10.1996,20.10.1993,21.01.1996,20.02.1995,21.08.1998,20.11.1995,24.02.1995
30.07.1995,20.03.1996,16.03.1999,15.10.1997,12.11.1996,21.02.1997,08.01.1996,14.07.1964
10.07.1997,14.08.1968,11.12.1997,09.10.1985,15.09.1980,08.04.1996,20.10.1995,01.01.1992
22.06.1997,15.11.1997,11.11.1987,23.03.1999,06.06.1995,07.01.1997,11.02.1997,04.12.1996
18.06.1999,19.02.1995,03.11.1999,18.08.1996,09.07.1998,31.01.1999,21.08.1999,02.10.1974
23.11.1973,25.08.1998,22.01.1995,19.10.1998,06.03.1997,06.12.1997,15.09.1995,06.09.1998
29.11.1994,09.05.1995,13.10.1998,03.08.1996,27.07.1975,11.01.1995,11.10.1995,11.01.1995
17.05.1966,06.05.1996,18.09.1996,18.04.1998,29.10.1965,14.06.1996,24.01.1995,29.09.1995
19.11.1996,31.10.1995,17.04.1998,08.09.1995,10.07.1993,17.08.1997,23.05.1996,11.12.1966
26.11.1995,28.10.1996,11.10.1994,28.04.1996,24.12.1957,27.11.1998,12.12.1998,01.03.1999
30.12.1997,17.06.1999,15.09.1998,05.02.1995,31.03.1999,18.10.1994,28.11.1994,09.01.1995
03.07.1997,23.08.1996,07.07.1998,20.01.1998,12.06.1963,11.08.1994,01.10.1998,16.03.1966
05.07.1997,15.10.1996,07.10.1994,04.06.1997,02.12.1963,28.12.1996,12.01.1997,01.04.1994
04.02.1997,29.10.1998,12.03.1994,29.12.1996,26.09.1958,25.05.1995,09.08.1999,21.05.1999
22.07.1996,13.08.1997,28.03.1996,18.09.1994,05.09.1996,28.09.1995,18.09.1997,08.08.1996
18.11.1998,05.12.1997,09.07.1997,28.06.1995,14.05.1956,19.02.1996,17.04.1999,10.10.1997
07.10.1995,17.09.1994,04.08.1996,08.04.1968,15.03.1996,24.02.1999,05.02.1995,16.01.1995
02.10.1994,01.06.1999,04.09.1993,07.07.1998,06.12.1997,21.10.1985,17.11.1994,19.04.1982
22.09.1996,09.12.1996,13.09.1995,14.07.1995,18.11.1997,09.10.1997,28.05.1961,11.09.1997
21.02.1997,30.12.1998,20.12.1995,27.07.1996,30.07.1995,11.02.1997,03.05.1997,02.02.1997
27.07.1999,14.01.1999,01.01.1999,17.06.1956,02.08.1997,11.09.1955,14.07.1993,20.10.1973
16.05.1995,30.01.1999,25.05.1995,13.07.1999,16.12.1998,18.12.1997,12.08.1999,05.11.1996
28.12.1998,20.11.1998,27.07.1997,18.01.1999,11.01.1999,02.09.1993,12.01.1999,09.08.1998
05.06.1998,21.09.1997,01.12.1997,14.05.1998,04.05.1995,01.09.1998,23.01.1998,15.06.1968
20.12.1998,17.12.1997,08.05.1961,28.12.1995,25.06.1997,21.11.1996,14.03.1992,19.04.1997
20.03.1997,20.01.1999,03.04.1997,16.08.1998,09.04.1996,01.11.1998,30.08.1999,30.07.1997
12.12.1998,06.07.1995,13.05.1997,05.07.1998,04.03.1996,27.06.1998,21.12.1994,12.02.1995
14.06.1999,21.05.1997,16.05.1995,25.04.1998,28.08.1998,22.11.1969,17.06.1999,18.12.1996
14.07.1997,08.09.1998,19.09.1995,05.09.1996,04.08.1997,15.10.1994,01.10.1968,12.03.1997
21.06.1967,16.11.1994,11.07.1956,10.03.1999,02.04.1994,26.08.1996,01.10.1993,07.02.1997
23.01.1996,04.09.1996,14.09.1998,20.09.1958,19.01.1996,12.01.1999,26.05.1999,03.09.1996
16.02.1995,14.10.1994,14.03.1999,11.11.1995,19.04.1995,28.11.1997,29.03.1996,08.05.1996
10.06.1955,05.01.1996,22.03.1996,04.07.1995,03.03.1997,08.03.1999,24.01.1971,07.11.1997
05.03.1997,14.06.1973,20.12.1995,11.11.1995,04.05.1995,13.07.1995,10.07.1997,21.10.1996
19.04.1997,09.09.1958,21.01.1997,17.12.1995,13.01.1995,25.12.1994,01.01.1999,01.09.1998
15.08.1998,26.12.1994,24.04.1995,22.09.1997,04.06.1958,09.10.1995,05.06.1998,27.12.1997
13.02.1996,30.12.1996,08.02.1996,18.02.1995,03.09.1998,11.12.1994,07.02.1997,17.05.1996
16.02.1997,01.05.1996,02.03.1998,11.04.1996,19.01.1995,15.11.1994,07.07.1998,02.05.1998
17.07.1998,10.05.1995,08.08.1995,18.06.1968,19.07.1997,15.12.1994,20.04.1958,24.01.1998
25.08.1995,06.10.1995,12.05.1996,14.06.1996,01.02.1998,09.11.1998,19.12.1997,26.04.1995

View File

@@ -0,0 +1,17 @@
13
ananas juice:Latin Lover,Carribean Dream,Malibu Barbados,Malibu Margarita
cachaca:Brazilian Sunrise,Latin Lover,Caipirinha,Caipifragola
carribean rum with coconut:Malibu Barbados,Malibu Margarita,Malibu Sunrise
cointreau:Margarita,Malibu Margarita
grenadine:Brazilian Sunrise,Tequila Sunrise,Carribean Dream,Malibu Sunrise
lemon juice:Brazilian Sunrise,Tequila Sunrise,Latin Lover,Carribean Dream,Malibu Margarita
lime juice:Latin Lover,Caipirinha,Caipifragola,Strawberry Daiquiri,Margarita,Malibu Margarita
orange juice:Brazilian Sunrise,Tequila Sunrise,Carribean Dream,Malibu Barbados,Malibu Sunrise
passion fruit nectar:Carribean Dream
rum:Strawberry Daiquiri,Carribean Dream
strawberry liqueur:Caipifragola,Strawberry Daiquiri
strawberry sirup:Caipifragola
tequila:Tequila Sunrise,Latin Lover,Margarita,Malibu Margarita
cachaca,lime juice,grenadine,lemon juice,orange juice,carribean rum with coconut

View File

@@ -0,0 +1,37 @@
package UE04_270924_Map_Cocktails;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*;
public class UE04_Cocktails {
public static void main(String[] args) {
System.out.println(readCocktails(Path.of("src/UE04_270924_Map_Cocktails/CocktailMix.txt")));
}
public static String readCocktails(Path path) {
Map<String, Set<String>> cocktails = new TreeMap<>();
List<String> lines;
try {
lines = Files.readAllLines(path);
} catch (IOException e) {
throw new RuntimeException(e);
}
if (lines.isEmpty()) throw new RuntimeException();
lines.removeIf(String::isEmpty);
String existingIngredients = lines.getLast();
lines.removeFirst();
lines.removeLast();
List<String> output = new ArrayList<>();
List<String> ingredients = new ArrayList<>(List.of(existingIngredients.split(",")));
ingredients.replaceAll(String::trim);
//Set<String> values = cocktails.getOrDefault(key.trim(), new TreeSet<>());values.add(line.split(":")[0].trim());cocktails.put(key.trim(), values);
for (String line : lines)
for (String key : line.split(":")[1].split(","))
cocktails.computeIfAbsent(key.trim(), _ -> new TreeSet<>()).add(line.split(":")[0].trim()); //Alternative from ChatGPT (original above)
for (Map.Entry<String, Set<String>> entry : cocktails.entrySet())
if (new HashSet<>(ingredients).containsAll(entry.getValue())) output.add(entry.getKey());
return output.toString().substring(1, output.toString().length() - 1);
}
}

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,87 @@
package UE05_031024_RegExp1;
import java.util.Arrays;
import java.util.regex.Pattern;
public class UE05_Main {
static Pattern iPv4 = Pattern.compile("^(?:\\d{1,3}\\.){3}\\d{1,3}$");
static Pattern iPv6 = Pattern.compile("^[a-fA-F\\d]{4}(?::[a-fA-F\\d]{4}){7}$");
static Pattern macAddr = Pattern.compile("^(?:[a-fA-F\\d]{2}-){5}[a-fA-F\\d]{2}$");
static Pattern classNames = Pattern.compile("^[A-Z]\\w*(?:\\.[A-Z]\\w*)*$");
static Pattern flightNr = Pattern.compile("^[A-Z]{2,3}\\d{2,4}$");
static Pattern floatNrs = Pattern.compile("^[+-]?\\d+(?:\\.?\\d+)?$");
static Pattern dates = Pattern.compile("^\\d{1,2}\\.\\d{1,2}(?:\\.(?:\\d{2}|\\d{4}))?$");
static Pattern emails = Pattern.compile("^[\\w-]*(?:\\.?[\\w-]+)*@[A-Za-z\\d-]{3,}\\.[A-Za-z]{2,}$");
static Pattern kfzPlattes = Pattern.compile("^[A-Z]{2}-(?=.{4,5}$)[1-9]\\d*[A-NPR-Z][A-PR-Z]*$|^[A-Z]-(?=.{5,6}$)[1-9]\\d*[A-NPR-Z][A-PR-Z]*$");
public static void main(String[] args) {
testRegEx();
System.out.println("\n");
Arrays.stream(new String[]{"192.168.1.1", "255.255.255.255", "0.0.0.0", "256.100.50.25", "192.168.1.256", "192.168.-1.1", "192.168.1", "192.168.1.a", "123.456.78.90", "192.168.01.1"}).forEach(ip -> System.out.printf("IP-Adresse: %s -> %b%n", ip, isIPv4(ip)));
System.out.println("\n");
Arrays.stream(new String[]{"00-1A-2B-3C-4D-5E", "00-1A-2B-3C-4D-5E", "00-1A-2B-3C-4D", "00-1A-2B-3C-4D-5E-6F", "G0-1A-2B-3C-4D-5E"}).forEach(mac -> System.out.printf("MAC-Adresse: %s -> %b%n", mac, isMacAddr(mac)));
System.out.println("\n");
Arrays.stream(new String[]{"3.14", "-3.14", "+3.14", "0.0", "42", "-42", "+42", "3.", ".5", "3.14.15", "abc", "1e10", "2.5e3"}).forEach(dez -> System.out.printf("Dezimalzahl: %s -> %b%n", dez, isDezimal(dez)));
System.out.println("\n");
Arrays.stream(new String[]{"7.11.2013", "7.11.13", "01.01.2020", "1.1.99", "31.12.2024", "31.02.2020", "32.01.2020", "7.11.201", "7.11", "7.13.2020", "abc.def.ghij"}).forEach(date -> System.out.printf("Datum: %s -> %b%n", date, isDate(date)));
System.out.println("\n");
Arrays.stream(new String[]{"KI-1AAA", "KI-99ZZZ", "KI-10AA", "KI-999ZZ", "KI-100A", "KI-9999Z", "W-10AAA", "W-999ZZZ", "W-100AA", "W-9999ZZ", "W-1000A", "W-99999Z"}).forEach(platte -> System.out.printf("Kennzeichen: %s -> %b%n", platte, isKFZ_Kennzeichen(platte)));
}
public static void testRegEx() {
System.out.println("\n" +
"01. IPv4: \t\t\t" + "192.168.12.0".matches(iPv4.pattern()) + "\n" +
"02. IPv4: \t\t\t" + "255.255.255.255".matches(iPv4.pattern()) + "\n\n" +
"01. IPv6: \t\t\t" + "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff".matches(iPv6.pattern()) + "\n" +
"02. IPv6: \t\t\t" + "abcd:ffff:1234:e5fc:12bf:5cf2:cabd:12cf".matches(iPv6.pattern()) + "\n\n" +
"01. MAC-Adress: \t" + "F1-CB-CF-E3-CA-45".matches(macAddr.pattern()) + "\n" +
"02. MAC-Adress: \t" + "FF-FF-FF-FF-FF-FF".matches(macAddr.pattern()) + "\n\n" +
"01. Class names: \t" + "Regex_Main".matches(classNames.pattern()) + "\n" +
"02. Class names: \t" + "Map.Entry".matches(classNames.pattern()) + "\n\n" +
"01. Flight Number: \t" + "AUS1234".matches(flightNr.pattern()) + "\n" +
"02. Flight Number: \t" + "SAS69".matches(flightNr.pattern()) + "\n\n" +
"01. Numbers: \t\t" + "3.1415926589".matches(floatNrs.pattern()) + "\n" +
"02. Numbers: \t\t" + String.format("%f", Math.E).matches(floatNrs.pattern()) + "\n" +
"03. Numbers: \t\t" + "235".matches(floatNrs.pattern()) + "\n\n" +
"01. Dates: \t\t\t" + "25.12.1969".matches(dates.pattern()) + "\n" +
"02. Dates: \t\t\t" + "11.12.07".matches(dates.pattern()) + "\n\n" +
"01. Emails: \t\t" + "mail@provider.com".matches(emails.pattern()) + "\n" +
"02. Emails: \t\t" + "sew@gmail.com".matches(emails.pattern()) + "\n\n" +
"01. Kennzeichen: \t" + "KI-1AAA".matches(kfzPlattes.pattern()) + "\n" +
"02. Kennzeichen: \t" + "KI-99ZZZ".matches(kfzPlattes.pattern())
);
}
public static boolean isIPv4(String value) {
if (!value.matches(iPv4.pattern())) return false;
return Arrays.stream(value.split("\\.")).noneMatch(v -> Integer.parseInt(v) > 255);
}
public static boolean isMacAddr(String value) {
return value.matches(macAddr.pattern());
}
public static boolean isDezimal(String value) {
return value.matches(floatNrs.pattern());
}
public static boolean isKFZ_Kennzeichen(String value) {
return value.matches(kfzPlattes.pattern());
}
public static boolean isDate(String value) {
if (!value.matches(dates.pattern())) return false;
String[] values = value.split("\\.");
return isValidDate(Integer.parseInt(values[0]), Integer.parseInt(values[1]));
}
public static boolean isValidDate(int d, int m) {
return (m <= 12 && m >= 1) && (d >= 1 && d <= lastDayInMonth(m));
}
public static int lastDayInMonth(int m) {
if (m == 2) return 28;
else if (m == 4 || m == 6 || m == 9 || m == 11) return 30;
return 31;
}
}

Binary file not shown.

View File

@@ -0,0 +1,103 @@
package UE06_151024_RegExp2;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class UE06_Main {
public static void main(String[] args) {
Path htmlDatei = Path.of("src/UE06_151024_RegExp2/index.html");
Path cssDatei = Path.of("src/UE06_151024_RegExp2/styles.css");
System.out.println(tagStatistik(htmlDatei));
System.out.println(links(htmlDatei));
System.out.println(domains(htmlDatei));
System.out.println(klassen(cssDatei));
System.out.println(removeMultipleSpaces("Hallo Du kek !"));
System.out.println(bigStartingLetter("Hallo du kek !"));
System.out.println(lineSplitting("Es war einmal ein Lehrer namens Herr Klein, der in einem kleinen Dorf am Rande eines großen, dichten Waldes lebte. Aber Herr Klein war kein gewöhnlicher Lehrer. Während die meisten Lehrer Lesen, Schreiben und Rechnen unterrichteten, hatte Herr Klein eine ganz besondere Leidenschaft: das Programmieren. Seine Augen leuchteten jedes Mal auf, wenn er über Code sprach, und er konnte Stunden damit verbringen, knifflige Probleme zu lösen.\n" + "\n" + "Herr Klein war bekannt für seine Geduld und sein freundliches Wesen. Die Dorfbewohner liebten ihn, denn er brachte den Kindern bei, wie man Programme schreibt, die die Welt verbessern konnten. Die Kinder nannten ihn liebevoll \"den Magier des Codes\", denn er zauberte scheinbar mit Zahlen und Buchstaben, um unglaubliche Dinge zu erschaffen.\n" + "\n" + "Eines Tages hörte Herr Klein von einer alten Legende, die in seinem Dorf seit Generationen erzählt wurde. Tief im Herzen des Waldes sollte es einen magischen Code geben, den niemand je vollständig entschlüsselt hatte. Dieser Code, so hieß es, hatte die Macht, jede Frage der Welt zu beantworten, jedes Problem zu lösen und jede Vision wahr werden zu lassen. Doch er war verschlüsselt und versteckt in einer uralten Höhle, die nur denjenigen zugänglich war, die das Herz eines wahren Programmierers hatten.\n" + "\n" + "Fasziniert von dieser Legende beschloss Herr Klein, sich auf die Suche nach dem magischen Code zu machen. Er packte seinen Laptop, sein Lieblingsbuch über Algorithmen und machte sich auf den Weg in den dichten Wald. Der Weg war lang und voller Herausforderungen. Rätselhafte Pfade, die sich ständig veränderten, zwangen Herrn Klein dazu, seinen Verstand zu nutzen und clevere Algorithmen zu entwickeln, um die richtige Richtung zu finden. Manchmal musste er Code schreiben, um Brücken über tiefe Schluchten zu bauen oder wilde Tiere zu beruhigen, indem er für sie kleine Spiele programmierte.\n" + "\n" + "Nach vielen Tagen erreichte er endlich die alte Höhle. Ihre Wände waren mit uralten Runen bedeckt, die wie Programmzeilen wirkten. Herr Klein erkannte sofort, dass dies der magische Code war. Doch es war ein Rätsel, so komplex, dass es Jahrhunderte dauern würde, es von Hand zu lösen. Aber Herr Klein war nicht entmutigt. Er setzte sich hin, öffnete seinen Laptop und begann, den Code zu analysieren.\n" + "\n" + "Stunden wurden zu Tagen, und Tage wurden zu Wochen. Aber Herr Klein gab nicht auf. Schließlich, nach einem letzten tiefen Atemzug, schrieb er die letzte Zeile Code, die den magischen Code entsperrte. Mit einem leisen Klicken öffnete sich die Höhle, und eine leuchtende Kugel schwebte in die Luft. Aus ihr heraus hörte Herr Klein eine sanfte, weise Stimme:\n" + "\n" + "\"Du hast bewiesen, dass du das Herz eines wahren Programmierers trägst. Der magische Code gehört nun dir. Nutze ihn weise, um Gutes in die Welt zu bringen.\"\n" + "\n" + "Doch Herr Klein, so sehr er auch von der Macht des Codes beeindruckt war, wusste, dass die wahre Magie nicht darin lag, alle Antworten zu kennen. Es war die Freude am Lernen, am Lösen von Problemen und am Teilen seines Wissens mit anderen. Also kehrte er ins Dorf zurück und lehrte weiterhin seine Schüler. Aber jetzt brachte er ihnen nicht nur das Programmieren bei er zeigte ihnen auch, wie man mit Geduld, Kreativität und einer Portion Mut selbst die kniffligsten Herausforderungen meistert.\n" + "\n" + "Und so lebte Herr Klein glücklich und zufrieden. Er fand Freude darin, seine Schüler zu inspirieren, und der magische Code ruhte sicher in seinem Herzen, bereit, nur dann genutzt zu werden, wenn es wirklich notwendig war. Und wenn die Dorfbewohner an seinen Fenstern vorbeigingen, konnten sie oft das leise Klicken seiner Tastatur hören, während Herr Klein weiter seine Leidenschaft verfolgte, eine Zeile Code nach der anderen.\n" + "\n" + "Und wenn er nicht gestorben ist, dann programmiert er noch heute."));
System.out.println(lineSplitting("hgkjhgsdhjgsjhfgshjfghjsgfhjgshjkghgfjhsghjfgsjhkgfjksgfhjgdhgdfjhgsdhjgfdhjsgdfhjdfghjksgjhsdghjsdfgdshjgfjhsdgfjhs sdhjfgsdhfsdjhkshfdsghjdghjsghjdfgjhsgfsgfhjsgdhjfgsjfgjhsgdfshjgfshjdgfhjsdgjhsgfjhsgdjfgsjhgfdhjsgjhgdfjsdfg jfhgshjsdfgjsdgfgsfghd dsgsdfj"));
}
public static Map<String, Double> tagStatistik(Path htmlDatei) {
Map<String, Double> statistik = new TreeMap<>();
int counter = 0;
try {
for (String line : Files.readAllLines(htmlDatei)) {
Matcher matcher = Pattern.compile("(?<=<)\\w+").matcher(line);
while (matcher.find()) {
statistik.put(matcher.group(), statistik.getOrDefault(matcher.group(), 0.0) + 1);
counter++;
}
}
} catch (IOException e) {
System.err.println("Error while reading/ analysing File!");
}
for (Map.Entry<String, Double> entry : statistik.entrySet())
statistik.put(entry.getKey(), entry.getValue() / counter);
return statistik;
}
public static Set<String> links(Path htmlDatei) {
Set<String> links = new HashSet<>();
try {
for (String line : Files.readAllLines(htmlDatei)) {
Matcher matcher = Pattern.compile("(?<=href=\")https?://[^\"]+").matcher(line);
while (matcher.find()) links.add(matcher.group());
}
} catch (IOException e) {
System.err.println("Error while reading/ analysing File!");
}
return links;
}
public static Set<String> domains(Path htmlDatei) {
Set<String> domains = new HashSet<>();
try {
Pattern pattern = Pattern.compile("(?<=href=\"https?://)(?:\\w+\\.)*([\\w-]+\\.[a-zA-Z]{2,})");
for (String line : Files.readAllLines(htmlDatei)) {
Matcher matcher = pattern.matcher(line);
while (matcher.find()) domains.add(matcher.group(1));
}
} catch (IOException e) {
System.err.println("Error while reading/ analysing File!");
}
return domains;
}
public static Set<String> klassen(Path cssDatei) {
Set<String> classes = new HashSet<>();
try {
Pattern pattern = Pattern.compile("(?<=\\.)[a-zA-Z]+[\\w-]*(?=.*\\{)");
for (String line : Files.readAllLines(cssDatei)) {
Matcher matcher = pattern.matcher(line);
while (matcher.find()) classes.add(matcher.group());
}
} catch (IOException e) {
System.err.println("Error while reading/ analysing File!");
}
return classes;
}
public static String removeMultipleSpaces(String string) {
return string.replaceAll(" +", " ");
}
public static String bigStartingLetter(String string) {
return Pattern.compile("\\b[a-z]").matcher(string).replaceAll(matchResult -> matchResult.group().toUpperCase());
}
public static String lineSplitting(String string) {
if (Pattern.compile("\\b\\w{41,}\\b").matcher(string).find())
throw new RuntimeException("A word with more than 40 letters was found!");
Matcher matcher = Pattern.compile(".{1,40}(?:\\s|$)").matcher(string.replaceAll("\n", " "));
StringBuilder output = new StringBuilder();
while (matcher.find()) output.append(matcher.group().trim()).append("\n");
return output.toString();
}
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,243 @@
*{transition: all 0.2s;margin: 0px;}
html{
scroll-behavior: smooth;
text-align: center;
font-family:'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
}
section{
display: flex;
flex-direction: column;
row-gap: 30px;
}
a{
text-decoration: none;
color: black;
}
p{
font-size: 20px;
}
h1{
font-size: 30px;
text-decoration: underline;
}
.mainNAV{
background-color: rgba(53, 53, 53, 0.833);
padding: 15px;
padding-bottom: 20px;
position: fixed;
top: 0;
left: 0;
width: 100%;
box-sizing: border-box;
z-index: 5;
}
.mainNAV > div{
display: flex;
max-width: 1000px;
margin: 0 auto;
}
.mainNAV > div{
margin-top: 15px;
}
.mainNAV > div a{
flex-grow: 1;
color: white;
margin: auto 15px;
font-size: 18px;
border: solid 2px rgb(128, 128, 128);
border-radius: 15px;
box-sizing: border-box;
background-image: url(../pictures/board.png);
background-color: rgba(48, 48, 48, 0.833);
background-size: 100%;
padding: 5px 0;
}
.mainNAV > div a:hover, .mainNAV img:hover{
cursor: pointer;
transform: scale(1.2);
}
.wellcome{
margin: 0 10px;
margin-top: 200px;
max-width: 800px;
align-self: center;
}
.toshop{
align-self: center;
}
.toshop:hover{
cursor: pointer;
transform: scale(1.2);
}
.toshop p{
margin-top: 15px;
font-size: 30px;
}
.toshop a{
display: flex;
flex-direction: column;
align-items: center;
padding: 25px 35px;
border-radius: 30px;
background-image: url(../pictures/board.png);
background-size: 100%;
text-decoration: none;
color: white;
}
.pizzabutton{
width: 150px;
height: auto;
position: relative;
animation: rotate 4s linear infinite;
}
@keyframes rotate {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.menu{
display: flex;
align-content: center;
flex-wrap: wrap;
align-items: center;
gap: 30px;
margin: 0 auto;
justify-content: center;
max-width: 1000px;
}
.menu li{
text-align: left;
}
.menu img{
width: 180px;
}
.menu > div{
box-sizing: border-box;
background-image: url(../pictures/menu.jpg);
background-size: 100%;
border-radius: 30px;
padding: 25px;
width: 300px;
height: 446px;
}
.menu > div:hover{
transform: scale(1.1);
}
.menu > div:hover > img{
animation: menuRotate 4s linear infinite;
}
@keyframes menuRotate {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.menu *{
color: white;
font-size: 25px;
}
.menu sup{
font-size: 20px;
}
.menu p{
margin: 15px 0;
font-weight: bold;
text-decoration: underline;
}
.aboutUS{
max-width: 800px;
margin: 0 auto;
}
.location {
background-color: #f8f8f8;
padding: 40px 0;
text-align: center;
}
.location h1 {
font-size: 28px;
margin-bottom: 20px;
color: #333;
}
.contact {
background-color: #fff;
padding: 40px 0;
text-align: center;
}
.contact h1 {
font-size: 28px;
margin-bottom: 20px;
color: #333;
}
.contact p {
font-size: 20px;
margin: 10px 0;
color: #555;
}
.allergene{
text-align: center;
}
.allergene h1{
font-size: 30px;
color: black;
}
table {
width: 60%;
margin: 20px auto;
border-collapse: collapse;
}
th, td {
padding: 10px;
text-align: center;
border: 1px solid darkgray;
}
th {
background-color: darkgray;
color: white;
}
tr:hover {
background-color: lightgray;
}
footer{
background-color: black;
color: white;
padding: 20px;
}
/*Small*/
@media (max-width: 600px) {
.mainNAV > div{
display: grid;
grid-template-columns: 1fr 1fr;
grid-auto-rows: 31px;
row-gap: 15px;
}
.WE{
grid-column: 1;
grid-row: 1;
}
.MU{
grid-column: 2;
grid-row: 1;
}
.AUS{
grid-column: 1;
grid-row: 2;
}
.LOC{
grid-column: 2;
grid-row: 2;
}
}
#wellcome, #menu, #aboutUS, #location {
scroll-margin-top: 170px;
}

Binary file not shown.

View File

@@ -0,0 +1,42 @@
package UE08_051124_Rekursion;
import javafx.application.Application;
import javafx.geometry.Point2D;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class Sierpinski_Dreieck extends Application {
static final int canvasWidth = 580;
static final int canvasHeight = 502;
static final int minSize = 10;
public static void main(String[] args) {
Application.launch(args);
}
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Sierpinski-Dreieck");
Canvas canvas = new Canvas(canvasWidth, canvasHeight);
primaryStage.setResizable(false);
primaryStage.setScene(new Scene(new BorderPane(canvas)));
primaryStage.show();
Point2D p1 = new Point2D(0, canvas.getHeight()), p2 = new Point2D(canvas.getWidth(), canvas.getHeight()), p3 = new Point2D(canvas.getWidth() / 2, 0);
drawSierpinskiTriangle(canvas.getGraphicsContext2D(), minSize, p1, p2, p3);
}
private void drawSierpinskiTriangle(GraphicsContext gc, int size, Point2D p1, Point2D p2, Point2D p3) {
if (p2.getX() - p1.getX() <= size) return;
gc.strokeLine(p1.getX(), p1.getY(), p2.getX(), p2.getY());
gc.strokeLine(p2.getX(), p2.getY(), p3.getX(), p3.getY());
gc.strokeLine(p1.getX(), p1.getY(), p3.getX(), p3.getY());
drawSierpinskiTriangle(gc, size, p1, p1.midpoint(p2), p1.midpoint(p3));
drawSierpinskiTriangle(gc, size, p1.midpoint(p2), p2, p2.midpoint(p3));
drawSierpinskiTriangle(gc, size, p1.midpoint(p3), p2.midpoint(p3), p3);
}
}

View File

@@ -0,0 +1,39 @@
package UE08_051124_Rekursion;
public class UE08_Rekursion {
public static void main(String[] args) {
printFibonacciFolge(8);
System.out.println(zaehleSelbstlaute("Hallo du MENSCH"));
System.out.println(zahlHoch(2, 5));
System.out.println(zahlHoch(2, 10));
System.out.println(zahlHoch(1, 1));
System.out.println(zahlHoch(1, 10));
System.out.println(zahlHoch(5, 5));
System.out.println(zahlHoch(20, 3));
System.out.println(zahlHoch(10, 1));
System.out.println(zahlHoch(10, 10));
}
public static int fibonacci(int n) {
return n <= 2 ? n <= 0 ? 0 : 1 : fibonacci(n - 1) + fibonacci(n - 2);
}
public static void printFibonacciFolge(int anz) {
for (int i = 1; i <= anz; i++) System.out.print(fibonacci(i) + " ");
}
public static int zaehleSelbstlaute(String s) {
// if (s.isEmpty()) return 0;
// if ("aeiouAEIOU".indexOf(s.charAt(0)) == -1) return 0;
// return 1 + zaehleSelbstlaute(s.substring(1));
return s.isEmpty() ? 0 : (("aeiouAEIOU".indexOf(s.charAt(0)) == -1) ? 0 : 1) + zaehleSelbstlaute(s.substring(1));
}
public static long zahlHoch(int x, int n) {
// if (n <= 1) return x;
// long z = zahlHoch(x, n >> 1);
// if ((n & 1) != 0) return x * z * z;
// return z * z;
return n <= 1 ? x : ((n & 1) != 0 ? x * zahlHoch(x, n >> 1) * zahlHoch(x, n >> 1) : zahlHoch(x, n >> 1) * zahlHoch(x, n >> 1));
}
}