Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Dry implementation solution in Clear category for Building Base by maurice.makaay
class Building:
def __init__(self, south, west, len_we, len_ns, height=10):
self.len_we = len_we
self.len_ns = len_ns
self.north = south + len_ns
self.east = west + len_we
self.south = south
self.west = west
self.height = height
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.len_ns * self.len_we;
def volume(self):
return self.area() * self.height
def __repr__(self):
f = "Building({0.south}, {0.west}, {0.len_we}, {0.len_ns}, {0.height})";
return f.format(self)
Nov. 14, 2014
Comments: