Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

shawnf Group Title

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?

  • one year ago
  • one year ago

  • This Question is Closed
  1. KonradZuse Group Title
    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?"

    • one year ago
  2. shawnf Group Title
    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

    • one year ago
  3. shawnf Group Title
    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)

    • one year ago
    • Attachments:

See more questions >>>

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...

23

  • 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.