Compare commits

...

26 Commits

Author SHA1 Message Date
352a9909ed Vorlesung 16 / Aufgabe 1 2024-06-11 14:47:57 +02:00
1f0c7abff6 some changes from practice group 2024-06-10 15:20:28 +02:00
e1eaf252de Vorlesung 15 / Aufgabe 1 2024-06-09 23:16:37 +02:00
b90a013f4c now using wait and notify 2024-06-03 22:04:50 +02:00
108cd3259e removed custom name for threads - using internal name instead 2024-05-30 11:37:17 +02:00
dad420e8d8 Vorlesung 14 / Aufgabe 1 2024-05-30 11:31:58 +02:00
c08f4d3196 Vorlesung 14 / Aufgabe 2 2024-05-30 11:27:24 +02:00
b96c8c7b21 removed extension Rainbow Brackets 2024-05-17 18:42:31 +02:00
9506ee39ed Vorlesung 8 / Aufgabe 3 2024-05-17 08:15:15 +02:00
ee2b5d5e1c Vorlesung 8 / Aufgabe 4 2024-05-16 16:32:58 +02:00
203e18ca10 added missing extension 2024-05-16 10:55:00 +02:00
2f0de3f778 improvements initializing arrays 2024-05-16 10:50:07 +02:00
8c527a98de small improvement and same values while running the tests 2024-05-16 10:47:47 +02:00
0b552e9d0f added README.md 2024-05-13 16:32:49 +02:00
a0a812406d small improvements 2024-05-13 16:05:20 +02:00
01bb3e9def Vorlesung 4 / Aufgabe 6 2024-05-13 16:04:59 +02:00
7e87a3bec2 Vorlesung 4 / Aufgabe 5 2024-05-13 16:04:41 +02:00
b1d4deb0e3 Vorlesung 4 / Aufgabe 4 2024-05-13 16:04:23 +02:00
bf7453a3de Vorlesung 4 / Aufgabe 3 2024-05-13 16:03:58 +02:00
cba4d08315 Vorlesung 3 / Aufgabe 4 2024-05-10 08:14:31 +02:00
4257cab1fa Vorlesung 3 / Aufgabe 3 2024-05-10 08:09:58 +02:00
d64c33dfe5 Vorlesung 3 / Aufgabe 2 2024-05-10 08:01:49 +02:00
dc781ca0bd Vorlesung 3 / Aufgabe 1 2024-05-09 15:16:52 +02:00
3e064693bf Vorlesung 5 / Aufgabe 2 2024-05-09 14:45:37 +02:00
7c8a682066 Vorlesung 4 / Aufgabe 2 2024-05-09 12:59:05 +02:00
98e7893343 Vorlesung 4 / Aufgabe 1 2024-05-09 12:58:50 +02:00
43 changed files with 1582 additions and 346 deletions

10
README.md Normal file
View File

@@ -0,0 +1,10 @@
# :chipmunk: VL-Programmieren
Lösungen zu den Aufgaben der Vorlesung "Programmieren" des ersten und zweiten Semesters.
## :hammer: Entwicklungsumgebung
- **Editor**: [Visual Studio Code](https://code.visualstudio.com/)
- [Extension Pack for Java](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack)
- [EditorConfig for VS Code](https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig)
- **Java**: [Java Development Kit 21 (LTS)](https://www.oracle.com/de/java/technologies/downloads/#java21)
- **Style Guide**: [Google Java Style Guide](https://github.com/google/styleguide/blob/gh-pages/eclipse-java-google-style.xml)

View File

@@ -1,5 +0,0 @@
class Aufgabe {
public static void main(String[] args) {
System.out.println("Hallo Welt");
}
}

View File

@@ -1,23 +0,0 @@
class Aufgabe {
public static void main(String[] args) {
// Die drei Zahlen für die Prüfung definieren.
int a = 3;
int b = 4;
int c = 5;
// Die Zahlen überprüfen und das Ergebnis ausgeben.
System.out.println("Werte entsprechen dem Satz des Pythagoras: " + (check(a,b,c) ? "Ja" : "Nein"));
}
/**
* Prüfen ob die angegebenen Zahlen dem Satz des Pythagoras entsprechen.
* @param a Die erste Zahl (a).
* @param b Die zweite Zahl (b).
* @param c Das Ergebnis (c).
* @return Status ob die angegebenen Zahlen dem Satz des Pythagoras entsprechen.
*/
public static boolean check(int a, int b, int c) {
return (a*a + b*b == c*c) ? true : false;
}
}

View File

@@ -1,25 +0,0 @@
class Aufgabe {
public static void main(String[] args) {
int i = 5;
int j = 3;
boolean b = false;
/*
* a.) (!((i<j) && b)) - boolean (true)
* b.) i/j - int (1)
* c.) (float) (i/j) - float (1.0)
* d.) (float) i/j - float (1.6)
* e.) (float) i / (float) j - float (1.6)
* f.) ((i++ == 5) || (--i == 5)) - boolean (true)
* g.) ((i++ == 5) | (--i == 5)) - int (1)
*/
System.out.println("a.) " + (!((i<j) && b)));
System.out.println("b.) " + (i/j));
System.out.println("c.) " + (float) (i/j));
System.out.println("d.) " + ((float) i/j));
System.out.println("e.) " + ((float) i / (float) j));
System.out.println("f.) " + (((i++ == 5) || (--i == 5))));
System.out.println("g.) " + (((i++ == 5) | (--i == 5))));
}
}

View File

@@ -1,21 +0,0 @@
class Aufgabe {
public static void main(String[] args) {
final int MAXIMUM = 10;
System.out.println("Alle geraden Zahlen zwischen 1 und " + MAXIMUM + " (aufsteigend):");
for(int i = 1; i <= MAXIMUM; i++) {
if(i % 2 == 0) {
System.out.println(i);
}
}
System.out.println("Alle ungeraden Zahlen zwischen 1 und " + MAXIMUM + " (absteigend):");
for(int i = MAXIMUM; i >= 1; i--) {
if(i % 2 == 1) {
System.out.println(i);
}
}
}
}

View File

@@ -1,38 +0,0 @@
class Aufgabe {
public static void main(String[] args) {
final int START = 1;
final int ENDE = 20;
int summe = 0;
int n = 0;
System.out.println("Lösung mit for-Schleife:");
for(n = START; n <= ENDE; n++) {
summe += n;
System.out.println(summe);
}
System.out.println("Lösung mit while-Schleife:");
summe = 0;
n = START;
while(n <= 20) {
summe += n;
System.out.println(summe);
n++;
}
System.out.println("Lösung mit do-while-Schleife:");
summe = 0;
n = START;
do {
summe += n;
System.out.println(summe);
n++;
} while (n <= ENDE);
}
}

View File

@@ -1,40 +0,0 @@
class Aufgabe {
public static void main(String[] args) {
final int MAXIMUM = 200;
int[] zahlenreihe = new int[MAXIMUM];
// Initialisieren der Zahlenreihe.
for(int i = 0; i < MAXIMUM; i++) {
zahlenreihe[i] = i + 1;
}
// Alle Basen durchlaufen.
for(int i = 0; i <= (MAXIMUM / 2); i++) {
int basis = zahlenreihe[i];
// Alle Basen und Zahlen kleiner als 2 können ignoriert werden.
// Zahlen kleiner als 2 sind keine Primzahlen.
// Eine Base welche keine Primzahl ist wird mit 0 überschrieben ("durchgestrichen").
if(basis < 2) {
continue;
}
// Alle Zahlen der Zahlenreihe durchlaufen um für die Basis passende Zahlen zu finden.
for(int j = i + 1; j < MAXIMUM; j++) {
int zahl = zahlenreihe[j];
// Es ist keine Primzahl wenn die Zahl durch die Basis teilbar ist.
if(zahl % basis == 0) {
zahlenreihe[j] = 0;
}
}
}
// In der Zahlenreihe sind jetzt nur noch Primzahlen vorhanden.
for(int i = 0; i < MAXIMUM; i++) {
if(zahlenreihe[i] >= 2) {
System.out.println(zahlenreihe[i]);
}
}
}
}

View File

@@ -1,32 +0,0 @@
class Aufgabe {
public static void main(String[] args) {
final int laufzeit = 10;
final double startwert = 100.0;
// Die verschiedenen Zinssätze definieren.
double zinssatz[] = {3.5, 4.5, 5.5};
// Es kann eine Matrix erstellt werden in welcher die Informationen für die Entwicklung gespeichert werden.
// Die Zeilen sind die Informationen der Jahre. Die Spalten sind die Entwicklung je nach Zinssatz.
double entwicklung[][] = new double[laufzeit][3];
// Für jedes Jahr muss die Entwicklung angepasst werden.
for(int i = 0; i < laufzeit; i++) {
for(int z = 0; z < zinssatz.length; z++) {
double wert = (i == 0) ? startwert : entwicklung[i-1][z];
entwicklung[i][z] = wert + (wert * (zinssatz[z] / 100.0));
}
}
// Die Parameter ausgeben damit die Grundlage der Entwicklung sichtbar ist.
System.out.printf("Laufzeit: %d Jahre - Startwert: %.2f EUR\n\n", laufzeit, startwert);
// Die Kopfleiste für die Tabelle ausgeben.
System.out.printf("Jahr\t%11.2f%%\t%11.2f%%\t%11.2f%%\n", zinssatz[0], zinssatz[1], zinssatz[2]);
// Die Informationen der Entwicklung ausgeben.
for(int i = 0; i < entwicklung.length; i++) {
System.out.printf("%d\t%8.2f EUR\t%8.2f EUR\t%8.2f EUR\n", (2023 + 1) + i, entwicklung[i][0], entwicklung[i][1], entwicklung[i][2]);
}
}
}

View File

@@ -1,73 +0,0 @@
class Aufgabe {
public static void main(String[] args) {
final int RECHTS = 1;
final int LINKS = 0;
final int NUM_FROESCHE = 100000;
// Neuer Frosch startet bei Feld 1.
int position = 1;
int position_max = 0;
// Es gibt zwei Eimer in welchen ein Frosch landen kann.
// Eimer bei Index 0 ist der linke Eimer.
// Eimer bei Index 1 ist der rechte Eimer.
int[] eimer = {0, 0};
// Auf der Zahlengerade springt der aktuelle Frosch.
// Das Feld 0 ist bereits ein Eimer (der rechte Eimer).
// Wenn der Frosch den Index auf der linken Seite verlässt springt er in den linken Eimer.
int[] zahlengerade = new int[1000];
// Die Zahlengerade wird initialisiert. Am Anfang zeigen alle Felder nach rechts.
// 0 = Frosch springt nach links.
// 1 = Frosch springt nach rechts.
for(int i = 0; i < zahlengerade.length; i++) {
zahlengerade[i] = RECHTS;
}
// Schleife mit welcher alle Frösche durchlaufen werden.
// Es ist immer nur ein Frosch auf der Zahlengerade unterwegs.
for(int anzahl_froesche = NUM_FROESCHE; anzahl_froesche > 0; anzahl_froesche--) {
position = 1;
// Der Frosch bewegt sich so lange auf der Zahlengerade bis dieser in einen Eimer fällt.
// Es steht ein Eimer auf Index 0 und Index -1.
while(position > 0) {
// Wenn der Frosch das Feld berüht ändert sich die Richtung des Felds.
zahlengerade[position] = (zahlengerade[position] == RECHTS) ? LINKS : RECHTS;
// Je nach Richtung muss der Frosch jetzt springen.
if (zahlengerade[position] == RECHTS) {
position += 1;
// Die maximale Position soll gespeichert werden.
if (position_max < position) {
position_max = position;
}
} else {
// Der Frosch soll nach links springen.
// Er könnte jetzt in einen Eimer springen.
if (position == 1) {
// Der Frosch springt in den linken Eimer.
eimer[0]++;
} else if (position == 2) {
// Der Frosch springt in den rechten Eimer.
eimer[1]++;
}
// Der Frosch springt nach links (evtl. in einen Eimer).
position -= 2;
}
}
}
// Ausgabe der wichtigsten Informationen.
System.out.printf("Linker Eimer (Index -1): %d Frösche\n", eimer[0]);
System.out.printf("Rechter Eimer (Index 0): %d Frösche\n", eimer[1]);
System.out.printf("Maximale Position auf der Zahlengerade: %d\n", position_max);
}
}

View File

@@ -1,78 +0,0 @@
class Aufgabe {
public static void main(String[] args) {
enum Monate {Januar, Februar, März, April, Mai, Juni, Juli, August, September, Oktober, November, Dezember};
String quartal = "";
Monate monat = Monate.Oktober;
// Ursprüngliche switch-Anweisung:
switch(monat) {
case Januar : quartal = "1. Quartal"; break;
case Februar : quartal = "1. Quartal"; break;
case März : quartal = "1. Quartal"; break;
case April : quartal = "2. Quartal"; break;
case Mai : quartal = "2. Quartal"; break;
case Juni : quartal = "2. Quartal"; break;
case Juli : quartal = "3. Quartal"; break;
case August : quartal = "3. Quartal"; break;
case September : quartal = "3. Quartal"; break;
case Oktober : quartal = "4. Quartal"; break;
case November : quartal = "4. Quartal"; break;
case Dezember : quartal = "4. Quartal"; break;
default : quartal = "";
}
System.out.println("a.) ursprüngliche switch-Anweisung: " + quartal);
// Zusammenfassung mehrerer Ausdrücke.
switch(monat) {
case Januar, Februar, März : quartal = "1. Quartal"; break;
case April, Mai, Juni : quartal = "2. Quartal"; break;
case Juli, August, September : quartal = "3. Quartal"; break;
case Oktober, November, Dezember : quartal = "4. Quartal"; break;
default : quartal = "";
}
System.out.println("b.) Zusammenfassung mehrerer Ausdrücke: " + quartal);
// Pfeilnotation
switch (monat) {
case Januar -> quartal = "1. Quartal";
case Februar -> quartal = "1. Quartal";
case März -> quartal = "1. Quartal";
case April -> quartal = "2. Quartal";
case Mai -> quartal = "2. Quartal";
case Juni -> quartal = "2. Quartal";
case Juli -> quartal = "3. Quartal";
case August -> quartal = "3. Quartal";
case September -> quartal = "3. Quartal";
case Oktober -> quartal = "4. Quartal";
case November -> quartal = "4. Quartal";
case Dezember -> quartal = "4. Quartal";
default -> quartal = "";
}
System.out.println("c.) Pfeilnotation: " + quartal);
// Zusammenfassung mehrerer Ausdrücke in Pfeilnotation.
switch(monat) {
case Januar, Februar, März -> quartal = "1. Quartal";
case April, Mai, Juni -> quartal = "2. Quartal";
case Juli, August, September -> quartal = "3. Quartal";
case Oktober, November, Dezember -> quartal = "4. Quartal";
default -> quartal = "";
}
System.out.println("d.) Zusammenfassung mehrerer Ausdrücke in Pfeilnotation: " + quartal);
// switch-Ausdruck mit Pfeilnotation
quartal = switch(monat) {
case Januar, Februar, März -> "1. Quartal";
case April, Mai, Juni -> "2. Quartal";
case Juli, August, September -> "3. Quartal";
case Oktober, November, Dezember -> "4. Quartal";
default -> "";
};
System.out.println("e.) switch-Ausdruck mit Pfeilnotation: " + quartal);
}
}

View File

@@ -1,5 +0,0 @@
class Aufgabe {
public static void main(String[] args) {
// Code
}
}

View File

@@ -0,0 +1,12 @@
package VL03.Aufgabe01;
/**
* Vorlesung 3 / Aufgabe 1
*
* @author Sebastian Brosch
*/
public class Aufgabe01 {
public static void main(String[] args) {
System.out.println("Hallo Welt");
}
}

View File

@@ -1,16 +1,29 @@
class Aufgabe {
package VL03.Aufgabe02;
/**
* Vorlesung 3 / Aufgabe 2
*
* @author Sebastian Brosch
*/
public class Aufgabe02 {
public static void main(String[] args) {
int a1 = 2;
int a2 = 4;
int a3 = 6;
System.out.printf("a1: %d, a2: %d, a3: %d\n\n", a1, a2, a3);
System.out.println("a.) Arithmetisches Mittel: " + ((a1 + a2 + a3) / 3));
System.out.println("b.) Ist " + a1 + " < " + a2 + " < " + a3 + "? " + (a1 < a2 && a2 < a3 ? "Ja" : "Nein"));
System.out.println("c.) Ist " + a1 + " ein ganzzahliges Vielfaches von " + a2 + "? " + (a1 % a2 == 0 ? "Ja" : "Nein"));
System.out.println("c.) Ist " + a1 + " ein Vielfaches von " + a2 + "? " + (a1 % a2 == 0 ? "Ja" : "Nein"));
System.out.println("d.) " + a3 + " invertiert: " + (~a3));
a3 = Integer.MAX_VALUE;
System.out.println("e.) Größter positiver Integer-Wert: " + (a3));
System.out.println("f.) Größter postiver Integer-Wert + 1: " + (a3 + 1));
a2 = 0xFFFFFFFF;
a2 = ~(a3 << a2);
System.out.println("g.) a2 (0xFFFFFFFF) nach a3 umwandeln: " + a2);
}
}

View File

@@ -0,0 +1,30 @@
package VL03.Aufgabe03;
/**
* Vorlesung 3 / Aufgabe 3
*
* @author Sebastian Brosch
*/
public class Aufgabe03 {
public static void main(String[] args) {
int a = 3;
int b = 4;
int c = 5;
System.out.printf("a: %d, b: %d, c: %d\n", a, b, c);
System.out.println("Werte entsprechen dem Satz des Pythagoras: " + (check(a, b, c) ? "Ja" : "Nein"));
}
/**
* Method to check three numbers against the pythagorean theorem.
*
* @param a The first number (a in formula).
* @param b The second number (b in formula).
* @param c The result of the theorem (c in formula).
* @return The state whether the three numbers are matching the pythagorean
* theorem.
*/
public static boolean check(int a, int b, int c) {
return (a * a + b * b == c * c) ? true : false;
}
}

View File

@@ -0,0 +1,22 @@
package VL03.Aufgabe04;
/**
* Vorlesung 3 / Aufgabe 4
*
* @author Sebastian Brosch
*/
public class Aufgabe04 {
public static void main(String[] args) {
int i = 5;
int j = 3;
boolean b = false;
System.out.println("a.) " + (!((i < j) && b)));
System.out.println("b.) " + (i / j));
System.out.println("c.) " + (float) (i / j));
System.out.println("d.) " + ((float) i / j));
System.out.println("e.) " + ((float) i / (float) j));
System.out.println("f.) " + (((i++ == 5) || (--i == 5))));
System.out.println("g.) " + (((i++ == 5) | (--i == 5))));
}
}

View File

@@ -0,0 +1,26 @@
package VL04.Aufgabe01;
/**
* Vorlesung 4 / Aufgabe 1
*
* @author Sebastian Brosch
*/
public class Aufgabe01 {
public static void main(String[] args) {
final int MAXIMUM = 25;
System.out.printf("\nGerade Zahlen zwischen 1 und %d:\n", MAXIMUM);
for (int i = 1; i <= MAXIMUM; i++) {
if (i % 2 == 0)
System.out.printf("%d\n", i);
}
System.out.printf("\nUngerade Zahlen zwischen 1 und %d:\n", MAXIMUM);
for (int j = 1; j <= MAXIMUM; j++) {
if (j % 2 == 1)
System.out.printf("%d\n", j);
}
}
}

View File

@@ -0,0 +1,43 @@
package VL04.Aufgabe02;
/**
* Vorlesung 4 / Aufgabe 2
*
* @author Sebastian Brosch
*/
public class Aufgabe02 {
public static void main(String[] args) {
final int START = 1;
final int END = 20;
int sum = 0;
// create sum using for loop.
for (int i = START; i <= END; i++) {
sum += i;
}
System.out.printf("\nSumme aller Zahlen zwischen %d und %d: %d (for)", START, END, sum);
// create sum using while loop.
int j = START;
sum = 0;
while (j <= END) {
sum += j;
j++;
}
System.out.printf("\nSumme aller Zahlen zwischen %d und %d: %d (while)", START, END, sum);
// create sum using do while loop.
int k = START;
sum = 0;
do {
sum += k;
k++;
} while (k <= END);
System.out.printf("\nSumme aller Zahlen zwischen %d und %d: %d (do while)", START, END, sum);
}
}

View File

@@ -0,0 +1,40 @@
package VL04.Aufgabe03;
/**
* Vorlesung 4 / Aufgabe 3
*
* @author Sebastian Brosch
*/
public class Aufgabe03 {
public static void main(String[] args) {
final int MAXIMUM = 50;
int[] numbers = new int[MAXIMUM];
for (int i = 0; i < numbers.length; i++) {
numbers[i] = i + 1;
}
for (int i = 0; i <= (numbers.length / 2); i++) {
int base = numbers[i];
if (base < 2) {
numbers[i] = 0;
continue;
}
for (int j = i + 1; j < numbers.length; j++) {
int number = numbers[j];
if (number % base == 0) {
numbers[j] = 0;
}
}
}
for (int i = 0; i < numbers.length; i++) {
if (numbers[i] > 0) {
System.out.println(numbers[i]);
}
}
}
}

View File

@@ -0,0 +1,37 @@
package VL04.Aufgabe04;
/**
* Vorlesung 4 / Aufgabe 4
*
* @author Sebastian Brosch
*/
public class Aufgabe04 {
public static void main(String[] args) {
final int laufzeit = 4;
final double startwert = 100.0;
final double[] zinssaetze = new double[] { 2.0, 2.5, 3.0 };
double entwicklung[][] = new double[laufzeit][zinssaetze.length];
for (int i = 0; i < laufzeit; i++) {
for (int z = 0; z < zinssaetze.length; z++) {
double wert = (i == 0) ? startwert : entwicklung[i - 1][z];
entwicklung[i][z] = wert + (wert * (zinssaetze[z] / 100.0));
}
}
System.out.printf("Laufzeit: %d Jahre - Startwert: %.2f EUR\n\n", laufzeit, startwert);
System.out.printf("Jahr");
for (int z = 0; z < zinssaetze.length; z++) {
System.out.printf("\t%11.2f%%", zinssaetze[z]);
}
for (int i = 0; i < entwicklung.length; i++) {
System.out.printf("\n%d", (2023 + 1) + i);
for (int z = 0; z < zinssaetze.length; z++) {
System.out.printf("\t%8.2f EUR", entwicklung[i][z]);
}
}
}
}

View File

@@ -0,0 +1,54 @@
package VL04.Aufgabe05;
/**
* Vorlesung 4 / Aufgabe 5
*
* @author Sebastian Brosch
*/
public class Aufgabe05 {
public static void main(String[] args) {
final int DIR_LEFT = 0;
final int DIR_RIGHT = 1;
final int NUM_FROGS = 100;
int[] numbersrow = new int[1000];
int[] bucket = new int[] { 0, 0 };
int position = 1;
int position_max = position;
for (int i = 0; i < numbersrow.length; i++) {
numbersrow[i] = DIR_RIGHT;
}
for (int f = NUM_FROGS; f > 0; f--) {
position = 1;
while (position > 0) {
numbersrow[position] = (numbersrow[position] == DIR_RIGHT) ? DIR_LEFT : DIR_RIGHT;
if (numbersrow[position] == DIR_RIGHT) {
position++;
if (position_max < position) {
position_max = position;
}
} else {
switch (position) {
case 1:
bucket[0]++;
break;
case 2:
bucket[1]++;
break;
}
position -= 2;
}
}
}
System.out.printf("Linker Eimer: %d Frösche\n", bucket[0]);
System.out.printf("Rechter Eimer: %d Frösche\n", bucket[1]);
System.out.printf("Maximale Position auf der Zahlengerade: %d\n", position_max);
}
}

View File

@@ -0,0 +1,129 @@
package VL04.Aufgabe06;
/**
* Vorlesung 4 / Aufgabe 6
*
* @author Sebastian Brosch
*/
public class Aufgabe06 {
public static void main(String[] args) {
enum Months {
January,
February,
March,
April,
May,
June,
July,
August,
September,
October,
November,
December
};
String quarter = "";
Months month = Months.October;
System.out.printf("Monat: %s\n\n", month);
switch (month) {
case January:
quarter = "1. Quartal";
break;
case February:
quarter = "1. Quartal";
break;
case March:
quarter = "1. Quartal";
break;
case April:
quarter = "2. Quartal";
break;
case May:
quarter = "2. Quartal";
break;
case June:
quarter = "2. Quartal";
break;
case July:
quarter = "3. Quartal";
break;
case August:
quarter = "3. Quartal";
break;
case September:
quarter = "3. Quartal";
break;
case October:
quarter = "4. Quartal";
break;
case November:
quarter = "4. Quartal";
break;
case December:
quarter = "4. Quartal";
break;
default:
quarter = "";
}
System.out.printf("a.) ursprüngliche switch-Anweisung: %s\n", quarter);
switch (month) {
case January, February, March:
quarter = "1. Quartal";
break;
case April, May, June:
quarter = "2. Quartal";
break;
case July, August, September:
quarter = "3. Quartal";
break;
case October, November, December:
quarter = "4. Quartal";
break;
default:
quarter = "";
}
System.out.printf("b.) Zusammenfassung mehrerer Ausdrücke: %s\n", quarter);
switch (month) {
case January -> quarter = "1. Quartal";
case February -> quarter = "1. Quartal";
case March -> quarter = "1. Quartal";
case April -> quarter = "2. Quartal";
case May -> quarter = "2. Quartal";
case June -> quarter = "2. Quartal";
case July -> quarter = "3. Quartal";
case August -> quarter = "3. Quartal";
case September -> quarter = "3. Quartal";
case October -> quarter = "4. Quartal";
case November -> quarter = "4. Quartal";
case December -> quarter = "4. Quartal";
default -> quarter = "";
}
System.out.printf("c.) Pfeilnotation: %s\n", quarter);
switch (month) {
case January, February, March -> quarter = "1. Quartal";
case April, May, June -> quarter = "2. Quartal";
case July, August, September -> quarter = "3. Quartal";
case October, November, December -> quarter = "4. Quartal";
default -> quarter = "";
}
System.out.printf("d.) Zusammenfassung mehrerer Ausdrücke in Pfeilnotation: %s\n", quarter);
quarter = switch (month) {
case January, February, March -> "1. Quartal";
case April, May, June -> "2. Quartal";
case July, August, September -> "3. Quartal";
case October, November, December -> "4. Quartal";
default -> "";
};
System.out.printf("e.) switch-Ausdruck mit Pfeilnotation: %s\n", quarter);
}
}

View File

@@ -27,7 +27,7 @@ public class Aufgabe01 {
* @return The fibonacci number.
*/
private static int iterativeFibonacci(int nth) {
int[] fib = { 1, 1 };
int[] fib = new int[] { 1, 1 };
for (int i = 0; i <= nth; i++) {
if (i < fib.length)

View File

@@ -0,0 +1,128 @@
package VL05.Aufgabe02;
/**
* Vorlesung 5 / Aufgabe 2
*
* @author Sebastian Brosch
*/
public class Aufgabe02 {
public static void main(String[] args) {
final int DAMEN = 8;
int chessboard[][] = new int[DAMEN][DAMEN];
queens(chessboard, 1);
}
/**
* Method to place a queen on the chessboard.
*
* @param chessboard The chessboard to place the queen.
* @param q The number of the queen to be placed.
*/
private static void queens(int[][] chessboard, int q) {
if (q > chessboard.length) {
print(chessboard);
return;
} else {
for (int i = 0; i < chessboard.length; i++) {
if (isQueenPossible(chessboard, q - 1, i)) {
chessboard[q - 1][i] = 1;
queens(chessboard, q + 1);
chessboard[q - 1][i] = 0;
}
}
}
}
/**
* Method to check whether a queen can be placed on the field.
*
* @param chessboard The chessboard to place the queen.
* @param row The row to place the queen.
* @param column The column to place the queen.
* @return The state whether the queen can be placed on the field.
*/
private static boolean isQueenPossible(int[][] chessboard, int row, int column) {
int currentRow = 0;
int currentColumn = 0;
// check whether the queen can be placed in current row.
for (int c = 0; c < chessboard[row].length; c++) {
if (chessboard[row][c] == 1)
return false;
}
// check whether the queen can be placed in current column.
for (int r = 0; r < chessboard.length; r++) {
if (chessboard[r][column] == 1)
return false;
}
// check whether the queen can be placed diagonal (top left).
currentRow = row;
currentColumn = column;
while (currentColumn >= 0 && currentRow >= 0) {
if (chessboard[currentRow][currentColumn] == 1)
return false;
currentRow--;
currentColumn--;
}
// check whether the queen can be placed diagonal (bottom right).
currentRow = row;
currentColumn = column;
while (currentColumn < chessboard[row].length && currentRow < chessboard.length) {
if (chessboard[currentRow][currentColumn] == 1)
return false;
currentRow++;
currentColumn++;
}
// check whether the queen can be placed diagonal (bottom left).
currentRow = row;
currentColumn = column;
while (currentColumn >= 0 && currentRow < chessboard.length) {
if (chessboard[currentRow][currentColumn] == 1)
return false;
currentRow++;
currentColumn--;
}
// check whether the queen can be placed diagonal (top right).
currentRow = row;
currentColumn = column;
while (currentColumn < chessboard[row].length && currentRow >= 0) {
if (chessboard[currentRow][currentColumn] == 1)
return false;
currentRow--;
currentColumn++;
}
return true;
}
/**
* Method to print a chessboard.
*
* @param chessboard The chessboard to be printed.
*/
private static void print(int[][] chessboard) {
System.out.println("\nChessboard:\n");
for (int r = 0; r < chessboard.length; r++) {
for (int c = 0; c < chessboard[r].length; c++) {
System.out.printf("%d", chessboard[r][c]);
}
System.out.printf("\n");
}
}
}

View File

@@ -2,6 +2,8 @@ package VL06.Aufgabe01;
/**
* Vorlesung 6 / Aufgabe 1
*
* @author Sebastian Brosch
*/
public class Aufgabe01 {
public static void main(String[] args) {

View File

@@ -0,0 +1,38 @@
package VL08.Aufgabe03;
/**
* Vorlesung 8 / Aufgabe 3
*
* @author Sebastian Brosch
*/
public class Aufgabe03 {
public static void main(String[] args) {
Matrix matrixA = new Matrix(2, 3);
matrixA.setValue(0, 0, 3);
matrixA.setValue(0, 1, 2);
matrixA.setValue(0, 2, 1);
matrixA.setValue(1, 0, 1);
matrixA.setValue(1, 1, 0);
matrixA.setValue(1, 2, 2);
Matrix matrixB = new Matrix(3, 2);
matrixB.setValue(0, 0, 1);
matrixB.setValue(0, 1, 2);
matrixB.setValue(1, 0, 0);
matrixB.setValue(1, 1, 1);
matrixB.setValue(2, 0, 4);
matrixB.setValue(2, 1, 0);
System.out.println("------------------");
matrixA.print();
System.out.println("------------------");
matrixB.print();
System.out.println("------------------");
matrixA.multiply(matrixB);
matrixA.print();
System.out.println("------------------");
}
}

154
VL08/Aufgabe03/Matrix.java Normal file
View File

@@ -0,0 +1,154 @@
package VL08.Aufgabe03;
/**
* A class to represent a Matrix.
*/
public class Matrix {
private int rows = 0;
private int columns = 0;
private int[][] matrix;
Matrix(int rows, int columns) {
this.rows = rows;
this.columns = columns;
this.matrix = new int[this.rows][this.columns];
for (int rowIndex = 0; rowIndex < this.rows; rowIndex++) {
for (int columnIndex = 0; columnIndex < this.columns; columnIndex++) {
this.matrix[rowIndex][columnIndex] = 0;
}
}
}
/**
* Method to get the number of columns.
*
* @return The number of columns.
*/
int getColumns() {
return this.columns;
}
/**
* Method to get the number of rows.
*
* @return The number of rows.
*/
int getRows() {
return this.rows;
}
/**
* Method to get the value of a specific field.
*
* @param row The row of the value.
* @param column The column of the value.
* @return The value of the given row and column.
*/
int getValue(int row, int column) {
return this.matrix[row][column];
}
/**
* Method to set the value of a specific field.
*
* @param row The row to set the value.
* @param column The column to set the value.
* @param value The value to be set in the field.
*/
void setValue(int row, int column, int value) {
this.matrix[row][column] = value;
}
/**
* Methode to get the state whether the given Matrix is same size.
*
* @param matrix The Matrix to check for same size.
* @return The state whether the given Matrix is same size.
*/
boolean isSameSize(Matrix matrix) {
return (this.rows == matrix.getRows()) && (this.columns == matrix.getColumns());
}
/**
* Method to add a Matrix to the current Matrix.
*
* @param matrix The Matrix to add to the current Matrix.
*/
void add(Matrix matrix) {
if (!this.isSameSize(matrix)) {
return;
}
for (int rowIndex = 0; rowIndex < this.rows; rowIndex++) {
for (int columnIndex = 0; columnIndex < this.columns; columnIndex++) {
this.matrix[rowIndex][columnIndex] += matrix.getValue(rowIndex, columnIndex);
}
}
}
/**
* Method to multiply a scalar value to the Matrix.
*
* @param scalar The scalar value to multiply the Matrix.
*/
void multiply(int scalar) {
for (int rowIndex = 0; rowIndex < this.rows; rowIndex++) {
for (int columnIndex = 0; columnIndex < this.columns; columnIndex++) {
this.matrix[rowIndex][columnIndex] *= scalar;
}
}
}
/**
* Method to multiply a Matrix to the Matrix.
*
* @param matrix The Matrix to multiply with this Matrix.
* @return State whether the multiplication of the Matrix was successful.
*/
boolean multiply(Matrix matrix) {
// multiplication is not possible if there are no rows or no columns.
if (this.getColumns() == 0 || this.getRows() == 0) {
return false;
}
// multiplication is only possible if the number of rows of Matrix A
// is equals to the number of columns of Matrix B.
if (this.getColumns() != matrix.getRows()) {
return false;
}
int[][] tempMatrix = new int[this.matrix.length][this.matrix.length];
for (int rowIndex = 0; rowIndex < this.getRows(); rowIndex++) {
for (int columnIndex = 0; columnIndex < matrix.getColumns(); columnIndex++) {
tempMatrix[rowIndex][columnIndex] = 0;
for (int fieldIndex = 0; fieldIndex < matrix.getRows(); fieldIndex++) {
tempMatrix[rowIndex][columnIndex] += this.getValue(rowIndex, fieldIndex)
* matrix.getValue(fieldIndex, columnIndex);
}
}
}
this.matrix = tempMatrix;
this.columns = tempMatrix.length;
this.rows = tempMatrix.length;
return true;
}
/**
* Method to print the Matrix.
*/
void print() {
for (int rowIndex = 0; rowIndex < this.rows; rowIndex++) {
for (int columnIndex = 0; columnIndex < this.columns; columnIndex++) {
System.out.printf("%5d", this.getValue(rowIndex, columnIndex));
}
System.out.print("\n");
}
}
}

View File

@@ -0,0 +1,30 @@
package VL08.Aufgabe04;
import VL08.Aufgabe04.PersonenDH.Person;
import VL08.Aufgabe04.PersonenDH.Student;
import VL08.Aufgabe04.PersonenDH.Studiengangsleiter;
import VL08.Aufgabe04.PersonenDH.Dozent;
import VL08.Aufgabe04.PersonenDH.Mitarbeiter;
import java.util.ArrayList;
/**
* Vorlesung 8 / Aufgabe 4
*
* @author Sebastian Brosch
*/
public class Aufgabe04 {
public static void main(String[] args) {
ArrayList<Person> personen = new ArrayList<Person>();
personen.add(new Person("Petra Mustermann", 37));
personen.add(new Student("Max Mustermann", 30, "1234567"));
personen.add(new Dozent("Eva Mustermann", 50, "Informatik"));
personen.add(new Mitarbeiter("Tim Mustermann", 35, "Programmieren"));
personen.add(new Studiengangsleiter("Kevin Mustermann", 40, "BWL", "BWL 1"));
for (Person person : personen) {
person.print();
System.out.println("-------------------------");
}
}
}

View File

@@ -0,0 +1,15 @@
package VL08.Aufgabe04.PersonenDH;
public class Dozent extends Person {
private String specialization;
public Dozent(String name, int age, String specialization) {
super(name, age);
this.specialization = specialization;
}
public void print() {
super.print();
System.out.printf("Fachrichtung: %s\n", specialization);
}
}

View File

@@ -0,0 +1,15 @@
package VL08.Aufgabe04.PersonenDH;
public class Mitarbeiter extends Person {
private String activity;
public Mitarbeiter(String name, int age, String activity) {
super(name, age);
this.activity = activity;
}
public void print() {
super.print();
System.out.printf("Tätigkeit: %s\n", this.activity);
}
}

View File

@@ -0,0 +1,16 @@
package VL08.Aufgabe04.PersonenDH;
public class Person {
String name;
int age;
public Person(String name, int age) {
this.name = name;
this.age = age;
}
public void print() {
System.out.printf("Name: %s\n", this.name);
System.out.printf("Alter: %d\n", this.age);
}
}

View File

@@ -0,0 +1,15 @@
package VL08.Aufgabe04.PersonenDH;
public class Student extends Person {
private String studentNumber;
public Student(String name, int age, String studentNumber) {
super(name, age);
this.studentNumber = studentNumber;
}
public void print() {
super.print();
System.out.printf("Matrikel-Nummer: %s\n", this.studentNumber);
}
}

View File

@@ -0,0 +1,15 @@
package VL08.Aufgabe04.PersonenDH;
final public class Studiengangsleiter extends Dozent {
private String course;
public Studiengangsleiter(String name, int age, String specialization, String course) {
super(name, age, specialization);
this.course = course;
}
public void print() {
super.print();
System.out.printf("Kurs: %s\n", this.course);
}
}

View File

@@ -12,15 +12,15 @@ import java.util.Random;
public class Aufgabe03 {
public static void main(String[] args) {
final int MAX_RUNS = 10;
int[] sizes = { 10000, 20000, 50000, 100000, 200000, 500000, 1000000, 2000000, 5000000, 10000000, 20000000,
50000000 };
int[] sizes = new int[] { 10000, 20000, 50000, 100000, 200000, 500000, 1000000, 2000000, 5000000, 10000000,
20000000, 50000000 };
for (int size : sizes) {
long sumArrayList = 0;
long sumLinkedList = 0;
ArrayList<String> values = getValues(size);
for (int i = 0; i < MAX_RUNS; i++) {
ArrayList<String> values = getValues(size);
sumArrayList += runTestArrayList(values);
sumLinkedList += runTestLinkedList(values);
}

View File

@@ -0,0 +1,18 @@
package VL14.Aufgabe01;
/**
* Vorlesung 14 / Aufgabe 1
*
* @author Sebastian Brosch
*/
class Aufgabe01 {
public static void main(String[] args) {
Counter counterUp = new Counter(1, 100);
Counter counterDown = new Counter(-10);
Thread threadCounterUp = new Thread(counterUp);
Thread threadCounterDown = new Thread(counterDown);
threadCounterUp.start();
threadCounterDown.start();
}
}

View File

@@ -0,0 +1,52 @@
package VL14.Aufgabe01;
/**
* Class representing a counter.
*
* @author Sebastian Brosch
*/
public class Counter implements Runnable {
static int counter;
// some information of the counter.
private int number;
/**
* Create a new counter with initializing the start value.
*
* @param number The number to increment or decrement the counter.
* @param start The start value of the counter.
*/
public Counter(int number, int start) {
this(number);
counter = start;
}
/**
* Create a new counter without initializing the start value.
*
* @param number The number to increment or decrement the counter.
*/
public Counter(int number) {
this.number = number;
}
/**
* Method to run some code in a Thread.
*/
public void run() {
while (counter > 0 && counter < 1000) {
this.count();
}
}
/**
* Method to increment or decrement the counter.
*/
private void count() {
synchronized (getClass()) {
counter += this.number;
System.out.printf("%3d [%s: %3d]\n", counter, Thread.currentThread().getName(), this.number);
}
}
}

View File

@@ -0,0 +1,38 @@
package VL14.Aufgabe02;
import java.util.Random;
/**
* Vorlesung 14 / Aufgabe 2
*
* @author Sebastian Brosch
*/
public class Aufgabe02 {
public static void main(String[] args) throws Exception {
final int NUMBER_OF_USERS = 2;
final int NUMBER_OF_PRINTERS = 2;
// create some printers.
for (int p = 0; p < NUMBER_OF_PRINTERS; p++) {
Thread threadPrinter = new Thread(new Printer());
threadPrinter.start();
}
// create some users.
for (int u = 0; u < NUMBER_OF_USERS; u++) {
Thread threadUser = new Thread(new User(getRandomNumber(1, 10) * 1000));
threadUser.start();
}
}
/**
* Method to determine a random number from a certain range.
*
* @param start The first number of the range.
* @param end The last number of the range.
* @return A random number from a certain range.
*/
private static int getRandomNumber(int start, int end) {
return (new Random()).nextInt((end - start + 1)) + start;
}
}

View File

@@ -0,0 +1,19 @@
package VL14.Aufgabe02;
/**
* Class which represents a printer.
*
* @author Sebastian Brosch
*/
public class Printer implements Runnable {
public void run() {
while (true) {
synchronized (PrinterQueue.queue) {
if (PrinterQueue.queue.size() > 0) {
System.out.println("Printer " + Thread.currentThread().threadId() + " prints: " + PrinterQueue.queue.getFirst());
PrinterQueue.queue.removeFirst();
}
}
}
}
}

View File

@@ -0,0 +1,14 @@
package VL14.Aufgabe02;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Class which represents a printer queue.
*
* @author Sebastian Brosch
*/
public class PrinterQueue {
static List<Object> queue = Collections.synchronizedList(new ArrayList<>());
}

36
VL14/Aufgabe02/User.java Normal file
View File

@@ -0,0 +1,36 @@
package VL14.Aufgabe02;
/**
* Class which represents a user.
*
* @author Sebastian Brosch
*/
public class User implements Runnable {
private int number = 0;
private long wait = 0;
/**
* Constructor to initialize a User.
*/
public User() {
this.wait = 1000;
}
/**
* Constructor to initialize a User.
*
* @param wait The time the user is waiting for creating new print jobs.
*/
public User(int wait) {
this.wait = wait;
}
public void run() {
while (this.wait > 0) {
int data = this.number++;
PrinterQueue.queue.add(data);
System.out.println("User " + Thread.currentThread().threadId() + " added " + data);
this.wait--;
}
}
}

View File

@@ -0,0 +1,18 @@
package VL15.Aufgabe01;
import javax.swing.JFrame;
/**
* Vorlesung 15 / Aufgabe 1
*
* @author Sebastian Brosch
*/
public class Aufgabe01 {
public static void main(String[] args) {
Screenshot screenshot = new Screenshot("Screenshot");
screenshot.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
screenshot.setSize(690, 390);
screenshot.setResizable(false);
screenshot.setVisible(true);
}
}

View File

@@ -0,0 +1,238 @@
package VL15.Aufgabe01;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import java.awt.event.WindowListener;
import java.awt.Color;
import java.awt.Font;
import java.awt.Image;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class Screenshot extends JFrame {
Screenshot(String title) {
super(title);
JTabbedPane tcMain = new JTabbedPane();
JPanel pnlVerbindungssuche = new JPanel();
pnlVerbindungssuche.setLayout(null);
JPanel pnlErweiterteSuche = new JPanel();
tcMain.addTab("Verbindungssuche", pnlVerbindungssuche);
tcMain.addTab("Erweiterte Suche", pnlErweiterteSuche);
JTextArea txtLanguageMenu = new JTextArea();
txtLanguageMenu.setText("deutsch | english | francais | italiano");
txtLanguageMenu.setBounds(480, 0, 200, 20);
this.getContentPane().add(txtLanguageMenu);
insertHeading("Start & Ziel", pnlVerbindungssuche, 0);
JLabel lblStartZielVon = new JLabel();
lblStartZielVon.setText("Von:");
lblStartZielVon.setBounds(0, 25, 100, 25);
pnlVerbindungssuche.add(lblStartZielVon);
JLabel lblStartZielNach = new JLabel();
lblStartZielNach.setText("Nach:");
lblStartZielNach.setBounds(0, 50, 100, 25);
pnlVerbindungssuche.add(lblStartZielNach);
JLabel lblStartZielBahnhofHaltestelleVon = new JLabel();
lblStartZielBahnhofHaltestelleVon.setText("Bahnhof/Haltestelle");
lblStartZielBahnhofHaltestelleVon.setBounds(100, 25, 150, 25);
lblStartZielBahnhofHaltestelleVon.setFont(lblStartZielBahnhofHaltestelleVon.getFont().deriveFont(Font.PLAIN));
pnlVerbindungssuche.add(lblStartZielBahnhofHaltestelleVon);
JLabel lblStartZielBahnhofHaltestelleNach = new JLabel();
lblStartZielBahnhofHaltestelleNach.setText("Bahnhof/Haltestelle");
lblStartZielBahnhofHaltestelleNach.setBounds(100, 50, 150, 25);
lblStartZielBahnhofHaltestelleNach.setFont(lblStartZielBahnhofHaltestelleNach.getFont().deriveFont(Font.PLAIN));
pnlVerbindungssuche.add(lblStartZielBahnhofHaltestelleNach);
JTextField txtStartZielVon = new JTextField();
txtStartZielVon.setBounds(250, 27, 300, 20);
txtStartZielVon.setBorder(BorderFactory.createLineBorder(Color.black));
pnlVerbindungssuche.add(txtStartZielVon);
JTextField txtStartZielNach = new JTextField();
txtStartZielNach.setBounds(250, 52, 300, 20);
txtStartZielNach.setBorder(BorderFactory.createLineBorder(Color.BLACK));
pnlVerbindungssuche.add(txtStartZielNach);
pnlVerbindungssuche.add(getInfoIcon(555, 27));
JButton btnStartZielUeber = new JButton();
btnStartZielUeber.setText("Über");
btnStartZielUeber.setBounds(555, 52, 65, 20);
pnlVerbindungssuche.add(btnStartZielUeber);
insertHeading("Reisedatum und -zeit", pnlVerbindungssuche, 75);
JLabel lblReisedatumHinfahrt = new JLabel();
lblReisedatumHinfahrt.setText("Hinfahrt:");
lblReisedatumHinfahrt.setBounds(0, 100, 100, 25);
pnlVerbindungssuche.add(lblReisedatumHinfahrt);
JLabel lblReisedatumHinfahrtDatum = new JLabel();
lblReisedatumHinfahrtDatum.setText("Datum:");
lblReisedatumHinfahrtDatum.setBounds(100, 100, 75, 25);
lblReisedatumHinfahrtDatum.setFont(lblReisedatumHinfahrtDatum.getFont().deriveFont(Font.PLAIN));
pnlVerbindungssuche.add(lblReisedatumHinfahrtDatum);
JLabel lblReisedatumHinfahrtUhrzeit = new JLabel();
lblReisedatumHinfahrtUhrzeit.setText("Uhrzeit:");
lblReisedatumHinfahrtUhrzeit.setBounds(100, 125, 50, 25);
lblReisedatumHinfahrtUhrzeit.setFont(lblReisedatumHinfahrtUhrzeit.getFont().deriveFont(Font.PLAIN));
pnlVerbindungssuche.add(lblReisedatumHinfahrtUhrzeit);
JTextField txtReisedatumHinfahrtDatum = new JTextField();
txtReisedatumHinfahrtDatum.setBounds(150, 102, 100, 20);
txtReisedatumHinfahrtDatum.setBorder(BorderFactory.createLineBorder(Color.black));
pnlVerbindungssuche.add(txtReisedatumHinfahrtDatum);
JTextField txtReisedatumHinfahrtUhrzeit = new JTextField();
txtReisedatumHinfahrtUhrzeit.setBounds(150, 127, 50, 20);
txtReisedatumHinfahrtUhrzeit.setBorder(BorderFactory.createLineBorder(Color.black));
pnlVerbindungssuche.add(txtReisedatumHinfahrtUhrzeit);
String uhrzeitTypes[] = { "Ankunft", "Abfahrt" };
JComboBox<String> cmbReisedatumHinfahrtUhrzeitType = new JComboBox<String>(uhrzeitTypes);
cmbReisedatumHinfahrtUhrzeitType.setBounds(205, 127, 100, 20);
pnlVerbindungssuche.add(cmbReisedatumHinfahrtUhrzeitType);
JSeparator sepReisedatum = new JSeparator(SwingConstants.VERTICAL);
sepReisedatum.setBounds(315, 100, 1, 50);
sepReisedatum.setBackground(Color.LIGHT_GRAY);
pnlVerbindungssuche.add(sepReisedatum);
JLabel lblReisedatumRueckfahrt = new JLabel();
lblReisedatumRueckfahrt.setText("Rückfahrt:");
lblReisedatumRueckfahrt.setBounds(325, 100, 100, 25);
pnlVerbindungssuche.add(lblReisedatumRueckfahrt);
JLabel lblReisedatumRueckfahrtDatum = new JLabel();
lblReisedatumRueckfahrtDatum.setText("Datum:");
lblReisedatumRueckfahrtDatum.setBounds(425, 100, 75, 25);
lblReisedatumRueckfahrtDatum.setFont(lblReisedatumRueckfahrtDatum.getFont().deriveFont(Font.PLAIN));
pnlVerbindungssuche.add(lblReisedatumRueckfahrtDatum);
JLabel lblReisedatumRueckfahrtUhrzeit = new JLabel();
lblReisedatumRueckfahrtUhrzeit.setText("Uhrzeit:");
lblReisedatumRueckfahrtUhrzeit.setBounds(425, 125, 50, 25);
lblReisedatumRueckfahrtUhrzeit.setFont(lblReisedatumRueckfahrtUhrzeit.getFont().deriveFont(Font.PLAIN));
pnlVerbindungssuche.add(lblReisedatumRueckfahrtUhrzeit);
JTextField txtReisedatumRueckfahrtDatum = new JTextField();
txtReisedatumRueckfahrtDatum.setBounds(475, 102, 100, 20);
txtReisedatumRueckfahrtDatum.setBorder(BorderFactory.createLineBorder(Color.black));
pnlVerbindungssuche.add(txtReisedatumRueckfahrtDatum);
JTextField txtReisedatumRueckfahrtUhrzeit = new JTextField();
txtReisedatumRueckfahrtUhrzeit.setBounds(475, 127, 50, 20);
txtReisedatumRueckfahrtUhrzeit.setBorder(BorderFactory.createLineBorder(Color.black));
pnlVerbindungssuche.add(txtReisedatumRueckfahrtUhrzeit);
JComboBox<String> cmbReisedatumRueckfahrtUhrzeitType = new JComboBox<String>(uhrzeitTypes);
cmbReisedatumRueckfahrtUhrzeitType.setBounds(530, 127, 100, 20);
pnlVerbindungssuche.add(cmbReisedatumRueckfahrtUhrzeitType);
insertHeading("Angaben zur Preisberechnung", pnlVerbindungssuche, 150);
JLabel lblPreisberechnungReisende = new JLabel();
lblPreisberechnungReisende.setText("Reisende:");
lblPreisberechnungReisende.setBounds(0, 175, 100, 25);
pnlVerbindungssuche.add(lblPreisberechnungReisende);
String personType[] = { "1 Erwachsener", "2 Erwachsene" };
JComboBox<String> cmbPreisberechnungPersonType = new JComboBox<String>(personType);
cmbPreisberechnungPersonType.setBounds(100, 177, 205, 20);
pnlVerbindungssuche.add(cmbPreisberechnungPersonType);
JButton btnPreisberechnungAdd = new JButton();
btnPreisberechnungAdd.setText("Personen hinzufügen");
btnPreisberechnungAdd.setBounds(100, 202, 160, 20);
pnlVerbindungssuche.add(btnPreisberechnungAdd);
pnlVerbindungssuche.add(getInfoIcon(265, 202));
String rabattType[] = { "Keine Ermäßigung", "Bahn-Card 25", "Bahn-Card 50" };
JComboBox<String> cmbPreisberechnungRabattType = new JComboBox<String>(rabattType);
cmbPreisberechnungRabattType.setBounds(315, 177, 210, 20);
pnlVerbindungssuche.add(cmbPreisberechnungRabattType);
JButton btnPreisberechnungAuslandspreise = new JButton();
btnPreisberechnungAuslandspreise.setText("Auslandspreise");
btnPreisberechnungAuslandspreise.setBounds(315, 202, 125, 20);
pnlVerbindungssuche.add(btnPreisberechnungAuslandspreise);
pnlVerbindungssuche.add(getInfoIcon(445, 202));
String klasseType[] = { "1. Klasse", "2. Klasse" };
JComboBox<String> cmbPreisberechnungKlasse = new JComboBox<String>(klasseType);
cmbPreisberechnungKlasse.setBounds(530, 177, 100, 20);
pnlVerbindungssuche.add(cmbPreisberechnungKlasse);
insertHeading("Angaben zur Verbindung", pnlVerbindungssuche, 225);
JLabel lblVerbindungVerkehrsmittel = new JLabel();
lblVerbindungVerkehrsmittel.setText("Verkehrsmittel:");
lblVerbindungVerkehrsmittel.setBounds(0, 250, 100, 25);
pnlVerbindungssuche.add(lblVerbindungVerkehrsmittel);
String searchType[] = { "Standardsuche", "Erweiterte Suche" };
JComboBox<String> cmbVerbindungSucheType = new JComboBox<String>(searchType);
cmbVerbindungSucheType.setBounds(100, 252, 205, 20);
pnlVerbindungssuche.add(cmbVerbindungSucheType);
JButton btnVerbindungAdvanced = new JButton();
btnVerbindungAdvanced.setText("Erweitert");
btnVerbindungAdvanced.setBounds(315, 252, 100, 20);
pnlVerbindungssuche.add(btnVerbindungAdvanced);
pnlVerbindungssuche.add(getInfoIcon(420, 252));
JCheckBox chkVerbindungSchnelleVerbindung = new JCheckBox();
chkVerbindungSchnelleVerbindung.setText("schnelle Verbindungen bevorzugen");
chkVerbindungSchnelleVerbindung.setBounds(100, 277, 235, 20);
pnlVerbindungssuche.add(chkVerbindungSchnelleVerbindung);
pnlVerbindungssuche.add(getInfoIcon(335, 277));
JCheckBox chkVerbindungFahrrad = new JCheckBox();
chkVerbindungFahrrad.setText("Fahrradmitnahme");
chkVerbindungFahrrad.setBounds(370, 277, 150, 20);
pnlVerbindungssuche.add(chkVerbindungFahrrad);
JSeparator sepControls = new JSeparator(SwingConstants.HORIZONTAL);
sepControls.setBounds(0, 300, 670, 1);
sepControls.setBackground(Color.LIGHT_GRAY);
pnlVerbindungssuche.add(sepControls);
JButton btnVerbindungSuchen = new JButton();
btnVerbindungSuchen.setText("Verbindung suchen");
btnVerbindungSuchen.setBounds(0, 305, 150, 20);
pnlVerbindungssuche.add(btnVerbindungSuchen);
JButton btnVerbindungNeueAnfrage = new JButton();
btnVerbindungNeueAnfrage.setText("Neue Anfrage");
btnVerbindungNeueAnfrage.setBounds(155, 305, 125, 20);
pnlVerbindungssuche.add(btnVerbindungNeueAnfrage);
JButton btnMeinAnfrageprofil = new JButton();
btnMeinAnfrageprofil.setText("Mein Anfrageprofil");
btnMeinAnfrageprofil.setBounds(520, 305, 150, 20);
pnlVerbindungssuche.add(btnMeinAnfrageprofil);
this.getContentPane().add(tcMain);
WindowListener closeListener = new WindowAdapter() {
public void windowClosing(WindowEvent event) {
System.exit(0);
}
};
this.addWindowListener(closeListener);
}
private void insertHeading(String title, JPanel panel, int top) {
JLabel lblStartZiel = new JLabel();
lblStartZiel.setText(title);
lblStartZiel.setOpaque(true);
lblStartZiel.setBackground(Color.decode("#ceccfe"));
lblStartZiel.setForeground(Color.decode("#1b0897"));
lblStartZiel.setBounds(0, top, 670, 25);
panel.add(lblStartZiel);
}
/**
* Get a JLabel with displaying the info icon.
*
* @param left The position on the x-axis.
* @param top The position on the y-axis.
* @return The label with info icon.
*/
private JLabel getInfoIcon(int left, int top) {
ImageIcon icon = (ImageIcon) UIManager.get("OptionPane.informationIcon");
Image imgFit = icon.getImage().getScaledInstance(20, 20, java.awt.Image.SCALE_SMOOTH);
JLabel lblInfoIcon = new JLabel(new ImageIcon(imgFit));
lblInfoIcon.setBounds(left, top, 20, 20);
return lblInfoIcon;
}
}

View File

@@ -0,0 +1,18 @@
package VL16.Aufgabe01;
import javax.swing.JFrame;
/**
* Vorlesung 16 / Aufgabe 1
*
* @author Sebastian Brosch
*/
public class Aufgabe01 {
public static void main(String[] args) {
Screenshot screenshot = new Screenshot("Screenshot mit Zusammenfassung");
screenshot.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
screenshot.setSize(690, 390);
screenshot.setResizable(false);
screenshot.setVisible(true);
}
}

View File

@@ -0,0 +1,281 @@
package VL16.Aufgabe01;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import java.awt.event.WindowListener;
import java.awt.Color;
import java.awt.Font;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class Screenshot extends JFrame implements ActionListener {
// Controls (used in events).
JButton btnVerbindungSuchen = new JButton("Verbindung suchen");
JTextField txtStartZielVon = new JTextField();
JTextField txtStartZielNach = new JTextField();
JTextField txtReisedatumHinfahrtDatum = new JTextField();
JTextField txtReisedatumHinfahrtUhrzeit = new JTextField();
String uhrzeitTypes[] = { "Ankunft", "Abfahrt" };
JComboBox<String> cmbReisedatumHinfahrtUhrzeitType = new JComboBox<String>(uhrzeitTypes);
JTextField txtReisedatumRueckfahrtDatum = new JTextField();
JTextField txtReisedatumRueckfahrtUhrzeit = new JTextField();
JComboBox<String> cmbReisedatumRueckfahrtUhrzeitType = new JComboBox<String>(uhrzeitTypes);
String personType[] = { "1 Erwachsener", "2 Erwachsene" };
JComboBox<String> cmbPreisberechnungPersonType = new JComboBox<String>(personType);
String rabattType[] = { "Keine Ermäßigung", "Bahn-Card 25", "Bahn-Card 50" };
JComboBox<String> cmbPreisberechnungRabattType = new JComboBox<String>(rabattType);
String klasseType[] = { "1. Klasse", "2. Klasse" };
JComboBox<String> cmbPreisberechnungKlasse = new JComboBox<String>(klasseType);
String searchType[] = { "Standardsuche", "Erweiterte Suche" };
JComboBox<String> cmbVerbindungSucheType = new JComboBox<String>(searchType);
JCheckBox chkVerbindungSchnelleVerbindung = new JCheckBox();
JCheckBox chkVerbindungFahrrad = new JCheckBox();
Screenshot(String title) {
super(title);
JTabbedPane tcMain = new JTabbedPane();
JPanel pnlVerbindungssuche = new JPanel();
pnlVerbindungssuche.setLayout(null);
JPanel pnlErweiterteSuche = new JPanel();
tcMain.addTab("Verbindungssuche", pnlVerbindungssuche);
tcMain.addTab("Erweiterte Suche", pnlErweiterteSuche);
JTextArea txtLanguageMenu = new JTextArea();
txtLanguageMenu.setText("deutsch | english | francais | italiano");
txtLanguageMenu.setBounds(480, 0, 200, 20);
this.getContentPane().add(txtLanguageMenu);
insertHeading("Start & Ziel", pnlVerbindungssuche, 0);
JLabel lblStartZielVon = new JLabel();
lblStartZielVon.setText("Von:");
lblStartZielVon.setBounds(0, 25, 100, 25);
pnlVerbindungssuche.add(lblStartZielVon);
JLabel lblStartZielNach = new JLabel();
lblStartZielNach.setText("Nach:");
lblStartZielNach.setBounds(0, 50, 100, 25);
pnlVerbindungssuche.add(lblStartZielNach);
JLabel lblStartZielBahnhofHaltestelleVon = new JLabel();
lblStartZielBahnhofHaltestelleVon.setText("Bahnhof/Haltestelle");
lblStartZielBahnhofHaltestelleVon.setBounds(100, 25, 150, 25);
lblStartZielBahnhofHaltestelleVon.setFont(lblStartZielBahnhofHaltestelleVon.getFont().deriveFont(Font.PLAIN));
pnlVerbindungssuche.add(lblStartZielBahnhofHaltestelleVon);
JLabel lblStartZielBahnhofHaltestelleNach = new JLabel();
lblStartZielBahnhofHaltestelleNach.setText("Bahnhof/Haltestelle");
lblStartZielBahnhofHaltestelleNach.setBounds(100, 50, 150, 25);
lblStartZielBahnhofHaltestelleNach.setFont(lblStartZielBahnhofHaltestelleNach.getFont().deriveFont(Font.PLAIN));
pnlVerbindungssuche.add(lblStartZielBahnhofHaltestelleNach);
txtStartZielVon.setBounds(250, 27, 300, 20);
txtStartZielVon.setBorder(BorderFactory.createLineBorder(Color.black));
pnlVerbindungssuche.add(txtStartZielVon);
txtStartZielNach.setBounds(250, 52, 300, 20);
txtStartZielNach.setBorder(BorderFactory.createLineBorder(Color.BLACK));
pnlVerbindungssuche.add(txtStartZielNach);
pnlVerbindungssuche.add(getInfoIcon(555, 27));
JButton btnStartZielUeber = new JButton();
btnStartZielUeber.setText("Über");
btnStartZielUeber.setBounds(555, 52, 65, 20);
pnlVerbindungssuche.add(btnStartZielUeber);
insertHeading("Reisedatum und -zeit", pnlVerbindungssuche, 75);
JLabel lblReisedatumHinfahrt = new JLabel();
lblReisedatumHinfahrt.setText("Hinfahrt:");
lblReisedatumHinfahrt.setBounds(0, 100, 100, 25);
pnlVerbindungssuche.add(lblReisedatumHinfahrt);
JLabel lblReisedatumHinfahrtDatum = new JLabel();
lblReisedatumHinfahrtDatum.setText("Datum:");
lblReisedatumHinfahrtDatum.setBounds(100, 100, 75, 25);
lblReisedatumHinfahrtDatum.setFont(lblReisedatumHinfahrtDatum.getFont().deriveFont(Font.PLAIN));
pnlVerbindungssuche.add(lblReisedatumHinfahrtDatum);
JLabel lblReisedatumHinfahrtUhrzeit = new JLabel();
lblReisedatumHinfahrtUhrzeit.setText("Uhrzeit:");
lblReisedatumHinfahrtUhrzeit.setBounds(100, 125, 50, 25);
lblReisedatumHinfahrtUhrzeit.setFont(lblReisedatumHinfahrtUhrzeit.getFont().deriveFont(Font.PLAIN));
pnlVerbindungssuche.add(lblReisedatumHinfahrtUhrzeit);
txtReisedatumHinfahrtDatum.setBounds(150, 102, 100, 20);
txtReisedatumHinfahrtDatum.setBorder(BorderFactory.createLineBorder(Color.black));
pnlVerbindungssuche.add(txtReisedatumHinfahrtDatum);
txtReisedatumHinfahrtUhrzeit.setBounds(150, 127, 50, 20);
txtReisedatumHinfahrtUhrzeit.setBorder(BorderFactory.createLineBorder(Color.black));
pnlVerbindungssuche.add(txtReisedatumHinfahrtUhrzeit);
cmbReisedatumHinfahrtUhrzeitType.setBounds(205, 127, 100, 20);
pnlVerbindungssuche.add(cmbReisedatumHinfahrtUhrzeitType);
JSeparator sepReisedatum = new JSeparator(SwingConstants.VERTICAL);
sepReisedatum.setBounds(315, 100, 1, 50);
sepReisedatum.setBackground(Color.LIGHT_GRAY);
pnlVerbindungssuche.add(sepReisedatum);
JLabel lblReisedatumRueckfahrt = new JLabel();
lblReisedatumRueckfahrt.setText("Rückfahrt:");
lblReisedatumRueckfahrt.setBounds(325, 100, 100, 25);
pnlVerbindungssuche.add(lblReisedatumRueckfahrt);
JLabel lblReisedatumRueckfahrtDatum = new JLabel();
lblReisedatumRueckfahrtDatum.setText("Datum:");
lblReisedatumRueckfahrtDatum.setBounds(425, 100, 75, 25);
lblReisedatumRueckfahrtDatum.setFont(lblReisedatumRueckfahrtDatum.getFont().deriveFont(Font.PLAIN));
pnlVerbindungssuche.add(lblReisedatumRueckfahrtDatum);
JLabel lblReisedatumRueckfahrtUhrzeit = new JLabel();
lblReisedatumRueckfahrtUhrzeit.setText("Uhrzeit:");
lblReisedatumRueckfahrtUhrzeit.setBounds(425, 125, 50, 25);
lblReisedatumRueckfahrtUhrzeit.setFont(lblReisedatumRueckfahrtUhrzeit.getFont().deriveFont(Font.PLAIN));
pnlVerbindungssuche.add(lblReisedatumRueckfahrtUhrzeit);
txtReisedatumRueckfahrtDatum.setBounds(475, 102, 100, 20);
txtReisedatumRueckfahrtDatum.setBorder(BorderFactory.createLineBorder(Color.black));
pnlVerbindungssuche.add(txtReisedatumRueckfahrtDatum);
txtReisedatumRueckfahrtUhrzeit.setBounds(475, 127, 50, 20);
txtReisedatumRueckfahrtUhrzeit.setBorder(BorderFactory.createLineBorder(Color.black));
pnlVerbindungssuche.add(txtReisedatumRueckfahrtUhrzeit);
cmbReisedatumRueckfahrtUhrzeitType.setBounds(530, 127, 100, 20);
pnlVerbindungssuche.add(cmbReisedatumRueckfahrtUhrzeitType);
insertHeading("Angaben zur Preisberechnung", pnlVerbindungssuche, 150);
JLabel lblPreisberechnungReisende = new JLabel();
lblPreisberechnungReisende.setText("Reisende:");
lblPreisberechnungReisende.setBounds(0, 175, 100, 25);
pnlVerbindungssuche.add(lblPreisberechnungReisende);
cmbPreisberechnungPersonType.setBounds(100, 177, 205, 20);
pnlVerbindungssuche.add(cmbPreisberechnungPersonType);
JButton btnPreisberechnungAdd = new JButton();
btnPreisberechnungAdd.setText("Personen hinzufügen");
btnPreisberechnungAdd.setBounds(100, 202, 160, 20);
pnlVerbindungssuche.add(btnPreisberechnungAdd);
pnlVerbindungssuche.add(getInfoIcon(265, 202));
cmbPreisberechnungRabattType.setBounds(315, 177, 210, 20);
pnlVerbindungssuche.add(cmbPreisberechnungRabattType);
JButton btnPreisberechnungAuslandspreise = new JButton();
btnPreisberechnungAuslandspreise.setText("Auslandspreise");
btnPreisberechnungAuslandspreise.setBounds(315, 202, 125, 20);
pnlVerbindungssuche.add(btnPreisberechnungAuslandspreise);
pnlVerbindungssuche.add(getInfoIcon(445, 202));
cmbPreisberechnungKlasse.setBounds(530, 177, 100, 20);
pnlVerbindungssuche.add(cmbPreisberechnungKlasse);
insertHeading("Angaben zur Verbindung", pnlVerbindungssuche, 225);
JLabel lblVerbindungVerkehrsmittel = new JLabel();
lblVerbindungVerkehrsmittel.setText("Verkehrsmittel:");
lblVerbindungVerkehrsmittel.setBounds(0, 250, 100, 25);
pnlVerbindungssuche.add(lblVerbindungVerkehrsmittel);
cmbVerbindungSucheType.setBounds(100, 252, 205, 20);
pnlVerbindungssuche.add(cmbVerbindungSucheType);
JButton btnVerbindungAdvanced = new JButton();
btnVerbindungAdvanced.setText("Erweitert");
btnVerbindungAdvanced.setBounds(315, 252, 100, 20);
pnlVerbindungssuche.add(btnVerbindungAdvanced);
pnlVerbindungssuche.add(getInfoIcon(420, 252));
chkVerbindungSchnelleVerbindung.setText("schnelle Verbindungen bevorzugen");
chkVerbindungSchnelleVerbindung.setBounds(100, 277, 235, 20);
pnlVerbindungssuche.add(chkVerbindungSchnelleVerbindung);
pnlVerbindungssuche.add(getInfoIcon(335, 277));
chkVerbindungFahrrad.setText("Fahrradmitnahme");
chkVerbindungFahrrad.setBounds(370, 277, 150, 20);
pnlVerbindungssuche.add(chkVerbindungFahrrad);
JSeparator sepControls = new JSeparator(SwingConstants.HORIZONTAL);
sepControls.setBounds(0, 300, 670, 1);
sepControls.setBackground(Color.LIGHT_GRAY);
pnlVerbindungssuche.add(sepControls);
btnVerbindungSuchen.addActionListener(this);
btnVerbindungSuchen.setBounds(0, 305, 150, 20);
pnlVerbindungssuche.add(btnVerbindungSuchen);
JButton btnVerbindungNeueAnfrage = new JButton();
btnVerbindungNeueAnfrage.setText("Neue Anfrage");
btnVerbindungNeueAnfrage.setBounds(155, 305, 125, 20);
pnlVerbindungssuche.add(btnVerbindungNeueAnfrage);
JButton btnMeinAnfrageprofil = new JButton();
btnMeinAnfrageprofil.setText("Mein Anfrageprofil");
btnMeinAnfrageprofil.setBounds(520, 305, 150, 20);
pnlVerbindungssuche.add(btnMeinAnfrageprofil);
this.getContentPane().add(tcMain);
WindowListener closeListener = new WindowAdapter() {
public void windowClosing(WindowEvent event) {
System.exit(0);
}
};
this.addWindowListener(closeListener);
}
/**
* Method to insert a heading to the JFrame.
*
* @param title Title of the heading.
* @param panel The parent panel of the heading.
* @param top The absolute top position of the heading.
*/
private void insertHeading(String title, JPanel panel, int top) {
JLabel lblStartZiel = new JLabel();
lblStartZiel.setText(title);
lblStartZiel.setOpaque(true);
lblStartZiel.setBackground(Color.decode("#ceccfe"));
lblStartZiel.setForeground(Color.decode("#1b0897"));
lblStartZiel.setBounds(0, top, 670, 25);
panel.add(lblStartZiel);
}
/**
* Get a JLabel with displaying the info icon.
*
* @param left The position on the x-axis.
* @param top The position on the y-axis.
* @return The label with info icon.
*/
private JLabel getInfoIcon(int left, int top) {
ImageIcon icon = (ImageIcon) UIManager.get("OptionPane.informationIcon");
Image imgFit = icon.getImage().getScaledInstance(20, 20, java.awt.Image.SCALE_SMOOTH);
JLabel lblInfoIcon = new JLabel(new ImageIcon(imgFit));
lblInfoIcon.setBounds(left, top, 20, 20);
return lblInfoIcon;
}
/**
* Method to react to events of the JFrame.
*
* @param event The event to react.
*/
public void actionPerformed(ActionEvent event) {
Object source = event.getSource();
if (source == btnVerbindungSuchen) {
String infoVerbindung = "";
infoVerbindung += String.format("Verbindung von %s nach %s.\n", txtStartZielVon.getText(), txtStartZielNach.getText());
infoVerbindung += String.format("Hinfahrt: %s am %s um %s Uhr.\n", cmbReisedatumHinfahrtUhrzeitType.getSelectedItem(), txtReisedatumHinfahrtDatum.getText(), txtReisedatumHinfahrtUhrzeit.getText());
infoVerbindung += String.format("Rückfahrt: %s am %s um %s Uhr.\n", cmbReisedatumRueckfahrtUhrzeitType.getSelectedItem(), txtReisedatumRueckfahrtDatum.getText(), txtReisedatumRueckfahrtUhrzeit.getText());
infoVerbindung += String.format("Reisende: %s (%s)\n", cmbPreisberechnungPersonType.getSelectedItem(), cmbPreisberechnungKlasse.getSelectedItem());
infoVerbindung += String.format("Ermäßigung: %s\n", cmbPreisberechnungRabattType.getSelectedItem());
if (chkVerbindungSchnelleVerbindung.isSelected()) {
if (chkVerbindungFahrrad.isSelected()) {
infoVerbindung += "Es soll die schnellste Verbindung mit Fahrradmitnahme gesucht werden.\n";
} else {
infoVerbindung += "Es soll die schnellste Verbindung gesucht werden.\n";
}
} else if (chkVerbindungFahrrad.isSelected()) {
infoVerbindung += "Es sollen nur Verbindungen mit Fahrradmitnahme angezeigt werden.\n";
}
JOptionPane.showMessageDialog(this, infoVerbindung, cmbVerbindungSucheType.getSelectedItem().toString(), JOptionPane.INFORMATION_MESSAGE);
}
}
}