Initial sharing of project
commit
8a8fbc4e93
|
@ -0,0 +1,35 @@
|
|||
|
||||
/**
|
||||
* Beschreiben Sie hier die Klasse LinkedList.
|
||||
*
|
||||
* @author (Ihr Name)
|
||||
* @version (eine Versionsnummer oder ein Datum)
|
||||
*/
|
||||
public class LinkedList
|
||||
{
|
||||
public Node first;
|
||||
public LinkedList(){
|
||||
}
|
||||
|
||||
public void einfuegen (int neu) {
|
||||
Node n = new Node(neu);//Neue Node mit Zahl "neu " anlegen
|
||||
|
||||
//Überprüfe ob die liste leer ist
|
||||
if(first == null){
|
||||
//setze neue node als erster Eintrag
|
||||
first = n;
|
||||
}
|
||||
else {
|
||||
Node current = first;
|
||||
|
||||
while(current.next != null){
|
||||
current = current.next;
|
||||
}
|
||||
current.setNext(n);
|
||||
}
|
||||
|
||||
//current ist jetzt der letzte Eintrag
|
||||
//setze neue Node als Nachfolger von bisher letztem Eintrag
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
|
||||
/**
|
||||
* Beschreiben Sie hier die Klasse Node.
|
||||
*
|
||||
* @author (Ihr Name)
|
||||
* @version (eine Versionsnummer oder ein Datum)
|
||||
*/
|
||||
public class Node
|
||||
{
|
||||
|
||||
public int zahl;
|
||||
|
||||
public Node next;
|
||||
|
||||
public Node(int z){
|
||||
zahl = z;
|
||||
}
|
||||
public void setNext(Node n){
|
||||
next = n;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
------------------------------------------------------------------------
|
||||
Dies ist die README-Datei des Projekts. Hier sollten Sie Ihr Projekt
|
||||
beschreiben.
|
||||
Erzählen Sie dem Leser (jemand, der nichts über dieses Projekt weiss),
|
||||
alles, was er/sie wissen muss. Üblicherweise sollte der Kommentar
|
||||
zumindest die folgenden Angaben umfassen:
|
||||
------------------------------------------------------------------------
|
||||
|
||||
PROJEKTBEZEICHNUNG:
|
||||
PROJEKTZWECK:
|
||||
VERSION oder DATUM:
|
||||
WIE IST DAS PROJEKT ZU STARTEN:
|
||||
AUTOR(EN):
|
||||
BENUTZERHINWEISE:
|
|
@ -0,0 +1,55 @@
|
|||
#BlueJ package file
|
||||
dependency1.from=test
|
||||
dependency1.to=LinkedList
|
||||
dependency1.type=UsesDependency
|
||||
dependency2.from=test
|
||||
dependency2.to=Node
|
||||
dependency2.type=UsesDependency
|
||||
dependency3.from=LinkedList
|
||||
dependency3.to=Node
|
||||
dependency3.type=UsesDependency
|
||||
editor.fx.0.height=728
|
||||
editor.fx.0.width=800
|
||||
editor.fx.0.x=1060
|
||||
editor.fx.0.y=217
|
||||
objectbench.height=100
|
||||
objectbench.width=776
|
||||
package.divider.horizontal=0.6
|
||||
package.divider.vertical=0.8003731343283582
|
||||
package.editor.height=422
|
||||
package.editor.width=661
|
||||
package.editor.x=228
|
||||
package.editor.y=167
|
||||
package.frame.height=600
|
||||
package.frame.width=800
|
||||
package.numDependencies=3
|
||||
package.numTargets=3
|
||||
package.showExtends=true
|
||||
package.showUses=true
|
||||
project.charset=UTF-8
|
||||
readme.height=60
|
||||
readme.name=@README
|
||||
readme.width=48
|
||||
readme.x=10
|
||||
readme.y=10
|
||||
target1.height=70
|
||||
target1.name=test
|
||||
target1.showInterface=false
|
||||
target1.type=ClassTarget
|
||||
target1.width=120
|
||||
target1.x=220
|
||||
target1.y=260
|
||||
target2.height=70
|
||||
target2.name=Node
|
||||
target2.showInterface=false
|
||||
target2.type=ClassTarget
|
||||
target2.width=120
|
||||
target2.x=70
|
||||
target2.y=10
|
||||
target3.height=70
|
||||
target3.name=LinkedList
|
||||
target3.showInterface=false
|
||||
target3.type=ClassTarget
|
||||
target3.width=120
|
||||
target3.x=30
|
||||
target3.y=140
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
/**
|
||||
* Beschreiben Sie hier die Klasse test.
|
||||
*
|
||||
* @author (Ihr Name)
|
||||
* @version (eine Versionsnummer oder ein Datum)
|
||||
*/
|
||||
public class test
|
||||
{
|
||||
public void test(){
|
||||
|
||||
LinkedList liste = new LinkedList();
|
||||
liste.einfuegen(5);
|
||||
liste.einfuegen(6);
|
||||
liste.einfuegen(8);
|
||||
liste.einfuegen(3);
|
||||
liste.einfuegen(7);
|
||||
liste.einfuegen(9);
|
||||
|
||||
Node current = liste.first;
|
||||
|
||||
while(current != null){
|
||||
System.out.println( current.zahl );
|
||||
current = current.next;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue