Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Building Base by IrvingProg
class Building():
def __init__(self, south, west, width_WE, width_NS, height=10):
self.south = south
self.west = west
self.width_WE = width_WE
self.width_NS = width_NS
self.height = height
def corners(self):
''' Return corners of building as a dictionary '''
corners = dict()
corners['north-west'] = [self.south + self.width_NS, self.west]
corners['north-east'] = [self.south + self.width_NS,
self.west + self.width_WE]
corners['south-west'] = [self.south, self.west]
corners['south-east'] = [self.south, self.west + self.width_WE]
return corners
def area(self):
''' Return area of building '''
return self.width_WE * self.width_NS
def volume(self):
''' Return volume of building '''
return (self.width_WE * self.width_NS) * self.height
def __repr__(self):
return "Building({}, {}, {}, {}, {})".format(
self.south, self.west, self.width_WE, self.width_NS, self.height)
Jan. 9, 2015