Skip to content

Instantly share code, notes, and snippets.

@Echocage
Created October 7, 2014 05:01
Show Gist options
  • Save Echocage/38182e1d5be168386023 to your computer and use it in GitHub Desktop.
Save Echocage/38182e1d5be168386023 to your computer and use it in GitHub Desktop.
class Chair(object):
"""Individual chair within the aircraft"""
def __init__(self, price=25):
self.price = price
self.occupied = False
def purchase(self):
self.occupied = True
class Aircraft(object):
"""Aircraft that contains seats"""
def __init__(self, rows=25, wide=6):
self.rows = [[Chair() for seat in xrange(wide)] for row in xrange(rows)]
def get_chairs(self):
chairs = list()
for row in self.rows:
for chair in row:
chairs.append(chair)
return chairs
chairs = property(get_chairs)
if __name__ == '__main__':
plane = Aircraft()
print len(plane.chairs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment