summaryrefslogtreecommitdiff
path: root/src/misc/Stapel.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/misc/Stapel.java')
-rwxr-xr-xsrc/misc/Stapel.java51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/misc/Stapel.java b/src/misc/Stapel.java
new file mode 100755
index 0000000..92efc6d
--- /dev/null
+++ b/src/misc/Stapel.java
@@ -0,0 +1,51 @@
+package misc;
+public class Stapel { //Die Klasse / Datei muss genau so heißen!
+
+ private Stapel nextObject;
+ private Object content;
+
+ private Stapel(Object o){
+ content = o;
+ nextObject = null;
+ }
+
+ public Stapel(){
+ nextObject = null;
+ }
+
+ public boolean istLeer(){
+ if (nextObject == null) return true;
+ else return false;
+ }
+
+ public Object inhaltGeben(){
+ if (!istLeer()) return nextObject.content;
+ else return null;
+ }
+
+ public void ablegen(Object o){
+ Stapel neu = new Stapel(o);
+ neu.nextObject = nextObject;
+ nextObject = neu;
+ }
+
+ public Object entnehmen(){
+ Object aus;
+ if (!istLeer()){
+ aus = inhaltGeben();
+ nextObject = nextObject.nextObject;
+ return aus;
+ }
+ else return null;
+ }
+
+ public String ausgeben(){
+ String aus = "";
+ if (!istLeer()){
+ aus = aus + nextObject.content + "|";
+ if (nextObject.nextObject != null) aus = aus + nextObject.ausgeben();
+ }
+ return aus;
+ }
+
+} \ No newline at end of file