diff options
author | Leonard Kugis <leonard@kug.is> | 2022-04-25 18:36:30 +0200 |
---|---|---|
committer | Leonard Kugis <leonard@kug.is> | 2022-04-25 18:36:30 +0200 |
commit | 84e220b332bfffb0f2dcc39b9697a6fd6691d265 (patch) | |
tree | 0b861a9a099017ffd9bf00bae12e33ed6a309bbe /src/misc/Stapel.java |
Diffstat (limited to 'src/misc/Stapel.java')
-rwxr-xr-x | src/misc/Stapel.java | 51 |
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 |