def __init__(self): """Initialise length and width and add them to get_properties()""" funClasses.Area.__init__(self) # Set defaults self.set_name("Area of Rectangle") self.set_symbol("A_rect") # Add properties __l = funClasses.Length() __l.set_name("Length") __l.set_symbol("l") __w = funClasses.Length() __w.set_name("Width") __w.set_symbol("w") self.add_property(__l) self.add_property(__w) # Add expression __expr0 = funClasses.Expression( expressionStr = "{l} * {w}", **{'l':self.get_properties()[0], 'w':self.get_properties()[1]}) self.add_expression(__expr0)
def __init__(self): """Initialise length and width and add them to get_properties()""" funClasses.Volume.__init__(self) # Set defaults self.set_name("Volume of Cuboid") self.set_symbol("V_cuboid") # Add properties __l = funClasses.Length() __l.set_name("Length") __l.set_symbol("l") __w = funClasses.Length() __w.set_name("Width") __w.set_symbol("w") __h = funClasses.Length() __h.set_name("Height") __h.set_symbol("h") __base = RectangleArea() __base.set_name("Base Area") __base.set_symbol("A(base)") self.add_property(__l) self.add_property(__w) self.add_property(__h) self.add_property(__base) # Add expressions __expr0 = funClasses.Expression( expressionStr = "{l} * {w} * {h}", **{'l':self.get_properties()[0], 'w':self.get_properties()[1], 'h':self.get_properties()[2]}) self.add_expression(__expr0) __expr1 = funClasses.Expression( expressionStr = "{base} * {h}", **{'base':self.get_properties()[3], 'h':self.get_properties()[2]}) self.add_expression(__expr1)
def __init__(self): """Initialise using the rectangle's class but remove the width property""" RectangleArea.__init__(self) self.remove_property(self.get_properties()[1]) # Set defaults self.set_name("Area of Square") self.set_symbol("A_square") # Add expression self.remove_expression(self.get_expressions()[0]) __expr0 = funClasses.Expression( expressionStr = "{l}^2", **{'l':self.get_properties()[0]}) self.add_expression(__expr0)