A community for students.

    Here's the question you clicked on:

    55 members online
    • 0 replying
    • 0 viewing


    • 2 years ago

    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?

    • This Question is Closed
    1. KonradZuse
      • 2 years ago
      Best Response
      You've already chosen the best response.
      Medals 0

      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?"

    2. shawnf
      • 2 years ago
      Best Response
      You've already chosen the best response.
      Medals 0

      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

    3. shawnf
      • 2 years ago
      Best Response
      You've already chosen the best response.
      Medals 0

      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)

    4. Not the answer you are looking for?
      Search for more explanations.

      • Attachments:

    Ask your own question

    Sign Up
    Find more explanations on OpenStudy
    Privacy Policy

    Your question is ready. Sign up for free to start getting answers.

    spraguer (Moderator)
    5 → View Detailed Profile

    is replying to Can someone tell me what button the professor is hitting...


    • Teamwork 19 Teammate
    • Problem Solving 19 Hero
    • You have blocked this person.
    • ✔ You're a fan Checking fan status...

    Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

    This is the testimonial you wrote.
    You haven't written a testimonial for Owlfred.