Created
October 7, 2014 05:01
-
-
Save Echocage/38182e1d5be168386023 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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