summaryrefslogtreecommitdiff
path: root/src/com/encrox/automaten/Schlange.java
diff options
context:
space:
mode:
authorLeonard Kugis <leonard@kug.is>2022-04-25 18:04:14 +0200
committerLeonard Kugis <leonard@kug.is>2022-04-25 18:04:14 +0200
commitc3973f2ade85ab9daea3435d22656097dd300602 (patch)
treefe428591f20c27df4f3e1ac34d365d49b2ff60a0 /src/com/encrox/automaten/Schlange.java
Initial commitHEADmaster
Diffstat (limited to 'src/com/encrox/automaten/Schlange.java')
-rwxr-xr-xsrc/com/encrox/automaten/Schlange.java56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/com/encrox/automaten/Schlange.java b/src/com/encrox/automaten/Schlange.java
new file mode 100755
index 0000000..c5b7f65
--- /dev/null
+++ b/src/com/encrox/automaten/Schlange.java
@@ -0,0 +1,56 @@
+package com.encrox.automaten;
+
+public class Schlange {
+
+ Schlange next;
+ Object inhalt;
+
+ public Schlange(){
+
+ }
+
+ private int zaehlen(){
+ if (next == null) return 0;
+ else return 1+next.zaehlen();
+ }
+
+ public boolean istLeer(){
+ if (zaehlen()==0) return true;
+ else return false;
+ }
+
+ public void anhaengen(Object i){
+ if (next == null){
+ Schlange element = new Schlange();
+ element.inhalt=i;
+ next = element;
+ }
+ else next.anhaengen(i);
+ }
+
+ 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;
+ }
+
+}