30 lines
714 B
Python
30 lines
714 B
Python
# szablon
|
|
|
|
class Klasa:
|
|
def __init__(self, nazwa_klasy, przedmiot="BRAK"):
|
|
self.klasa = nazwa_klasy
|
|
if przedmiot == "BRAK":
|
|
raise Exception("ZŁY PRZEDMIOT")
|
|
self.przedmiot = przedmiot
|
|
|
|
def jaki_przedmiot(self):
|
|
return f"Klasa {self.klasa} to {self.przedmiot}"
|
|
|
|
class Informatyka(Klasa):
|
|
def __init__(self, nazwa_klasy):
|
|
super().__init__(nazwa_klasy, przedmiot="Informa")
|
|
|
|
class Biologia(Klasa):
|
|
def __init__(self, nazwa_klasy):
|
|
super().__init__(nazwa_klasy, przedmiot="Biol")
|
|
|
|
klasy = [
|
|
Informatyka("1A"),
|
|
Biologia("2A"),
|
|
Biologia("3A"),
|
|
]
|
|
|
|
for jaka in klasy:
|
|
print(jaka.jaki_przedmiot())
|
|
|
|
Klasa("Tu powinien być eroor") |