I have a class containing a series of if/or statements below:
class Tester:
def __init__(self, name, test1, test2):
self.name = name
self.test1 = test1
self.test2 = test2
if (self.test1 == "halides") or (self.test2 == "halides"):
halideTest()
elif (self.test1 == "carbonate") or (self.test2 == "carbonate"):
carbonateTest()
elif (self.test1 == "sulphate") or (self.test2 == "sulphate"):
sulphateTest()
elif (self.test1 == "sulphite") or (self.test2 == "sulphite"):
sulphiteTest()
elif (self.test1 == "nitrate") or (self.test2 == "nitrate"):
nitrateTest()
elif (self.test1 == "nitrite") or (self.test2 == "nitrite"):
nitriteTest()
Which is supposed to take conduct two of the six possible tests by being instantiated like so:
tester1 = new Tester("bob", "nitrate", "sulphate")
.
however, when I create a new tester like that, only the first function (test1
, in this case nitrateTest) is called, whereas I expected the functions of test1
and test2
to both be called.
How can I restructure my code to make this happen?
Aucun commentaire:
Enregistrer un commentaire