Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 13 Online
OpenStudy (anonymous):

Problem set 5 no. 6 The solution for the not trigger is class NotTrigger(Trigger): def __init__(self, trigger) self.t = trigger def evaluate(self, story): return not self.t.evaluate(story) I'm unclear as to how the evaluate method works here, is it calling itself? How exactly does self.t.evaluate(story) work behind the scene to produce the desired trigger?

OpenStudy (rsmith6559):

I suspect that there are two evaluate methods in this program. The first is self.elvaluate, and the other is t.evaluate. self.t names a variable, self.t.evaluate() calls the evaluate method OF the self.t datatype. t.evaluate is recursive, self.evaluate is wrapping t.evaluate (getting it started). The key to this would be: what type of data/object is t?

OpenStudy (anonymous):

Hi, Thanks for your response. There are several evaluate methods but those evaluate methods are defined in other classes, for other trigger. In this part there is only one evaluate method. The problem set itself has more context that makes it clearer I guess.

OpenStudy (rsmith6559):

There is only one evaluate method defined in your code, there's two evaluate methods that will run ( NotTrigger.evaluate calls NotTrigger.t.evaluate, which is recursive ) if NotTrigger.evaluate is called.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
Countless7Echos: Ah trying out the whole T.V girl drawing :p (I love drawing eyes)
1 hour ago 7 Replies 5 Medals
kaelynw: starting to draw a hand
1 day ago 16 Replies 2 Medals
Twaylor: Rate it :D (Took 2 days)
2 days ago 7 Replies 0 Medals
XShawtyX: Art, Short Writing Assignment: Imagining Landscapes
2 hours ago 7 Replies 1 Medal
XShawtyX: Chemistry, Help ud83dude4fud83cudffe
3 days ago 13 Replies 1 Medal
kaelynw: tried a lil smt, the arm is off but i like the other stuff
3 days ago 27 Replies 3 Medals
kaelynw: art igg
3 days ago 14 Replies 1 Medal
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!