jeudi 25 avril 2019

How to use an if-statement right in a class [on hold]

I wanna include an if statement within a class, that the user have the options to choose between different types of wood. --> "wtype" But something went wrong by using the if statement... because the code is not working

My Code:

class SolidwoodC24(Material):

def __init__(self, name, Ex=300, Ey=300, Ez=11000, vxy=0.1, vzx=0.1, vyz=0.1, Gxy=500, Gzx=500, Gyz=500, p=380, tension=True, compression=True, wtype=1):
    Material.__init__(self, name=name)

    # Ex *= 10.**6; Ey *= 10.**6; Ez *= 10.**6; Gxy *= 10.**6; Gyz *= 10.**6; Gzx *= 10.**6

    self.__name__    = 'SolidwoodC24'
    self.name        = name
    self.wtype       = wtype

    # SolidwoodC24
    if self.wtype==1: 
        # SolidwoodC24
        Ex=300, Ey=300, Ez=11000, vxy=0.1, vzx=0.1, vyz=0.1, Gxy=500, Gzx=500, Gyz=500, p=380
    else:
        # SolidwoodC16
        Ex=270, Ey=270, Ez=8000, vxy=0.1, vzx=0.1, vyz=0.1, Gxy=500, Gzx=500, Gyz=500, p=310

    # Ex=300, Ey=300, Ez=11000, vxy=0.1, vzx=0.1, vyz=0.1, Gxy=500, Gzx=500, Gyz=500, p=380
    Ex *= 10.**6; Ey *= 10.**6; Ez *= 10.**6; Gxy *= 10.**6; Gyz *= 10.**6; Gzx *= 10.**6


...

Aucun commentaire:

Enregistrer un commentaire