From 84e220b332bfffb0f2dcc39b9697a6fd6691d265 Mon Sep 17 00:00:00 2001 From: Leonard Kugis Date: Mon, 25 Apr 2022 18:36:30 +0200 Subject: Initial commit --- src/misc/Stapel.java | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 src/misc/Stapel.java (limited to 'src/misc/Stapel.java') 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 -- cgit v1.2.1