Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AaronGoldsmith1/e616a8bff2417e28e6c4a6d6bf8a433d to your computer and use it in GitHub Desktop.
Save AaronGoldsmith1/e616a8bff2417e28e6c4a6d6bf8a433d to your computer and use it in GitHub Desktop.
st-regis-lab
from src.index import store
class Reservation:
id = 1
def __init__(self, guest, room, start_day, end_day):
self.id = Reservation.id
self.guest = guest
self.room = room
self.start_day = start_day
self.end_day = end_day
Reservation.id += 1
# add the instance to the store
store['reservations'][self.id] = self
class Guest:
id = 1
def __init__(self, name):
self.id = Guest.id
self.name = name
Guest.id += 1
# add the instance to the store
store['guests'][self.id] = self
def reservations(self):
# return a list of all the reservations associated with this Guest instance
result = []
for reservation_id in store['reservations']:
if store['reservations'][reservation_id].guest == self:
result.append(store['reservations'][reservation_id])
return result
def rooms(self):
# return a list of all the rooms associated with this Guest instance
result = []
for reservation in self.reservations():
if reservation.room not in result:
result.append(reservation.room)
return result
class Room:
id = 1
def __init__(self, room_number, rate):
self.id = Room.id
self.room_number = room_number
self.rate = rate
Room.id += 1
# add the instance to the store
store['rooms'][self.id] = self
def reservations(self):
# return all the Reservations associated with this Room instance
result = []
for reservation_id in store['reservations']:
if store['reservations'][reservation_id].room == self:
result.append(store['reservations'][reservation_id])
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment