Compare commits
51 Commits
70a0d0db83
...
main
Author | SHA1 | Date | |
---|---|---|---|
8d950c5704 | |||
|
cad9726d0d | ||
|
4c54ba5d4b | ||
|
1d523ed097 | ||
|
a64040170a | ||
|
59998680ad | ||
|
8429d5d7ae | ||
|
dd5284972c | ||
|
ba814ad400 | ||
|
238759ad89 | ||
|
8c5e3a705a | ||
|
a86661a37a | ||
|
929832b3aa | ||
|
b5d79e2b57 | ||
|
eadcc6fe1c | ||
|
b67396d350 | ||
|
b3bc487347 | ||
|
df2b1339d4 | ||
|
438fdeef0c | ||
|
a812a10736 | ||
|
28e9ad35b6 | ||
|
12b7b279c0 | ||
|
f829b973eb | ||
|
a661f40a7c | ||
|
233934e9b7 | ||
|
f5319538ad | ||
|
97ae6d91b6 | ||
|
c01b28001a | ||
|
f5853be7e1 | ||
|
f09b77cde5 | ||
|
68b4e77761 | ||
|
cd4e9e7187 | ||
|
17a117bc79 | ||
|
3cb31bb0a1 | ||
|
5277ba3836 | ||
|
0dbcbc0b64 | ||
|
c088211378 | ||
|
a38f51290a | ||
|
045ebe5e33 | ||
|
7705945e9e | ||
|
4aaf422d3b | ||
|
1d31b5950d | ||
|
f34040825c | ||
|
c933d61613 | ||
|
79c924b0dc | ||
|
43484e54f2 | ||
|
4fb8a4de2a | ||
|
970bc0ba91 | ||
|
280b47af7b | ||
|
4df804ebc9 | ||
|
69d7d9b4b9 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -26,4 +26,6 @@ bin/
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
.DS_Store
|
||||
/src/part2/aufg1/output_files/
|
||||
**/output_files/
|
||||
|
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal 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
|
8
.idea/encodings.xml
generated
Normal file
8
.idea/encodings.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/Medien/Input_Dateien/PLZOrt.TXT" charset="windows-1252" />
|
||||
<file url="file://$PROJECT_DIR$/Medien/Input_Dateien/Strassen.TXT" charset="windows-1252" />
|
||||
<file url="file://$PROJECT_DIR$/src/part2/aufg1/input_files/PLZOrt.txt" charset="ISO-8859-1" />
|
||||
</component>
|
||||
</project>
|
5
.idea/misc.xml
generated
Normal file
5
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,5 @@
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" project-jdk-name="openjdk-22" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/S2_Aufgaben.iml" filepath="$PROJECT_DIR$/S2_Aufgaben.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
124
.idea/uiDesigner.xml
generated
Normal file
124
.idea/uiDesigner.xml
generated
Normal 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>
|
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
BIN
Medien/Bilder/HackerUnicorn.png
Normal file
BIN
Medien/Bilder/HackerUnicorn.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.0 MiB |
BIN
Medien/Bilder/HackerUnicorn_Schäbig.png
Normal file
BIN
Medien/Bilder/HackerUnicorn_Schäbig.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 210 KiB |
BIN
Medien/Bilder/info_I.png
Normal file
BIN
Medien/Bilder/info_I.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 750 B |
BIN
Medien/Bilder/info_I_tiny.png
Normal file
BIN
Medien/Bilder/info_I_tiny.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 469 B |
BIN
Medien/Dokumente/Abgabe 14.05.24 aufg1.pdf
Normal file
BIN
Medien/Dokumente/Abgabe 14.05.24 aufg1.pdf
Normal file
Binary file not shown.
BIN
Medien/Dokumente/Abgabe 14.05.24 aufg2.pdf
Normal file
BIN
Medien/Dokumente/Abgabe 14.05.24 aufg2.pdf
Normal file
Binary file not shown.
BIN
Medien/Dokumente/Abgabe 14.05.24 aufg3.pdf
Normal file
BIN
Medien/Dokumente/Abgabe 14.05.24 aufg3.pdf
Normal file
Binary file not shown.
BIN
Medien/Dokumente/Abgabe 14.05.24.docx
Normal file
BIN
Medien/Dokumente/Abgabe 14.05.24.docx
Normal file
Binary file not shown.
5
Medien/Dokumente/Anmerkung.txt
Normal file
5
Medien/Dokumente/Anmerkung.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
Moodle meldet beim Versuch die Word-Datei einzufügen einen Fehler "Verbindung zum Server verloren"
|
||||
daher die Abgabe im PDF Format.
|
||||
Die Word Datei ist bei Gitea hochgeladen und kann dort heruntergeladen werden.
|
||||
|
||||
https://gitea.hb.dhbw-stuttgart.de/vanBos/S2_Aufgaben/src/branch/main/Medien/Dokumente/Abgabe%2014.05.24.docx
|
BIN
Medien/Dokumente/UML Random Übung.jpeg
Normal file
BIN
Medien/Dokumente/UML Random Übung.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 122 KiB |
BIN
Medien/Folien/Programmieren_12_EinAusgabe.pdf
Normal file
BIN
Medien/Folien/Programmieren_12_EinAusgabe.pdf
Normal file
Binary file not shown.
BIN
Medien/Folien/Programmieren_13_GenerischeProgrammierung.pdf
Normal file
BIN
Medien/Folien/Programmieren_13_GenerischeProgrammierung.pdf
Normal file
Binary file not shown.
BIN
Medien/Folien/Programmieren_14_Multithreading.pdf
Normal file
BIN
Medien/Folien/Programmieren_14_Multithreading.pdf
Normal file
Binary file not shown.
BIN
Medien/Folien/Programmieren_15_Swing_1.pdf
Normal file
BIN
Medien/Folien/Programmieren_15_Swing_1.pdf
Normal file
Binary file not shown.
11
README.md
11
README.md
@@ -8,7 +8,16 @@
|
||||
|
||||
- Abgabe der Ergebnisse des Selbststudiums am 26.04.2024
|
||||
<br>Sowohl SourceCode, PDF als auch Word Datei
|
||||
|
||||
- VL 2 Aufgabe 1 (Erstellen von Testdaten)
|
||||
- VL 2 Aufgabe 2 (StringTokenizer)
|
||||
- VL 3 Aufgabe 1 ([Int-] Stack)
|
||||
- a) IntStack
|
||||
- b) myGenericStack
|
||||
- c) Java built-in generic Stack
|
||||
- VL 3 Aufgabe 2 (Dynamischer Speicher einer Queue)
|
||||
- VL 3 Aufgabe 3 (ArrayList vs LinkedList)
|
||||
- VL 4 Aufgabe 1 (Threads counting)
|
||||
- VL 4 Aufgabe 2 (User - Printer)
|
||||
|
||||
- keine
|
||||
|
||||
|
@@ -1,17 +1,12 @@
|
||||
// Press Shift twice to open the Search Everywhere dialog and type `show whitespaces`,
|
||||
// then press Enter. You can now see whitespace characters in your code.
|
||||
|
||||
import part3.aufg3.Anwendung;
|
||||
|
||||
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
// Press Alt+Eingabe with your caret at the highlighted text to see how
|
||||
// IntelliJ IDEA suggests fixing it.
|
||||
System.out.println("Hello and welcome!");
|
||||
|
||||
// Press Umschalt+F10 or click the green arrow button in the gutter to run the code.
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
|
||||
// Press Umschalt+F9 to start debugging your code. We have set one breakpoint
|
||||
// for you, but you can always add more by pressing Strg+F8.
|
||||
System.out.println("i = " + i);
|
||||
}
|
||||
System.out.println("I am Main!");
|
||||
}
|
||||
}
|
@@ -28,9 +28,12 @@ public class PrimeFactorization {
|
||||
public static void main(String[] args) {
|
||||
int number = 120;
|
||||
|
||||
List<Integer> primeFactors = primeFactorization(number);
|
||||
for (int i = 0; i < number; i++) {
|
||||
|
||||
System.out.println("Prime factors of " + number + ": " + primeFactors);
|
||||
List<Integer> primeFactors = primeFactorization(i);
|
||||
|
||||
System.out.println("Prime factors of " + i + ": " + primeFactors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
53
src/part2/aufg1/Anwendung.java
Normal file
53
src/part2/aufg1/Anwendung.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package part2.aufg1;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileWriter;
|
||||
|
||||
public class Anwendung {
|
||||
public static void main(String[] args) {
|
||||
int startingNR = 0;
|
||||
int amountOfSets = 0;
|
||||
Console_Input reader = new Console_Input();
|
||||
String input;
|
||||
|
||||
while (!(startingNR<1_000_000 && startingNR>99_999)) {
|
||||
input = reader.getInput("enter a valid customer ID (6 Digit Integer)");
|
||||
startingNR = Integer.parseInt(input);
|
||||
}
|
||||
|
||||
while (!(amountOfSets>0 && amountOfSets<1000)) {
|
||||
input = reader.getInput("How many data Sets do you want? (1-999)");
|
||||
amountOfSets = Integer.parseInt(input);
|
||||
}
|
||||
|
||||
try {
|
||||
FileWriter out1 = new FileWriter("C:\\Users\\dh10mbo\\OneDrive - Durr Group\\Documents\\Uni\\S2\\Repos\\S2_Aufgaben\\src\\part2\\aufg1\\output_files\\spacedOut.txt");
|
||||
FileWriter out2 = new FileWriter("C:\\Users\\dh10mbo\\OneDrive - Durr Group\\Documents\\Uni\\S2\\Repos\\S2_Aufgaben\\src\\part2\\aufg1\\output_files\\CSVOut.txt");
|
||||
|
||||
BufferedWriter writer1 = new BufferedWriter(out1);
|
||||
BufferedWriter writer2 = new BufferedWriter(out2);
|
||||
|
||||
for (int i = 0; i < amountOfSets; i++) {
|
||||
CustomerData data = new CustomerData(startingNR++);
|
||||
String spacedData = data.getSpacedValues();
|
||||
System.out.println(spacedData);
|
||||
writer1.write(spacedData);
|
||||
writer1.newLine();
|
||||
|
||||
}
|
||||
for (int i = 0; i < amountOfSets; i++) {
|
||||
CustomerData data = new CustomerData(startingNR++);
|
||||
String csvData = data.getCSV();
|
||||
System.out.println(csvData);
|
||||
writer2.write(csvData);
|
||||
writer2.newLine();
|
||||
}
|
||||
|
||||
writer1.close();
|
||||
writer2.close();
|
||||
}
|
||||
catch (Exception e){
|
||||
System.out.println(e);
|
||||
}
|
||||
}
|
||||
}
|
24
src/part2/aufg1/Console_Input.java
Normal file
24
src/part2/aufg1/Console_Input.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package part2.aufg1;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
public class Console_Input {
|
||||
|
||||
public String getInput(String prompt) {
|
||||
String input = "";
|
||||
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
|
||||
System.out.println(prompt);
|
||||
input = reader.readLine();
|
||||
System.out.print("The following input was read: ");
|
||||
System.out.println(input);
|
||||
|
||||
} catch (Throwable e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
}
|
216
src/part2/aufg1/CustomerData.java
Normal file
216
src/part2/aufg1/CustomerData.java
Normal file
@@ -0,0 +1,216 @@
|
||||
package part2.aufg1;
|
||||
|
||||
import java.io.FileReader;
|
||||
import java.io.LineNumberReader;
|
||||
import java.util.Arrays;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
public class CustomerData {
|
||||
private int customNR; //count =6 digit
|
||||
private String firstName; //file 20 char
|
||||
private String lastName; //file 20 char
|
||||
private String street; //file 20 char
|
||||
private int postCode; //file =5 char
|
||||
private String city; //file 20 char
|
||||
private int houseNR; //random 5 digit
|
||||
private double amount; //random 500-2000
|
||||
private String fileEntryCSV;
|
||||
|
||||
CustomerData(int customNR){
|
||||
this.customNR = customNR;
|
||||
this.firstName = getRandomFirstName();
|
||||
this.lastName = getRandomLastName();
|
||||
this.street = getRandomStreet();
|
||||
this.houseNR = getRandomNumberBetween(1, 150);
|
||||
this.city = getRandomCityNCode();
|
||||
this.amount = getRandomNumberBetween(500, 2000);
|
||||
}
|
||||
|
||||
public void print(){
|
||||
System.out.println(this.customNR);
|
||||
System.out.println(this.firstName + " " + this.lastName);
|
||||
System.out.println(this.street + " " + this.houseNR);
|
||||
System.out.println(this.city);
|
||||
System.out.println(this.amount);
|
||||
}
|
||||
|
||||
StringField allFirstNames = new StringField();
|
||||
StringField allLastNames = new StringField();
|
||||
StringField allStreets = new StringField();
|
||||
StringField allCitiesNCodes = new StringField();
|
||||
|
||||
public void readFirstNames(){
|
||||
try{
|
||||
String line;
|
||||
int i = 0;
|
||||
|
||||
FileReader fileIN = new FileReader("C:\\Users\\dh10mbo\\OneDrive - Durr Group\\Documents\\Uni\\S2\\Repos\\S2_Aufgaben\\src\\part2\\aufg1\\input_files\\Vornamen.txt");
|
||||
LineNumberReader dataIN = new LineNumberReader(fileIN);
|
||||
|
||||
while ((line = dataIN.readLine()) != null) {
|
||||
allFirstNames.setData(line, i++);
|
||||
}
|
||||
fileIN.close();
|
||||
}
|
||||
catch (Throwable e){
|
||||
System.out.println("smth went wrong with reading the first names!");
|
||||
System.out.println(e);
|
||||
}
|
||||
}
|
||||
public void readLastNames(){
|
||||
try{
|
||||
String line;
|
||||
int i = 0;
|
||||
|
||||
FileReader fileIN = new FileReader("C:\\Users\\dh10mbo\\OneDrive - Durr Group\\Documents\\Uni\\S2\\Repos\\S2_Aufgaben\\src\\part2\\aufg1\\input_files\\Nachnamen.txt");
|
||||
LineNumberReader dataIN = new LineNumberReader(fileIN);
|
||||
|
||||
while ((line = dataIN.readLine()) != null) {
|
||||
allLastNames.setData(line, i++);
|
||||
}
|
||||
fileIN.close();
|
||||
}
|
||||
catch (Throwable e){
|
||||
System.out.println("smth went wrong with reading the last names!");
|
||||
System.out.println(e);
|
||||
}
|
||||
}
|
||||
public void readStreets(){
|
||||
try{
|
||||
String line;
|
||||
int i = 0;
|
||||
|
||||
FileReader fileIN = new FileReader("C:\\Users\\dh10mbo\\OneDrive - Durr Group\\Documents\\Uni\\S2\\Repos\\S2_Aufgaben\\src\\part2\\aufg1\\input_files\\Strassen.txt");
|
||||
LineNumberReader dataIN = new LineNumberReader(fileIN);
|
||||
|
||||
while ((line = dataIN.readLine()) != null) {
|
||||
allStreets.setData(line, i++);
|
||||
}
|
||||
|
||||
fileIN.close();
|
||||
}
|
||||
catch (Throwable e){
|
||||
System.out.println("smth went wrong with reading the streets!");
|
||||
System.out.println(e);
|
||||
}
|
||||
}
|
||||
public void readCities(){
|
||||
try{
|
||||
String line;
|
||||
int i = 0;
|
||||
|
||||
FileReader fileIN = new FileReader("C:\\Users\\dh10mbo\\OneDrive - Durr Group\\Documents\\Uni\\S2\\Repos\\S2_Aufgaben\\src\\part2\\aufg1\\input_files\\PLZOrt.txt");
|
||||
LineNumberReader dataIN = new LineNumberReader(fileIN);
|
||||
|
||||
while ((line = dataIN.readLine()) != null) {
|
||||
allCitiesNCodes.setData(line, i++);
|
||||
}
|
||||
fileIN.close();
|
||||
}
|
||||
catch (Throwable e){
|
||||
System.out.println("smth went wrong with reading the Cities!");
|
||||
System.out.println(e);
|
||||
}
|
||||
}
|
||||
|
||||
public String getRandomFirstName(){
|
||||
readFirstNames();
|
||||
|
||||
String name = null;
|
||||
int amountOfNames = allFirstNames.length();
|
||||
int index;
|
||||
|
||||
while (name == null){
|
||||
index = Math.toIntExact(Math.round(Math.random() * (amountOfNames-1)));
|
||||
name = allFirstNames.getData(index);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
public String getRandomLastName(){
|
||||
readLastNames();
|
||||
|
||||
String name = null;
|
||||
int amountOfNames = allLastNames.length();
|
||||
int index;
|
||||
|
||||
while (name == null){
|
||||
index = Math.toIntExact(Math.round(Math.random() * (amountOfNames-1)));
|
||||
name = allLastNames.getData(index);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
public String getRandomStreet(){
|
||||
readStreets();
|
||||
|
||||
String street = null;
|
||||
int amountOfStreets = allStreets.length();
|
||||
int index;
|
||||
|
||||
while (street == null){
|
||||
index = Math.toIntExact(Math.round(Math.random() * (amountOfStreets-1)));
|
||||
street = allStreets.getData(index);
|
||||
}
|
||||
return street;
|
||||
}
|
||||
public String getRandomCityNCode(){
|
||||
readCities();
|
||||
|
||||
String CityNCode = null;
|
||||
int amountOfStreets = allCitiesNCodes.length();
|
||||
int index;
|
||||
|
||||
while (CityNCode == null){
|
||||
index = Math.toIntExact(Math.round(Math.random() * (amountOfStreets-1)));
|
||||
CityNCode = allCitiesNCodes.getData(index);
|
||||
}
|
||||
return CityNCode;
|
||||
}
|
||||
public int getRandomNumberBetween(int min, int max){
|
||||
int result = 0;
|
||||
|
||||
while (!((min <= result) && (result <= max))){
|
||||
result = Math.toIntExact(Math.round(Math.random() * max));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getCSV(){
|
||||
this.fileEntryCSV = customNR + "#" + firstName + "#" + lastName + "#" + street + "#" + houseNR + "#" + city + "#" + amount;
|
||||
return this.fileEntryCSV;
|
||||
}
|
||||
private String addWhitespaceUntilLenght(String string, int length, char filler){
|
||||
if (string.length()>length){
|
||||
throw new RuntimeException("\nInput String \n" + string +"\nis longer than the allowed length of " + length);
|
||||
}else {
|
||||
while (string.length()<length){
|
||||
string += filler;
|
||||
}
|
||||
}
|
||||
return string;
|
||||
}
|
||||
public String getSpacedValues(){
|
||||
int customNR = this.customNR;
|
||||
String firstnameLocal = this.firstName;
|
||||
String lastnameLocal = this.lastName;
|
||||
String streetLocal = this.street;
|
||||
int houseNR = this.houseNR;
|
||||
String cityNCode = this.city;
|
||||
|
||||
String customNRString = addWhitespaceUntilLenght(customNR + "", 6, ' ');
|
||||
firstnameLocal = addWhitespaceUntilLenght(firstnameLocal, 20, ' ');
|
||||
lastnameLocal = addWhitespaceUntilLenght(lastnameLocal, 20, ' ');
|
||||
streetLocal = addWhitespaceUntilLenght(streetLocal, 20, ' ');
|
||||
String houseNRString = addWhitespaceUntilLenght(houseNR+"", 5, ' ');
|
||||
cityNCode = addWhitespaceUntilLenght(cityNCode, 26, ' '); // 26 because postCode is in there too
|
||||
|
||||
return customNRString + " " + firstnameLocal + " " + lastnameLocal + " " + streetLocal + " " + houseNRString + " " + cityNCode + " " + amount;
|
||||
}
|
||||
public static void main(String[] args){
|
||||
CustomerData data = new CustomerData(123456);
|
||||
|
||||
System.out.println(data.getRandomFirstName() + " " + data.getRandomLastName());
|
||||
System.out.println(data.getRandomStreet() + " " + data.getRandomNumberBetween(1, 150));
|
||||
System.out.println(data.getRandomCityNCode());
|
||||
System.out.println(data.getRandomNumberBetween(500, 2000) + "€");
|
||||
}
|
||||
}
|
32
src/part2/aufg1/StringField.java
Normal file
32
src/part2/aufg1/StringField.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package part2.aufg1;
|
||||
|
||||
public class StringField {
|
||||
private int length = 25;
|
||||
private String[] data = new String[length];
|
||||
|
||||
public void setAll(String[] data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public String[] getAll() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(String data, int index) {
|
||||
this.data[index] = data;
|
||||
}
|
||||
|
||||
public String getData(int index) {
|
||||
return data[index];
|
||||
}
|
||||
|
||||
public void printAll(){
|
||||
for (int i=0; i< data.length; i++){
|
||||
System.out.println(getData(i));
|
||||
}
|
||||
}
|
||||
|
||||
public int length(){
|
||||
return length;
|
||||
}
|
||||
}
|
12
src/part2/aufg1/input_files/Nachnamen.txt
Normal file
12
src/part2/aufg1/input_files/Nachnamen.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
Meier
|
||||
Kaiser
|
||||
Hellmann
|
||||
Fuchs
|
||||
Hampel
|
||||
Hinz
|
||||
Schmidt
|
||||
Andrack
|
||||
Zerlett
|
||||
Novincack
|
||||
Ullmann
|
||||
Mayer
|
25
src/part2/aufg1/input_files/PLZOrt.txt
Normal file
25
src/part2/aufg1/input_files/PLZOrt.txt
Normal file
@@ -0,0 +1,25 @@
|
||||
72160 Horb
|
||||
70179 Stuttgart
|
||||
70191 Stuttgart
|
||||
70192 Stuttgart
|
||||
70193 Stuttgart
|
||||
70195 Stuttgart
|
||||
70197 Stuttgart
|
||||
70199 Stuttgart
|
||||
70327 Stuttgart
|
||||
72070 T<>bingen
|
||||
72072 T<>bingen
|
||||
72074 T<>bingen
|
||||
72076 T<>bingen
|
||||
72181 Starzach
|
||||
72182 Eutingen
|
||||
72184 Eutingen
|
||||
72185 Empfingen
|
||||
72186 Empfingen
|
||||
72186 Weiherhof
|
||||
72187 V<>hringen
|
||||
72189 V<>hringen
|
||||
72202 Nagold
|
||||
72210 Altensteig
|
||||
72213 Altensteig
|
||||
72218 Wildberg
|
11
src/part2/aufg1/input_files/Strassen.txt
Normal file
11
src/part2/aufg1/input_files/Strassen.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
Hauptstr.
|
||||
Dorfstr.
|
||||
Rosenweg
|
||||
Nelkenweg
|
||||
Stuttgarter Str.
|
||||
Ulmer Str.
|
||||
Freiburger Str.
|
||||
Mönchner Str.
|
||||
Goetheweg
|
||||
Beethovenallee
|
||||
Schillerstr.
|
10
src/part2/aufg1/input_files/Vornamen.txt
Normal file
10
src/part2/aufg1/input_files/Vornamen.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
Frank
|
||||
Steffi
|
||||
Uschi
|
||||
Carola
|
||||
Susanne
|
||||
Marion
|
||||
Ingo
|
||||
Stefan
|
||||
Jochen
|
||||
Holger
|
49
src/part2/aufg2/Anwendung.java
Normal file
49
src/part2/aufg2/Anwendung.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package part2.aufg2;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
public class Anwendung {
|
||||
public static void main(String[] args){
|
||||
int numbers = 0;
|
||||
int words = 0;
|
||||
int tokens = 0;
|
||||
|
||||
String fileContent = "";
|
||||
|
||||
try{
|
||||
String line;
|
||||
FileReader fileIN = new FileReader("C:\\Users\\dh10mbo\\OneDrive - Durr Group\\Documents\\Uni\\S2\\Repos\\S2_Aufgaben\\src\\part2\\aufg2\\files\\input\\input.txt");
|
||||
LineNumberReader dataIN = new LineNumberReader(fileIN);
|
||||
|
||||
while ((line = dataIN.readLine()) != null) {
|
||||
fileContent += line + " ";
|
||||
}
|
||||
|
||||
dataIN.close();
|
||||
}
|
||||
catch (Throwable e){
|
||||
System.out.println("smth went wrong!");
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
StringTokenizer st = new StringTokenizer(fileContent);
|
||||
String token;
|
||||
while (st.hasMoreTokens()){
|
||||
token = st.nextToken();
|
||||
if (token.matches("\\d+")){
|
||||
numbers++;
|
||||
tokens++;
|
||||
System.out.println("Number: " + token);
|
||||
}else if (token.matches("[a-zäöüA-ZÄÖÜ]+")){
|
||||
words++;
|
||||
tokens++;
|
||||
System.out.println("Word: " + token);
|
||||
}
|
||||
}
|
||||
System.out.println("\n========================\n");
|
||||
System.out.println("Total Tokens : " + tokens);
|
||||
System.out.println("Numbers : " + numbers);
|
||||
System.out.println("Words : " + words);
|
||||
}
|
||||
}
|
2
src/part2/aufg2/files/input/input.txt
Normal file
2
src/part2/aufg2/files/input/input.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
Dieser Text hat 6 Worte und 2 Zahlen
|
||||
Das war eine Lüge es sind 13 und 4
|
87
src/part3/aufg1/Anwendung.java
Normal file
87
src/part3/aufg1/Anwendung.java
Normal file
@@ -0,0 +1,87 @@
|
||||
package part3.aufg1;
|
||||
|
||||
import java.util.Stack;
|
||||
|
||||
/**
|
||||
* a) Realisieren einen Integer‐Stapel. Dabei soll die Klasse Stack aber nicht verwendet
|
||||
* werden, sondern eine dynamische Struktur wie in der Vorlesung „Algorithmen und
|
||||
* Datenstrukturen“ vorgestellt selbst realisiert werden.
|
||||
* Schreiben Sie eine Klasse IntegerStack, die den Stapel mit den Methoden
|
||||
* public void push(int i) und
|
||||
* public int pop()
|
||||
* zur Verfügung stellt.
|
||||
* Schreiben Sie dann eine Klasse Anwendung, in der die Funktionalität Ihres Integer‐
|
||||
* Stapels anhand der im Skript vorgestellten Reihenfolge von Operationen demonstriert
|
||||
* wird.
|
||||
*
|
||||
* b) Realisieren Sie einen generischen Stapel und testen Sie auch diesen in einer
|
||||
* Anwendung.
|
||||
*
|
||||
* c) Realisieren Sie jetzt die Klasse Anwendung unter Verwendung der Klasse Stack aus
|
||||
* der Java‐Klassenbibliothek.
|
||||
*/
|
||||
|
||||
public class Anwendung {
|
||||
public void myIntStackDemo(){
|
||||
IntStack myIntStack = new IntStack();
|
||||
|
||||
myIntStack.print();
|
||||
myIntStack.p_push(7);
|
||||
myIntStack.p_push(3);
|
||||
myIntStack.p_push(8);
|
||||
myIntStack.p_push(2);
|
||||
|
||||
myIntStack.p_pop();
|
||||
myIntStack.p_pop();
|
||||
|
||||
myIntStack.p_push(7);
|
||||
|
||||
myIntStack.p_pop();
|
||||
myIntStack.p_pop();
|
||||
myIntStack.p_pop();
|
||||
}
|
||||
public void myGenericStackDemo(){
|
||||
GenericStack myStack = new GenericStack();
|
||||
|
||||
myStack.print();
|
||||
myStack.p_push(1);
|
||||
myStack.p_push('J');
|
||||
myStack.p_push(true);
|
||||
|
||||
myStack.p_pop();
|
||||
|
||||
myStack.p_push("\"Ich Liebe Generische Typen\"");
|
||||
}
|
||||
|
||||
public void notMyStack_Demo(){
|
||||
Stack javaStack = new Stack();
|
||||
|
||||
System.out.println(javaStack);
|
||||
javaStack.push(1);
|
||||
System.out.println(javaStack);
|
||||
javaStack.push('B');
|
||||
System.out.println(javaStack);
|
||||
javaStack.pop();
|
||||
System.out.println(javaStack);
|
||||
javaStack.push("\"Java kann Stacks!\"");
|
||||
System.out.println(javaStack);
|
||||
javaStack.pop();
|
||||
System.out.println(javaStack);
|
||||
javaStack.pop();
|
||||
System.out.println(javaStack);
|
||||
javaStack.push(true);
|
||||
System.out.println(javaStack);
|
||||
}
|
||||
public static void main(String[] args){
|
||||
Anwendung demo = new Anwendung();
|
||||
demo.myIntStackDemo();
|
||||
|
||||
System.out.println("=====/////======");
|
||||
|
||||
demo.myGenericStackDemo();
|
||||
|
||||
System.out.println("=====/////======");
|
||||
|
||||
demo.notMyStack_Demo();
|
||||
}
|
||||
}
|
51
src/part3/aufg1/GenericStack.java
Normal file
51
src/part3/aufg1/GenericStack.java
Normal file
@@ -0,0 +1,51 @@
|
||||
package part3.aufg1;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class GenericStack<T> {
|
||||
Object[] myArray;
|
||||
private int MAX_SIZE;
|
||||
private int firstFreeIndex;
|
||||
|
||||
public GenericStack(){
|
||||
this.MAX_SIZE = 100;
|
||||
this.firstFreeIndex = 0;
|
||||
this.myArray = new Object[MAX_SIZE];
|
||||
}
|
||||
|
||||
public void push(T t){
|
||||
this.myArray[this.firstFreeIndex] = t;
|
||||
this.firstFreeIndex++;
|
||||
}
|
||||
|
||||
public void p_push(T t){
|
||||
this.push(t);
|
||||
this.print();
|
||||
}
|
||||
|
||||
public T pop(){
|
||||
return (T) this.myArray[--this.firstFreeIndex];
|
||||
}
|
||||
|
||||
public T p_pop(){
|
||||
T temp = this.pop();
|
||||
this.print();
|
||||
return temp;
|
||||
}
|
||||
|
||||
public Object[] toArray(){
|
||||
Object[] retArray = new Object[this.firstFreeIndex];
|
||||
|
||||
if (this.firstFreeIndex<1){
|
||||
return new Object[0];
|
||||
}
|
||||
for (int i=0; i<firstFreeIndex; i++){
|
||||
retArray[i] = this.myArray[i];
|
||||
}
|
||||
return retArray;
|
||||
}
|
||||
|
||||
public void print(){
|
||||
System.out.println(Arrays.toString(this.toArray()));
|
||||
}
|
||||
}
|
51
src/part3/aufg1/IntStack.java
Normal file
51
src/part3/aufg1/IntStack.java
Normal file
@@ -0,0 +1,51 @@
|
||||
package part3.aufg1;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class IntStack {
|
||||
private int MAX_SIZE;
|
||||
private int[] myArray;
|
||||
private int firstFreeIndex;
|
||||
|
||||
public IntStack(){
|
||||
this.MAX_SIZE = 100;
|
||||
this.firstFreeIndex = 0;
|
||||
this.myArray = new int[MAX_SIZE];
|
||||
}
|
||||
|
||||
public void push(int value){
|
||||
this.myArray[this.firstFreeIndex] = value;
|
||||
this.firstFreeIndex++;
|
||||
}
|
||||
|
||||
public void p_push(int value){
|
||||
this.push(value);
|
||||
this.print();
|
||||
}
|
||||
|
||||
public int pop(){
|
||||
return this.myArray[--this.firstFreeIndex];
|
||||
}
|
||||
|
||||
public int p_pop(){
|
||||
int temp = this.pop();
|
||||
this.print();
|
||||
return temp;
|
||||
}
|
||||
|
||||
public int[] toArray(){
|
||||
int[] retArray = new int[firstFreeIndex];
|
||||
|
||||
if (firstFreeIndex<1){
|
||||
return new int[0];
|
||||
}
|
||||
for (int i=0; i<firstFreeIndex; i++){
|
||||
retArray[i] = this.myArray[i];
|
||||
}
|
||||
return retArray;
|
||||
}
|
||||
|
||||
public void print(){
|
||||
System.out.println(Arrays.toString(this.toArray()));
|
||||
}
|
||||
}
|
38
src/part3/aufg2/Anwendung.java
Normal file
38
src/part3/aufg2/Anwendung.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package part3.aufg2;
|
||||
|
||||
/**
|
||||
* Aufgabe 2
|
||||
* Ergänzen Sie das Beispiel der Schlange aus der Vorlesung, so dass sich die Feldgröße
|
||||
* dynamisch anpasst! Dabei soll
|
||||
* • bei einem Belegungsgrad von 80% die allokierte Feldgröße verdoppelt werden
|
||||
* • bei einem Belegungsgrad von 20% die allokierte Feldgröße halbiert werden
|
||||
* • die Feldgröße aber nie den Wert 20 unterschreiten
|
||||
*/
|
||||
|
||||
public class Anwendung {
|
||||
public static void main(String[] args){
|
||||
Schlenglein kleinesSchlenglein = new Schlenglein();
|
||||
|
||||
System.out.println(kleinesSchlenglein.getArrayLenght());
|
||||
|
||||
for (int i=0; i<43; i++){
|
||||
kleinesSchlenglein.add("a");
|
||||
}
|
||||
System.out.println(kleinesSchlenglein.getArrayLenght());
|
||||
|
||||
for (int i=0; i<35; i++){
|
||||
kleinesSchlenglein.get();
|
||||
}
|
||||
System.out.println(kleinesSchlenglein.getArrayLenght());
|
||||
|
||||
for (int i=0; i<4321; i++){
|
||||
kleinesSchlenglein.add("a");
|
||||
}
|
||||
System.out.println(kleinesSchlenglein.getArrayLenght());
|
||||
|
||||
for (int i=0; i<9999; i++){
|
||||
kleinesSchlenglein.get();
|
||||
}
|
||||
System.out.println(kleinesSchlenglein.getArrayLenght());
|
||||
}
|
||||
}
|
78
src/part3/aufg2/Schlenglein.java
Normal file
78
src/part3/aufg2/Schlenglein.java
Normal file
@@ -0,0 +1,78 @@
|
||||
package part3.aufg2;
|
||||
|
||||
public class Schlenglein <T>{
|
||||
|
||||
private Object[] myArray;
|
||||
private int numberOfElements;
|
||||
private int maxSize;
|
||||
|
||||
public Schlenglein(){
|
||||
this.numberOfElements = 0;
|
||||
this.maxSize = 100;
|
||||
myArray = new Object[this.maxSize];
|
||||
}
|
||||
|
||||
public void add(T t){
|
||||
this.myArray[this.numberOfElements] = t;
|
||||
this.numberOfElements++;
|
||||
attemptDynamicResize();
|
||||
}
|
||||
|
||||
public T get(){
|
||||
T retValue = (T) this.myArray[0];
|
||||
|
||||
for (int i=0; i<this.numberOfElements; i++){
|
||||
this.myArray[i] = this.myArray[i+1];
|
||||
}
|
||||
|
||||
this.numberOfElements--;
|
||||
attemptDynamicResize();
|
||||
return retValue;
|
||||
}
|
||||
|
||||
public int size(){
|
||||
return this.numberOfElements;
|
||||
}
|
||||
|
||||
public int getArrayLenght(){
|
||||
return this.maxSize;
|
||||
}
|
||||
|
||||
public boolean isEmpty(){
|
||||
return this.size()<=0;
|
||||
}
|
||||
|
||||
public void attemptDynamicResize(){
|
||||
if (numberOfElements < 0.2*maxSize){
|
||||
// Kleiner Machen
|
||||
Object[] temp = new Object[maxSize];
|
||||
|
||||
System.arraycopy(myArray, 0, temp, 0, maxSize);
|
||||
|
||||
maxSize /= 2;
|
||||
if (maxSize < 20){maxSize = 20;}
|
||||
|
||||
System.arraycopy(temp, 0, myArray, 0, maxSize);
|
||||
|
||||
} else if (numberOfElements > 0.8*maxSize) {
|
||||
// Größer Machen
|
||||
Object[] temp = new Object[maxSize];
|
||||
|
||||
System.arraycopy(myArray, 0, temp, 0, maxSize);
|
||||
|
||||
maxSize -=- maxSize;
|
||||
myArray = new Object[maxSize];
|
||||
|
||||
System.arraycopy(temp, 0, myArray, 0, maxSize / 2);
|
||||
}
|
||||
}
|
||||
|
||||
public void printAll(){
|
||||
System.out.print("[");
|
||||
for (int i = 0; i < this.size()-1; i++) {
|
||||
System.out.print(this.myArray[i] + ", ");
|
||||
}
|
||||
System.out.println(this.myArray[this.size()-1] + "]");
|
||||
|
||||
}
|
||||
}
|
100
src/part3/aufg3/Anwendung.java
Normal file
100
src/part3/aufg3/Anwendung.java
Normal file
@@ -0,0 +1,100 @@
|
||||
package part3.aufg3;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
|
||||
/**
|
||||
* Aufgabe 3
|
||||
* Es soll die Einfügeperformance der beiden Klassen LinkedList und ArrayList verglichen
|
||||
* werden.
|
||||
* Entwickeln Sie dazu ein Programm, das 10.000, 20.000, 50.000, 100.000, 200.000,
|
||||
* 500.000, 1.000.000, 2.000.000, 5.000.000, 10.000.000, 20.000.000 und 50.000.000
|
||||
* zufällig generierte Zeichenketten der Länge 10 bis 16 aufnimmt.
|
||||
* Führen Sie jede Messung 10‐mal durch und dokumentieren Sie die Werte! Berechnen Sie
|
||||
* jeweils den Mittelwert!
|
||||
*
|
||||
*
|
||||
* Verwenden Sie für die Zeitmessung folgenden Code:
|
||||
*
|
||||
* long timeStart = System.currentTimeMillis();
|
||||
* <Code, dessen Ausführungszeit gemessen werden soll>
|
||||
* long timeEnd = System.currentTimeMillis();
|
||||
* long elapsedTime = timeEnd - timeStart;
|
||||
*
|
||||
*/
|
||||
|
||||
public class Anwendung {
|
||||
|
||||
public static String getRandomString(int MIN_LENGTH, int MAX_LENGTH) {
|
||||
char[] alphabet = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
|
||||
int size;
|
||||
|
||||
do {
|
||||
size = (int) (Math.random() * (MAX_LENGTH+1));
|
||||
} while (size < MIN_LENGTH);
|
||||
|
||||
String output = "";
|
||||
int index;
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
index = (int) (Math.random() * alphabet.length);
|
||||
output += alphabet[index];
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
public static void fillWithRandomStrings(LinkedList<String> ls, int amount) {
|
||||
for (int i = 0; i < amount; i++) {
|
||||
ls.add(getRandomString(10, 16));
|
||||
}
|
||||
}
|
||||
|
||||
public static void fillWithRandomStrings(ArrayList<String> ls, int amount){
|
||||
for (int i=0; i<amount; i++){
|
||||
ls.add(getRandomString(10,16));
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
int stringsToAdd = 1000_000;
|
||||
long totalTimeSpent = 0;
|
||||
int measurements = 10;
|
||||
|
||||
for (int i = 0; i < measurements; i++) {
|
||||
|
||||
long timeStart = System.currentTimeMillis();
|
||||
|
||||
// LinkedList<String> ls = new LinkedList<>();
|
||||
ArrayList<String> ls = new ArrayList<>();
|
||||
|
||||
fillWithRandomStrings(ls, stringsToAdd);
|
||||
|
||||
long timeEnd = System.currentTimeMillis();
|
||||
long timeSpent = timeEnd-timeStart;
|
||||
totalTimeSpent += timeSpent;
|
||||
|
||||
System.out.println(timeSpent);
|
||||
}
|
||||
System.out.println("Average of " + measurements + ": " + (totalTimeSpent/measurements));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Linked List: ArrayLis:
|
||||
10k 10 single Time of 0 ??? 7
|
||||
20k 9 Here too ?? 11
|
||||
50k 24 22
|
||||
|
||||
100k 47 37
|
||||
200k 99 74
|
||||
500k 245 188
|
||||
|
||||
1Mil 737 350
|
||||
2Mil 1576 688
|
||||
5Mil 4173 1650
|
||||
|
||||
10Mil 8600 3300
|
||||
20Mil 17750 6690
|
||||
50Mil 43600 24860
|
||||
*/
|
12
src/part4/aufg1/Demo.java
Normal file
12
src/part4/aufg1/Demo.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package part4.aufg1;
|
||||
|
||||
public class Demo {
|
||||
public static void main(String[] args) {
|
||||
ThreadedCounter tc = new ThreadedCounter(-1,1);
|
||||
ThreadedCounter tC = new ThreadedCounter(4,2);
|
||||
|
||||
tc.start();
|
||||
tC.start();
|
||||
|
||||
}
|
||||
}
|
30
src/part4/aufg1/ThreadedCounter.java
Normal file
30
src/part4/aufg1/ThreadedCounter.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package part4.aufg1;
|
||||
|
||||
public class ThreadedCounter extends Thread {
|
||||
private final int threadNumber;
|
||||
private final int increment;
|
||||
static int sharedInt = 0;
|
||||
static int iterations = 0;
|
||||
|
||||
public ThreadedCounter(int increment, int threadNumber) {
|
||||
this.increment = increment;
|
||||
this.threadNumber = threadNumber;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
while (sharedInt < 1000){
|
||||
synchronized (getClass()) {
|
||||
iterations++;
|
||||
sharedInt += increment;
|
||||
System.out.println("Thread " + threadNumber + " made the shared Int: " + sharedInt);
|
||||
|
||||
try {
|
||||
sleep(10);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("it took " + iterations + " iterations");
|
||||
}
|
||||
}
|
28
src/part4/aufg2/Demo.java
Normal file
28
src/part4/aufg2/Demo.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package part4.aufg2;
|
||||
|
||||
/*
|
||||
In einem System arbeiten eine Reihe von Benutzer, die von Zeit zu Zeit
|
||||
Druckaufträge eines gewissen Umfangs erzeugen.
|
||||
Diese werden in einer Druckerwarteschlange verwaltet.
|
||||
Zwei Drucker stehen zur Verfügung und arbeiten die Aufträge ab.
|
||||
|
||||
Modellieren Sie das Problem als Erzeuger‐Verbraucher‐Problem und realisieren Sie es in Java.
|
||||
*/
|
||||
|
||||
|
||||
public class Demo {
|
||||
public static void main(String[] args) {
|
||||
int numUsers = 7;
|
||||
int numPrinter = 4;
|
||||
|
||||
for (int i = 1; i <= numUsers; i++) {
|
||||
User user = new User(i);
|
||||
user.start();
|
||||
}
|
||||
|
||||
for (int i = 1; i <= numPrinter ; i++) {
|
||||
Printer printer = new Printer(i);
|
||||
printer.start();
|
||||
}
|
||||
}
|
||||
}
|
31
src/part4/aufg2/Printer.java
Normal file
31
src/part4/aufg2/Printer.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package part4.aufg2;
|
||||
|
||||
public class Printer extends Thread {
|
||||
private int threadNumber;
|
||||
|
||||
public Printer(int threadNumber){
|
||||
this.threadNumber = threadNumber;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
while (true) {
|
||||
try {
|
||||
synchronized (Puwwer.q) {
|
||||
if (Puwwer.q.isEmpty()){
|
||||
try {
|
||||
Puwwer.q.wait();
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
System.out.println("Printer " + this.threadNumber + " prints " + Puwwer.q.get());
|
||||
}
|
||||
} catch (NullPointerException e){}
|
||||
try {
|
||||
sleep(100);
|
||||
} catch (InterruptedException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
7
src/part4/aufg2/Puwwer.java
Normal file
7
src/part4/aufg2/Puwwer.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package part4.aufg2;
|
||||
|
||||
import part3.aufg2.Schlenglein;
|
||||
|
||||
public class Puwwer {
|
||||
static Schlenglein q = new Schlenglein();
|
||||
}
|
36
src/part4/aufg2/User.java
Normal file
36
src/part4/aufg2/User.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package part4.aufg2;
|
||||
|
||||
public class User extends Thread {
|
||||
private int threadNumber;
|
||||
public User(int threadNumber) {
|
||||
this.threadNumber = threadNumber;
|
||||
}
|
||||
|
||||
public synchronized void makeRequest() {
|
||||
synchronized (Puwwer.q) {
|
||||
int randomInt = (int) (Math.random() * ((int) (Math.random() * 1000)));
|
||||
String randomIntStr = this.threadNumber + " " + randomInt;
|
||||
|
||||
Puwwer.q.add(randomIntStr);
|
||||
|
||||
System.out.println("User " + threadNumber + " added " + randomIntStr);
|
||||
|
||||
try {
|
||||
Puwwer.q.notify();
|
||||
} catch (IllegalMonitorStateException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void run() {
|
||||
while (true) {
|
||||
makeRequest();
|
||||
try {
|
||||
sleep(3000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
14
src/part5/Demo.java
Normal file
14
src/part5/Demo.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package part5;
|
||||
|
||||
public class Demo {
|
||||
public static void main(String[] args) {
|
||||
// for (int i = 0; i < 2; i++) {
|
||||
// Window w = new Window("My Java GUI");
|
||||
// w.display();
|
||||
// }
|
||||
|
||||
aufg gudWindow = new aufg("Mein Geniales GUI", 400, 340);
|
||||
gudWindow.loadDesign2();
|
||||
gudWindow.display(true);
|
||||
}
|
||||
}
|
88
src/part5/Window.java
Normal file
88
src/part5/Window.java
Normal file
@@ -0,0 +1,88 @@
|
||||
package part5;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.text.html.HTMLEditorKit;
|
||||
import java.awt.*;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.event.WindowListener;
|
||||
|
||||
public class Window {
|
||||
private String title;
|
||||
|
||||
public Window(String title){
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public JFrame setup(int height, int width){
|
||||
JFrame w = new JFrame();
|
||||
w.setVisible(true);
|
||||
w.setSize(width,height);
|
||||
w.setTitle(this.title);
|
||||
w.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
return w;
|
||||
}
|
||||
|
||||
public void display() {
|
||||
JFrame w = setup(700,700);
|
||||
|
||||
JPanel contentPane = new JPanel();
|
||||
|
||||
JButton textFeld = new JButton("Ich bin eine Beschriftung und lebe in einem Button");
|
||||
contentPane.add(textFeld);
|
||||
|
||||
JTextField text = new JFormattedTextField("Hello, I am a formatted Text field \nThis Linebreak may work");
|
||||
contentPane.add(text);
|
||||
|
||||
JLabel vorname = new JLabel("Vorname");
|
||||
JLabel nachname = new JLabel("Nachname");
|
||||
JLabel MatrikelNr = new JLabel("MatrikelNR.");
|
||||
JLabel password = new JLabel("Passwort");
|
||||
JLabel longText = new JLabel("Langer Text");
|
||||
|
||||
JTextField feldVorName = new JTextField(10);
|
||||
JTextField feldNachName = new JTextField(10);
|
||||
JPasswordField feldPassw = new JPasswordField(10);
|
||||
JTextArea feldLongText = new JTextArea(20,15);
|
||||
|
||||
contentPane.add(vorname);
|
||||
contentPane.add(feldVorName);
|
||||
contentPane.add(nachname);
|
||||
contentPane.add(feldNachName);
|
||||
contentPane.add(password);
|
||||
contentPane.add(feldPassw);
|
||||
|
||||
Icon i = new ImageIcon("Medien/Bilder/HackerUnicorn_Schäbig.png");
|
||||
JButton grafik = new JButton(i);
|
||||
contentPane.add(grafik);
|
||||
|
||||
contentPane.add((MatrikelNr));
|
||||
contentPane.add(longText);
|
||||
contentPane.add(feldLongText);
|
||||
|
||||
|
||||
w.setContentPane(contentPane);
|
||||
|
||||
|
||||
JMenuBar menuebar = new JMenuBar();
|
||||
JMenu file = new JMenu("file");
|
||||
JMenu help = new JMenu("help");
|
||||
|
||||
menuebar.add(file);
|
||||
menuebar.add(help);
|
||||
|
||||
JMenuItem fileOpen = new JMenuItem("open");
|
||||
JMenuItem fileClose = new JMenuItem("close");
|
||||
JMenuItem fileEdit = new JMenuItem("edit");
|
||||
JMenuItem helpInfo = new JMenuItem("info");
|
||||
JMenuItem helpUnsub = new JMenuItem("unsubscribe");
|
||||
|
||||
file.add(fileOpen);
|
||||
file.add(fileEdit);
|
||||
file.add(fileClose);
|
||||
help.add(helpInfo);
|
||||
help.add(helpUnsub);
|
||||
|
||||
w.setJMenuBar(menuebar);
|
||||
}
|
||||
}
|
246
src/part5/aufg.java
Normal file
246
src/part5/aufg.java
Normal file
@@ -0,0 +1,246 @@
|
||||
package part5;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
|
||||
public class aufg {
|
||||
private String title;
|
||||
private int height;
|
||||
private int width;
|
||||
private JFrame window;
|
||||
private JPanel contentPane;
|
||||
private JMenuBar menubar;
|
||||
|
||||
public aufg(String title, int height, int width){
|
||||
this.title = title;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.window = new JFrame();
|
||||
this.contentPane = new JPanel();
|
||||
this.menubar = new JMenuBar();
|
||||
}
|
||||
|
||||
public void display(boolean exitOnClose){
|
||||
this.window.setTitle(this.title);
|
||||
this.window.setSize(this.width, this.height);
|
||||
this.window.setContentPane(this.contentPane);
|
||||
this.window.setVisible(true);
|
||||
|
||||
if (exitOnClose){
|
||||
this.window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
}
|
||||
}
|
||||
|
||||
public void loadDesign2(){
|
||||
addMenuBar();
|
||||
addLabel("Von");
|
||||
addLabeledTextField("Bahnhof/Haltestelle", false);
|
||||
addImage("Medien/Bilder/info_I_tiny.png");
|
||||
addLabel("Nach");
|
||||
addLabeledTextField("Bahnhof/Haltestelle", false);
|
||||
addButton("über");
|
||||
addLabel("Hinfahrt");
|
||||
addLabeledTextField("Datum", false);
|
||||
addLabel("Rückfahrt");
|
||||
addLabeledTextField("Uhrzeit", false);
|
||||
// addDropdown(values = {"Abfahrt", "Ankunft"})
|
||||
addLabeledTextField("Uhrzeit", false);
|
||||
// addDropdown(values = {"Abfahrt", "Ankunft"})
|
||||
addLabel("Angaben zur Preisberechnung");
|
||||
addLabel("Reisende");
|
||||
// addDropdown(values = {"1 Erwachsener", "1 Student"})
|
||||
// addDropdown(values = {"Keine Ermäßigung", "20% Rabatt"})
|
||||
// addDropDown(values = {"2. Klasse", "1. Klasse"})
|
||||
addButton("Personen Hinzufügen");
|
||||
addImage("Medien/Bilder/info_I_tiny.png");
|
||||
addButton("Auslandspreise");
|
||||
addImage("Medien/Bilder/info_I_tiny.png");
|
||||
addLabel("Angaben zur Verbindung");
|
||||
addLabel("Verkehrsmittel: ");
|
||||
// addDropDown(values = {"Standartsuche", "Spezialsuche"})
|
||||
addButton("Erweitert");
|
||||
addImage("Medien/Bilder/info_I_tiny.png");
|
||||
// addCheckBox(label = "schnelle Verbindung bevorzugen")
|
||||
addImage("Medien/Bilder/info_I_tiny.png");
|
||||
// addCheckBox(label = "Fahrradmitnahme")
|
||||
addButton("Verbindung Suchen");
|
||||
addButton("Neue Anfrage");
|
||||
addButton("Mein Anfrageprofil");
|
||||
}
|
||||
|
||||
public void loadDesign(){
|
||||
addMenuBar();
|
||||
addLabeledTextField("TextBox", true);
|
||||
addLabeledPasswordField("Password", true);
|
||||
addImage("Medien/Bilder/info_I_tiny.png");
|
||||
addImage("Medien/Bilder/HackerUnicorn_Schäbig.png");
|
||||
addLabeledRadioButtons("First Set of radiobuttons", new String[] {"Option1", "Choice2", "Variant3"}, true);
|
||||
addLabeledRadioButtons("Second Group of Options", new String[] {"Maybe this?", "Or that"}, true);
|
||||
// popUpInputText(new String[] {"Choice1", "Option2"});
|
||||
popUpDropDown("Medien/Bilder/info_I_tiny.png",
|
||||
"Title of my Window",
|
||||
"choose your favourite",
|
||||
new String[] {"Choice1", "Option2"},
|
||||
"Option2");
|
||||
}
|
||||
|
||||
public void addMenuBar(){
|
||||
JMenu file = new JMenu("File");
|
||||
JMenuItem fileOpen = new JMenuItem("Open");
|
||||
JMenuItem fileEdit = new JMenuItem("Edit");
|
||||
JMenuItem fileClose = new JMenuItem("Close");
|
||||
file.add(fileOpen);
|
||||
file.add(fileEdit);
|
||||
file.add(fileClose);
|
||||
|
||||
JMenu help = new JMenu("Help");
|
||||
JMenuItem helpInfo = new JMenuItem("Info");
|
||||
JMenuItem helpUnsub = new JMenuItem("Unsubscribe");
|
||||
help.add(helpInfo);
|
||||
help.add(helpUnsub);
|
||||
|
||||
JMenu english = new JMenu("English");
|
||||
JMenuItem englishChangeTo = new JMenuItem("Change to English");
|
||||
english.add(englishChangeTo);
|
||||
|
||||
JMenu braile = new JMenu("Braile");
|
||||
JMenuItem braileChangeTo = new JMenuItem("Change to Braile");
|
||||
braile.add(braileChangeTo);
|
||||
|
||||
this.menubar.add(file);
|
||||
this.menubar.add(help);
|
||||
this.menubar.add(english);
|
||||
this.menubar.add(braile);
|
||||
|
||||
this.window.setJMenuBar(this.menubar);
|
||||
}
|
||||
|
||||
public void addLabel(String text){
|
||||
this.contentPane.add(makeLabel(text));
|
||||
}
|
||||
public JLabel makeLabel(String text){
|
||||
return new JLabel(text);
|
||||
}
|
||||
|
||||
public void addTextField(int columns){
|
||||
this.contentPane.add(makeTextField(columns));
|
||||
}
|
||||
public JTextField makeTextField(int columns){
|
||||
return new JTextField(columns);
|
||||
}
|
||||
|
||||
public void addLabeledTextField(String labelText, boolean makeVertical){
|
||||
this.contentPane.add(makeLabeledTextField(labelText,makeVertical));
|
||||
}
|
||||
public Box makeLabeledTextField(String labelText, boolean makeVertical){
|
||||
Box b;
|
||||
|
||||
if (makeVertical) {
|
||||
b = Box.createVerticalBox();
|
||||
}else{
|
||||
b = Box.createHorizontalBox();
|
||||
}
|
||||
|
||||
b.add(makeLabel(labelText));
|
||||
b.add(makeTextField(10));
|
||||
return b;
|
||||
}
|
||||
|
||||
public void addPasswordField(){
|
||||
this.contentPane.add(makePasswordField());
|
||||
}
|
||||
public JPasswordField makePasswordField(){
|
||||
return new JPasswordField(10);
|
||||
}
|
||||
|
||||
public void addLabeledPasswordField(String label, boolean makeVertical){
|
||||
this.contentPane.add(makeLabeledPasswordField(label,makeVertical));
|
||||
}
|
||||
public Box makeLabeledPasswordField(String label, boolean makeVertical){
|
||||
Box b;
|
||||
|
||||
if (makeVertical) {
|
||||
b = Box.createVerticalBox();
|
||||
}else{
|
||||
b = Box.createHorizontalBox();
|
||||
}
|
||||
|
||||
b.add(makeLabel(label));
|
||||
b.add(makePasswordField());
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
public void addTextArea(int rows, int cols){
|
||||
this.contentPane.add(makeTextArea(rows, cols));
|
||||
}
|
||||
public JTextArea makeTextArea(int rows, int cols){
|
||||
return new JTextArea(rows, cols);
|
||||
}
|
||||
|
||||
public void addImage(String link){
|
||||
this.contentPane.add(makeImage(link));
|
||||
}
|
||||
public JButton makeImage(String link){
|
||||
Icon i = new ImageIcon(link);
|
||||
return new JButton(i);
|
||||
}
|
||||
public void addRadioButtons(String[] options){
|
||||
this.contentPane.add(makeRadioButtons(options));
|
||||
}
|
||||
public Box makeRadioButtons(String[] options){
|
||||
Box b = Box.createVerticalBox();
|
||||
ButtonGroup group = new ButtonGroup();
|
||||
// this.contentPane.setLayout(new FlowLayout()); Don't know what this does,
|
||||
// Can't be bothered to look it up
|
||||
// Can be bothered to type this tho
|
||||
|
||||
for (String option: options){
|
||||
JRadioButton button = new JRadioButton(option);
|
||||
b.add(button);
|
||||
group.add(button);
|
||||
}
|
||||
|
||||
b.add(Box.createVerticalStrut(10));
|
||||
return b;
|
||||
}
|
||||
|
||||
public void addButton(String text){
|
||||
this.contentPane.add(makeButton(text));
|
||||
}
|
||||
public JButton makeButton(String text){
|
||||
return new JButton(text);
|
||||
}
|
||||
|
||||
public void addLabeledRadioButtons(String label, String[] options, boolean makeVertical){
|
||||
this.contentPane.add(makeLabeledRadioButtons(label, options, makeVertical));
|
||||
}
|
||||
public Box makeLabeledRadioButtons(String label, String[] options, boolean makeVertical){
|
||||
Box b;
|
||||
|
||||
if (makeVertical) {
|
||||
b = Box.createVerticalBox();
|
||||
}else{
|
||||
b = Box.createHorizontalBox();
|
||||
}
|
||||
b.add(makeLabel(label));
|
||||
b.add(makeRadioButtons(options));
|
||||
return b;
|
||||
}
|
||||
|
||||
public String popUpInputText(String[] values){
|
||||
return (String) JOptionPane.showInputDialog(this.contentPane, values);
|
||||
}
|
||||
|
||||
public String popUpDropDown(String iconLink, String title, String message, String[] values, String initialSelection){
|
||||
return (String) JOptionPane.showInputDialog(
|
||||
this.contentPane,
|
||||
message,
|
||||
title,
|
||||
JOptionPane.INFORMATION_MESSAGE,
|
||||
new ImageIcon(iconLink),
|
||||
values,
|
||||
initialSelection);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user