aa
This commit is contained in:
0
untitled/.idea/.gitignore → .idea/.gitignore
generated
vendored
0
untitled/.idea/.gitignore → .idea/.gitignore
generated
vendored
6
.idea/misc.xml
generated
Normal file
6
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="20" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
9
.idea/modules.xml
generated
Normal file
9
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/AuD/AuD.iml" filepath="$PROJECT_DIR$/AuD/AuD.iml" />
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/FH.iml" filepath="$PROJECT_DIR$/FH.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>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
public class Main{
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Link mittleresElement = new Link(T,"Test");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
0
untitled/.gitignore → AuD/.gitignore
vendored
0
untitled/.gitignore → AuD/.gitignore
vendored
0
untitled/.idea/vcs.xml → AuD/.idea/vcs.xml
generated
0
untitled/.idea/vcs.xml → AuD/.idea/vcs.xml
generated
@@ -1,3 +1,5 @@
|
|||||||
|
package UEB01;
|
||||||
|
|
||||||
// Press Shift twice to open the Search Everywhere dialog and type `show whitespaces`,
|
// 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.
|
// then press Enter. You can now see whitespace characters in your code.
|
||||||
public class Main {
|
public class Main {
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
package UEB01;
|
||||||
|
|
||||||
public class StopUhr
|
public class StopUhr
|
||||||
{
|
{
|
||||||
private long startTime, stopTime;
|
private long startTime, stopTime;
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
package UEB01;
|
||||||
|
|
||||||
public class Zeitmessung
|
public class Zeitmessung
|
||||||
{
|
{
|
||||||
static int tuWasCounter = 0;
|
static int tuWasCounter = 0;
|
||||||
20
AuD/src/UEB03/Link.java
Normal file
20
AuD/src/UEB03/Link.java
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
package UEB03;
|
||||||
|
|
||||||
|
public class Link<T>
|
||||||
|
{
|
||||||
|
public T daten;
|
||||||
|
public Link<T> naechster;
|
||||||
|
|
||||||
|
public Link(T daten, Link<T> naechster)
|
||||||
|
{
|
||||||
|
assert(daten != null);
|
||||||
|
|
||||||
|
this.daten = daten;
|
||||||
|
this.naechster = naechster;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return daten.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
189
AuD/src/UEB03/Liste.java
Normal file
189
AuD/src/UEB03/Liste.java
Normal file
@@ -0,0 +1,189 @@
|
|||||||
|
package UEB03;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class Liste<T>
|
||||||
|
{
|
||||||
|
protected Link<T> anfang;
|
||||||
|
protected Link<T> ende;
|
||||||
|
|
||||||
|
public Liste()
|
||||||
|
{
|
||||||
|
// Leere Liste: alle Zeiger sind null (Standardwerte)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Einfachster Fall und gleichzeitig Sonderfall:
|
||||||
|
// Element am Anfang einf<6E>gen
|
||||||
|
public void einfuegen(final T daten)
|
||||||
|
{
|
||||||
|
// Funktioniert immer
|
||||||
|
anfang = new Link<T>(daten, anfang);
|
||||||
|
|
||||||
|
// Bei einer leeren Liste muss auch ende gesetzt werden
|
||||||
|
if (ende == null)
|
||||||
|
ende = anfang;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Einfachster Fall und gleichzeitig Sonderfall:
|
||||||
|
// Element am Anfang entfernen
|
||||||
|
public T entfernen()
|
||||||
|
{
|
||||||
|
T opfer = null;
|
||||||
|
|
||||||
|
// Clowns k<>nnten diese Methode bei leerer Liste aufrufen
|
||||||
|
if (!istLeer())
|
||||||
|
{
|
||||||
|
// Bei einer Liste mit nur noch einem Element muss
|
||||||
|
// auch ende gel<65>scht werden
|
||||||
|
if (anfang == ende)
|
||||||
|
ende = null;
|
||||||
|
|
||||||
|
opfer = anfang.daten;
|
||||||
|
anfang = anfang.naechster;
|
||||||
|
}
|
||||||
|
|
||||||
|
return opfer;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Einfacher Fall: Anf<6E>gen am Ende der Liste
|
||||||
|
public void anfuegen(final T daten)
|
||||||
|
{
|
||||||
|
// Neuen Link anlegen
|
||||||
|
Link<T> neu = new Link<T>(daten, null);
|
||||||
|
|
||||||
|
// Wenn die Liste leer ist, m<>ssen anfang und ende gesetzt werden
|
||||||
|
if (istLeer())
|
||||||
|
{
|
||||||
|
// Neuen Link als anfang der Liste
|
||||||
|
anfang = ende = neu;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Anf<6E>gen des Elements an das bisherige ende
|
||||||
|
ende = ende.naechster = neu;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// EINF<4E>GEN AN EINER BESTIMMTEN STELLE
|
||||||
|
// Der Programmcode ist so gestaltet, dass er fehlerhafte Eingaben
|
||||||
|
// (z.B. eine negative oder zu hohe Position) elegant verarbeitet
|
||||||
|
// ohne abzust<73>rzen.
|
||||||
|
public void einfuegen(final T daten, int position)
|
||||||
|
{
|
||||||
|
// Wenn die Liste leer oder die Position 0 ist, entspricht dies
|
||||||
|
// einem Einf<6E>gen am Anfang
|
||||||
|
if (istLeer() || (position <= 0))
|
||||||
|
{
|
||||||
|
einfuegen(daten);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// VORG<52>NGER ZUR POSITION FINDEN
|
||||||
|
// Dessen Vorg<72>nger muss es geben: lediglich bei einer leeren
|
||||||
|
// Liste oder f<>r position==0 gibt es keinen. Genau diese F<>lle
|
||||||
|
// wurden aber oben bereits behandelt! Wird eine zu hohe position
|
||||||
|
// <20>bergeben, wird automatisch das letzte Element zum Vorg<72>nger.
|
||||||
|
Link<T> vorgaenger = anfang;
|
||||||
|
|
||||||
|
while ((--position > 0) && (vorgaenger.naechster != null))
|
||||||
|
vorgaenger = vorgaenger.naechster;
|
||||||
|
|
||||||
|
// Neues Element erzeugen
|
||||||
|
vorgaenger.naechster = new Link<T>(daten, vorgaenger.naechster);
|
||||||
|
|
||||||
|
// Beim Einf<6E>gen als letztes Element muss auch ende gesetzt werden
|
||||||
|
if (vorgaenger == ende)
|
||||||
|
ende = vorgaenger.naechster;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T entfernen(int position)
|
||||||
|
{
|
||||||
|
// Wenn die Liste leer oder die position < 0 ist, wird kein Element
|
||||||
|
// entfernt
|
||||||
|
if (istLeer() || (position < 0))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// Wenn die position 0 ist, wird am Anfang der Liste gel<65>scht
|
||||||
|
if (position == 0)
|
||||||
|
return entfernen();
|
||||||
|
|
||||||
|
// VORG<52>NGER ZUR POSITION FINDEN
|
||||||
|
// Bei einer leeren Liste oder f<>r position==0 gibt es keinen Vorg<72>nger;
|
||||||
|
// genau diese F<>lle wurden oben bereits behandelt. Es gibt aber auch
|
||||||
|
// keinen Vorg<72>ner, wenn position zu gro<72> ist! In diesem Fall wird das
|
||||||
|
// letzte Element NICHT Vorg<72>nger, damit nur tats<74>chlich existierende
|
||||||
|
// Elemente aus der Liste entfernt werden.
|
||||||
|
Link<T> vorgaenger = anfang;
|
||||||
|
|
||||||
|
while ((--position > 0) && (vorgaenger != null))
|
||||||
|
vorgaenger = vorgaenger.naechster;
|
||||||
|
|
||||||
|
// Gibt es ein Element zum l<>schen?
|
||||||
|
if ((vorgaenger == null) || (vorgaenger.naechster == null))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
final T opfer = vorgaenger.naechster.daten;
|
||||||
|
|
||||||
|
// Element l<>schen und ggf. ende anpassen beim L<>schen des letzten
|
||||||
|
// Listen-Elements
|
||||||
|
if ((vorgaenger.naechster = vorgaenger.naechster.naechster) == null)
|
||||||
|
ende = vorgaenger;
|
||||||
|
|
||||||
|
return opfer;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Liefert die Position eines bestimmten Elements oder -1 zur<75>ck.
|
||||||
|
// Existiert ein Element mehrfach, wird die Position des ersten Vorkommens
|
||||||
|
// zur<75>ckgegeben.
|
||||||
|
public int suchen(final T daten)
|
||||||
|
{
|
||||||
|
// Liste leer?
|
||||||
|
if (istLeer())
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
Link<T> zeiger = anfang;
|
||||||
|
int position = 0;
|
||||||
|
|
||||||
|
// Abfrage auf Gleichheit ist m<>glich mit equals (Operation von der Klasse Object)
|
||||||
|
while ((zeiger != null) && !zeiger.daten.equals(daten))
|
||||||
|
{
|
||||||
|
position++;
|
||||||
|
zeiger = zeiger.naechster;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (zeiger == null) ? -1 : position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ListeIterator<T> iterator()
|
||||||
|
{
|
||||||
|
return new ListeIterator<T>(anfang, ende);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pr<50>fen, ob Liste leer ist
|
||||||
|
public boolean istLeer()
|
||||||
|
{
|
||||||
|
return anfang==null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void verketten(Liste<T> zweiteListe)
|
||||||
|
{
|
||||||
|
assert(zweiteListe != null);
|
||||||
|
|
||||||
|
ende.naechster = zweiteListe.anfang;
|
||||||
|
ende= zweiteListe.ende;
|
||||||
|
zweiteListe.anfang = null;
|
||||||
|
zweiteListe.ende = null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int entferneWerte(final T opfer)
|
||||||
|
{
|
||||||
|
int anzGeloeschte = 0;
|
||||||
|
|
||||||
|
// Diese Methode wird im Praktikum implementiert
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
return anzGeloeschte;
|
||||||
|
}
|
||||||
|
}
|
||||||
47
AuD/src/UEB03/ListeCanvas.java
Normal file
47
AuD/src/UEB03/ListeCanvas.java
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
package UEB03;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class ListeCanvas extends Canvas
|
||||||
|
{
|
||||||
|
private Liste eineListe;
|
||||||
|
|
||||||
|
public void zeichneNeu(Liste eineListe)
|
||||||
|
{
|
||||||
|
this.eineListe = eineListe;
|
||||||
|
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void paint(Graphics g)
|
||||||
|
{
|
||||||
|
ListeIterator it = eineListe.iterator();
|
||||||
|
int x = 0;
|
||||||
|
int y = 30;
|
||||||
|
int position = 0;
|
||||||
|
|
||||||
|
while (it.hasNext())
|
||||||
|
{
|
||||||
|
g.setColor(new Color(0xE8, 0xE8, 0xFF));
|
||||||
|
g.fillRect(x+1, y+1, 30, 20);
|
||||||
|
|
||||||
|
g.setColor(Color.blue);
|
||||||
|
g.drawRect(x, y, 30, 20);
|
||||||
|
|
||||||
|
g.drawString(it.next().toString(), x + 1, y + 19);
|
||||||
|
|
||||||
|
if (it.hasNext())
|
||||||
|
{
|
||||||
|
g.setColor(Color.black);
|
||||||
|
g.drawLine(x + 30, y + 10, x + 45, y + 10);
|
||||||
|
g.drawLine(x + 45, y + 10, x + 40, y + 5);
|
||||||
|
g.drawLine(x + 45, y + 10, x + 40, y + 15);
|
||||||
|
}
|
||||||
|
|
||||||
|
g.setColor(Color.gray);
|
||||||
|
g.drawString("" + position++, x - 1, y + 35);
|
||||||
|
|
||||||
|
x = x + 45;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
202
AuD/src/UEB03/ListeGUI.java
Normal file
202
AuD/src/UEB03/ListeGUI.java
Normal file
@@ -0,0 +1,202 @@
|
|||||||
|
package UEB03;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.*;
|
||||||
|
import java.applet.*;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class ListeGUI extends Frame
|
||||||
|
{
|
||||||
|
//Attribute
|
||||||
|
protected Label wertFuehrungstext;
|
||||||
|
protected TextField wertTextfeld;
|
||||||
|
protected Label positionFuehrungstext;
|
||||||
|
protected TextField positionTextfeld;
|
||||||
|
protected Button einfuegenDruckknopf;
|
||||||
|
protected Button anhaengenDruckknopf;
|
||||||
|
protected Button entfernenDruckknopf;
|
||||||
|
protected Button alleEntfernenDruckknopf;
|
||||||
|
protected Button traversierenDruckknopf;
|
||||||
|
protected Button suchenDruckknopf;
|
||||||
|
protected Label ausgabeFuehrungstext;
|
||||||
|
protected TextArea ausgabeTextbereich;
|
||||||
|
|
||||||
|
protected Liste<Character> eineListe;
|
||||||
|
protected ListeCanvas eineZeichenflaeche; //Zeichenfl<66>che f<>r die Animation
|
||||||
|
|
||||||
|
//Operationen
|
||||||
|
public ListeGUI()
|
||||||
|
{
|
||||||
|
setTitle("Verkettete Liste");
|
||||||
|
setLayout(null);
|
||||||
|
setSize(492,315);
|
||||||
|
add(eineZeichenflaeche = new ListeCanvas());
|
||||||
|
eineZeichenflaeche.setBounds(32,32,430,80);
|
||||||
|
add(wertFuehrungstext= new Label());
|
||||||
|
wertFuehrungstext.setText("Wert:");
|
||||||
|
wertFuehrungstext.setBounds(30,112,58,23);
|
||||||
|
add(wertTextfeld = new TextField());
|
||||||
|
wertTextfeld.setBounds(90,112,45,23);
|
||||||
|
add(positionFuehrungstext= new Label());
|
||||||
|
positionFuehrungstext.setText("Position:");
|
||||||
|
positionFuehrungstext.setBounds(30,137,58,23);
|
||||||
|
add(positionTextfeld = new TextField());
|
||||||
|
positionTextfeld.setBounds(90,137,45,23);
|
||||||
|
add(einfuegenDruckknopf = new Button());
|
||||||
|
einfuegenDruckknopf.setLabel("Einf<EFBFBD>gen");
|
||||||
|
einfuegenDruckknopf.setBounds(30,170,100,23);
|
||||||
|
add(anhaengenDruckknopf = new Button());
|
||||||
|
anhaengenDruckknopf.setLabel("Anh<EFBFBD>ngen");
|
||||||
|
anhaengenDruckknopf.setBounds(140,170,100,23);
|
||||||
|
add(entfernenDruckknopf = new Button());
|
||||||
|
entfernenDruckknopf.setLabel("Entfernen");
|
||||||
|
entfernenDruckknopf.setBounds(250,170,100,23);
|
||||||
|
add(alleEntfernenDruckknopf = new Button());
|
||||||
|
alleEntfernenDruckknopf.setLabel("Alle entfernen");
|
||||||
|
alleEntfernenDruckknopf.setBounds(360,170,100,23);
|
||||||
|
add(traversierenDruckknopf = new Button());
|
||||||
|
traversierenDruckknopf.setLabel("Traversieren");
|
||||||
|
traversierenDruckknopf.setBounds(30,220,100,23);
|
||||||
|
add(suchenDruckknopf = new Button());
|
||||||
|
suchenDruckknopf.setLabel("Suchen");
|
||||||
|
suchenDruckknopf.setBounds(140,220,100,23);
|
||||||
|
add(ausgabeFuehrungstext= new Label());
|
||||||
|
ausgabeFuehrungstext.setText("Ausgabe:");
|
||||||
|
ausgabeFuehrungstext.setBounds(30,255,58,23);
|
||||||
|
add(ausgabeTextbereich = new TextArea("", 1, 1000, TextArea.SCROLLBARS_NONE));
|
||||||
|
ausgabeTextbereich.setBounds(90,255,370,23);
|
||||||
|
ausgabeTextbereich.setEnabled(false);
|
||||||
|
|
||||||
|
// Registrieren der Ereignisabh<62>rer
|
||||||
|
AktionsAbhoerer einAktionsAbhoerer = new AktionsAbhoerer();
|
||||||
|
einfuegenDruckknopf.addActionListener(einAktionsAbhoerer);
|
||||||
|
anhaengenDruckknopf.addActionListener(einAktionsAbhoerer);
|
||||||
|
entfernenDruckknopf.addActionListener(einAktionsAbhoerer);
|
||||||
|
alleEntfernenDruckknopf.addActionListener(einAktionsAbhoerer);
|
||||||
|
suchenDruckknopf.addActionListener(einAktionsAbhoerer);
|
||||||
|
traversierenDruckknopf.addActionListener(einAktionsAbhoerer);
|
||||||
|
|
||||||
|
// Test f<>r Verkettung zweier Listen
|
||||||
|
eineListe = new Liste<Character>();
|
||||||
|
eineListe.anfuegen(new Character('A'));
|
||||||
|
eineListe.anfuegen(new Character('B'));
|
||||||
|
Liste<Character> zweiteListe = new Liste<Character>();
|
||||||
|
zweiteListe.anfuegen(new Character('C'));
|
||||||
|
zweiteListe.anfuegen(new Character('D'));
|
||||||
|
eineListe.verketten(zweiteListe);
|
||||||
|
|
||||||
|
eineZeichenflaeche.zeichneNeu(eineListe);
|
||||||
|
|
||||||
|
addWindowListener(
|
||||||
|
new WindowAdapter()
|
||||||
|
{
|
||||||
|
public void windowClosing(WindowEvent e)
|
||||||
|
{
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Innere Klasse f<>r die Ereignisabh<62>rer
|
||||||
|
class AktionsAbhoerer implements ActionListener
|
||||||
|
{
|
||||||
|
private Character getCharacter()
|
||||||
|
{
|
||||||
|
final String s = wertTextfeld.getText();
|
||||||
|
|
||||||
|
return (s.length() > 0) ? s.charAt(0) : '?';
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getPosition()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return Integer.valueOf(positionTextfeld.getText());
|
||||||
|
}
|
||||||
|
catch(NumberFormatException e)
|
||||||
|
{
|
||||||
|
ausgabeTextbereich.setText("Es wurde kein Position angegeben. Standardwert: 0 (Listenanfang)");
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void finish()
|
||||||
|
{
|
||||||
|
wertTextfeld.setText("");
|
||||||
|
positionTextfeld.setText("");
|
||||||
|
|
||||||
|
eineZeichenflaeche.zeichneNeu(eineListe);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void finish(final String ausgabe)
|
||||||
|
{
|
||||||
|
ausgabeTextbereich.setText(ausgabe);
|
||||||
|
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void actionPerformed(ActionEvent event)
|
||||||
|
{
|
||||||
|
Object o = event.getSource();
|
||||||
|
ausgabeTextbereich.setText("");
|
||||||
|
|
||||||
|
if (o == einfuegenDruckknopf)
|
||||||
|
{
|
||||||
|
eineListe.einfuegen(getCharacter(), getPosition());
|
||||||
|
finish();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (o == anhaengenDruckknopf)
|
||||||
|
{
|
||||||
|
eineListe.anfuegen(getCharacter());
|
||||||
|
finish();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (o == entfernenDruckknopf)
|
||||||
|
{
|
||||||
|
if (eineListe.entfernen(getPosition()) == null)
|
||||||
|
ausgabeTextbereich.setText("Es wurde kein Opfer gefunden!");
|
||||||
|
|
||||||
|
finish();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (o == suchenDruckknopf)
|
||||||
|
{
|
||||||
|
final int position = eineListe.suchen(getCharacter());
|
||||||
|
finish(position == -1 ? "Der Wert wurde nicht gefunden." : "Der gesuchte Wert wird zum ersten Mal an Position " + position + " gefunden.");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (o == alleEntfernenDruckknopf)
|
||||||
|
{
|
||||||
|
finish(eineListe.entferneWerte(getCharacter()) + " Elemente wurden entfernt.");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (o == traversierenDruckknopf)
|
||||||
|
{
|
||||||
|
String ausgabe = "";
|
||||||
|
|
||||||
|
ListeIterator<Character> e = eineListe.iterator();
|
||||||
|
while (e.hasNext())
|
||||||
|
ausgabe += e.next() + " ";
|
||||||
|
|
||||||
|
finish(ausgabe);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
33
AuD/src/UEB03/ListeIterator.java
Normal file
33
AuD/src/UEB03/ListeIterator.java
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
package UEB03;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class ListeIterator<T> implements Iterator
|
||||||
|
{
|
||||||
|
private Link<T> zeiger;
|
||||||
|
private Link<T> ende;
|
||||||
|
|
||||||
|
ListeIterator(Link<T> start, Link<T> ende)
|
||||||
|
{
|
||||||
|
zeiger = start;
|
||||||
|
this.ende = ende;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasNext()
|
||||||
|
{
|
||||||
|
return zeiger != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T next()
|
||||||
|
{
|
||||||
|
final T daten = zeiger.daten;
|
||||||
|
zeiger = zeiger.naechster;
|
||||||
|
|
||||||
|
return daten;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove()
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
}
|
||||||
9
AuD/src/UEB03/ListeTest.java
Normal file
9
AuD/src/UEB03/ListeTest.java
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package UEB03;
|
||||||
|
|
||||||
|
public class ListeTest
|
||||||
|
{
|
||||||
|
public static void main(String[] args)
|
||||||
|
{
|
||||||
|
new ListeGUI().setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
10
AuD/src/UEB03/Main.java
Normal file
10
AuD/src/UEB03/Main.java
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package UEB03;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Link<String> ende = new Link<String>("Letzter", null);
|
||||||
|
Link<String> mittleresElement = new Link<String>("Test", ende);
|
||||||
|
Link<String> anfang= new Link<String>("TErster", mittleresElement);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
12
FH.iml
Normal file
12
FH.iml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/BP" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/EidP" isTestSource="false" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
BIN
out/production/AuD/UEB01/Main.class
Normal file
BIN
out/production/AuD/UEB01/Main.class
Normal file
Binary file not shown.
BIN
out/production/AuD/UEB01/StopUhr.class
Normal file
BIN
out/production/AuD/UEB01/StopUhr.class
Normal file
Binary file not shown.
BIN
out/production/AuD/UEB01/Zeitmessung.class
Normal file
BIN
out/production/AuD/UEB01/Zeitmessung.class
Normal file
Binary file not shown.
BIN
out/production/AuD/UEB03/Link.class
Normal file
BIN
out/production/AuD/UEB03/Link.class
Normal file
Binary file not shown.
BIN
out/production/AuD/UEB03/Liste.class
Normal file
BIN
out/production/AuD/UEB03/Liste.class
Normal file
Binary file not shown.
BIN
out/production/AuD/UEB03/ListeCanvas.class
Normal file
BIN
out/production/AuD/UEB03/ListeCanvas.class
Normal file
Binary file not shown.
BIN
out/production/AuD/UEB03/ListeGUI$1.class
Normal file
BIN
out/production/AuD/UEB03/ListeGUI$1.class
Normal file
Binary file not shown.
BIN
out/production/AuD/UEB03/ListeGUI$AktionsAbhoerer.class
Normal file
BIN
out/production/AuD/UEB03/ListeGUI$AktionsAbhoerer.class
Normal file
Binary file not shown.
BIN
out/production/AuD/UEB03/ListeGUI.class
Normal file
BIN
out/production/AuD/UEB03/ListeGUI.class
Normal file
Binary file not shown.
BIN
out/production/AuD/UEB03/ListeIterator.class
Normal file
BIN
out/production/AuD/UEB03/ListeIterator.class
Normal file
Binary file not shown.
BIN
out/production/AuD/UEB03/ListeTest.class
Normal file
BIN
out/production/AuD/UEB03/ListeTest.class
Normal file
Binary file not shown.
BIN
out/production/AuD/UEB03/Main.class
Normal file
BIN
out/production/AuD/UEB03/Main.class
Normal file
Binary file not shown.
Reference in New Issue
Block a user