Ace school

with brainly

  • Get help from millions of students
  • Learn from experts with step-by-step explanations
  • Level-up by helping others

A community for students.

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)
See more answers at brainly.com
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.

Join Brainly to access

this expert answer

SEE EXPERT ANSWER

To see the expert answer you'll need to create a free account at Brainly

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() { Trigger t; 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): raise NotImplementedError 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: def subclass.evaluate(self,story): if word in story: return True 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. class NotTrigger(Trigger): def __init__(self,object): self.object = object def evaluate(self,object): return not self.object.evaluate(self)

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

Not the answer you are looking for?

Search for more explanations.

Ask your own question