blob: a4c5ee9b633a02837b2af11ed72354d928ac4de4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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;
}
}
|