This commit is contained in:
alstergym
2026-09-18 09:14:16 +02:00
parent ce085e53eb
commit f98f2fa7ec
14 changed files with 199 additions and 16 deletions
+35
View File
@@ -0,0 +1,35 @@
class Schlange(object):
def __init__(self):
self.__liste = []
self.__anzahl = 0
def istLeer(self):
if self.__anzahl == 0:
return True
else:
return False
def mitLetztem(self, element):
self.__liste = self.__liste + [element]
self.__anzahl = self.__anzahl + 1
def ohneErstes(self):
if not self.istLeer():
self.__liste = self.__liste[1:] #1: => bis zum letzten Element
self.__anzahl = self.__anzahl - 1
def erstes(self):
if self.istLeer():
return None
else:
return self.__liste[0]
def anzahlElemente(self):
return self.__anzahl
def getSchlange(self):
return self.__liste
def setSchlange(self, liste):
self.__liste = liste
self.__anzahl = len(self.liste)