diff options
Diffstat (limited to 'src/com/encrox/automaten/Stapel.java')
-rwxr-xr-x | src/com/encrox/automaten/Stapel.java | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/com/encrox/automaten/Stapel.java b/src/com/encrox/automaten/Stapel.java new file mode 100755 index 0000000..a4c5ee9 --- /dev/null +++ b/src/com/encrox/automaten/Stapel.java @@ -0,0 +1,54 @@ + +package com.encrox.automaten; + +public class Stapel { + + Object inhalt; + Stapel next; + + private int zaehlen(){ + if (next == null) return 0; + else return 1+next.zaehlen(); + } + + public Stapel(){ + } + + public boolean istLeer(){ + if (zaehlen()==0) return true; + else return false; + } + + public void ablegen(Object i){ + Stapel element = new Stapel(); + element.inhalt = i; + element.next = next; + next = element; + } + + public Object inhaltGeben(){ + if (next != null) return next.inhalt; + else return null; + } + + public Object entnehmen(){ + if (next != null){ + Object i = next.inhalt; + next = next.next; + return i; + } + return null; + } + + public String ausgeben(){ + String s=""; + if (inhalt != null){ + s = s+inhalt.toString()+"\n"; + } + if (next != null){ + s = s + next.ausgeben(); + } + return s; + } + +} |