Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Building Base solution in Clear category for Building Base by DmytroKaminskiy
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
@property
def east(self):
return self.west + self.width_WE
@property
def north(self):
return self.south + self.width_NS
def corners(self):
return {
"north-west": [self.north, self.west],
"north-east": [self.north, self.east],
"south-west": [self.south, self.west],
"south-east": [self.south, self.east],
}
def area(self):
return self.width_NS * self.width_WE
def volume(self):
return self.area() * self.height
def __repr__(self):
return f'{self.__class__.__name__}({self.south}, {self.west}, {self.width_WE}, {self.width_NS}, {self.height})'
def __str__(self):
return self.__repr__()
March 1, 2019