PS5: little confused about this paragraph:
This trigger should produce its output by inverting the output of another trigger. The NOT trigger should take this other trigger as an argument to its constructor (why its constructor? Because we can’t change evaluate… that’d break our polymorphism). So, given a trigger T and a news item x, the output of the NOT trigger’s evaluate method should be equivalent to not T.evaluate(x).
So should NotTrigger implement its own evaluate method or should it inherit from Trigger? Did we talk about polymorphism?
MIT 6.00 Intro Computer Science (OCW)
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.
Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
it seems like you want to invert your output, aka a NOT. Basically NOT changes 1's to 0's and 0's to 1's.
It also seems like you're calling the Trigger in the NOT Trigger's Constructor. In Java it would be.
public class notTrigger()
public notTrigger(Trigger T)
this.t = T;
Next if we wanted to set up a Getter/Setter Methods we could also do this.
Now we however want the INVERTED of whatever we are given.
I'm also confused exactly what the Trigger is doing(true/false boolean)??? Also what is the news item/ what is our number set(0 and 1)???? What are we "inverting?"
Here is the inherited function:
def evaluate(self, story):
The trick would seem to be to implement a subclass.evaluate method, but the instructions say, "we can't change evaluate", so this confuses me. A subclass eval would be:
if word in story:
or something like that
This works, but it's a different implementation of evaluate. Since I didn't know anything about raise exception, I had no idea this was part of that scheme.
self.object = object
return not self.object.evaluate(self)