Untitled
unknown
plain_text
2 months ago
843 B
7
Indexable
class Hoteli:
def __init__(self, emri, dhomat_totale):
self.emri = emri
self.dhomat_totale = dhomat_totale
self.dhomat_e_zena = 0
def rezervat(self, sa_dhoma):
if self.dhomat_e_zena + sa_dhoma <= self.dhomat_totale:
self.dhomat_e_zena += sa_dhoma
print(f"Rezervimi u krye! Dhomat e lira: {self.dhomat_totale - self.dhomat_e_zena}")
else:
print("Nuk ka mjaftueshëm dhoma të lira!")
def anulo_rezervimin(self, sa_dhoma):
if self.dhomat_e_zena >= sa_dhoma:
self.dhomat_e_zena -= sa_dhoma
print(f"Anulimi u krye. Dhomat e lira: {self.dhomat_totale - self.dhomat_e_zena}")
# Testimi
h = Hoteli("Grand Hotel", 10)
h.rezervat(4)
h.rezervat(7) # Kjo do të dështojë sepse 4+7 > 10
h.anulo_rezervimin(2)Editor is loading...
Leave a Comment