2nd Commit
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
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:]
|
||||
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)
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
from schlange import Schlange
|
||||
s = Schlange()
|
||||
s.anzahl = s.liste + [3]
|
||||
print(s.istLeer())
|
||||
print (s.anzahlElemente())
|
||||
Reference in New Issue
Block a user