scrimba
IN1000 - Uke #9
Søk i bok-lista
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Søk i bok-lista
AboutCommentsNotes
Søk i bok-lista
Expand for more info
index.py
run
preview
console
class Forfatter:
def __init__(self, navn):
self._navn = navn

def __str__(self):
return f"Mitt navn er {self._navn}"

def getNavn(self):
return self._navn

class Bok:
def __init__(self, tittel, forfatter):
self._tittel = tittel
self._forfatter = forfatter

def __str__(self):
return self._tittel + " av " + self._forfatter.getNavn()

ibsen = Forfatter("Henrik Ibsen")
skram = Forfatter("Amalie Skram")

brand = Bok("Brand", ibsen)
peer = Bok("Peer Gynt", ibsen)
dukkehjem = Bok("Et dukkehjem", ibsen)

forradt = Bok("Forrådt", skram)
ines = Bok("Fru Ines", skram)

bokliste = []
bokliste.append(brand)
bokliste.append(peer)
bokliste.append(dukkehjem)
bokliste.append(forradt)
bokliste.append(ines)

for bok in bokliste:
print(bok)

Console
"Variables "
,
index.html
-10:01