diff --git a/.project b/.project new file mode 100644 index 0000000..3284409 --- /dev/null +++ b/.project @@ -0,0 +1,11 @@ + + + PR2-Hummel-3024753 + + + + + + + + diff --git a/PR2pvl/.gitignore b/PR2pvl/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/PR2pvl/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/PR2pvl/src/Knoten.java b/PR2pvl/src/Knoten.java new file mode 100644 index 0000000..e90c7ac --- /dev/null +++ b/PR2pvl/src/Knoten.java @@ -0,0 +1,31 @@ + +public class Knoten { + + private int wert; + private Knoten nachfolger; + + Knoten(int wert){ + this.wert = wert; + this.nachfolger=null; + } + + + public void einfuegenAmEnde(int wert) { + if(this.nachfolger != null) { + Knoten k = new Knoten(wert); + this.nachfolger=k; + } + } + + + + public void auslesenAnPos(int pos) { + if(pos >0 && this.nachfolger != null) { + nachfolger.auslesenAnPos(pos--); + }else { + System.out.println(this.wert); + } + + } + // End of Class +} diff --git a/PR2pvl/src/LinkedList.java b/PR2pvl/src/LinkedList.java new file mode 100644 index 0000000..59d2d8f --- /dev/null +++ b/PR2pvl/src/LinkedList.java @@ -0,0 +1,24 @@ + +public class LinkedList { + private Knoten kopf; + + LinkedList(int wert){ + kopf = new Knoten(wert); + } + + + public void einfuegenAmEnde(int wert) { + kopf.einfuegenAmEnde(wert); + } + + public void auslesenAnPos(int pos) throws Exception { + + kopf.auslesenAnPos(pos); + } + + public void loeschenAnPos(int pos) throws Exception { + kopf.loeschenAnPos(pos); + + } + +}