• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to remove item or don't post if checked true  RSS feed

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello and i sort of need some help as i can't figure out on how to do it
the method checks for certain word and "marks" it as spam so it will either remove the item or it won't post it
here is the code that i'm stuck on right now many thanks

 
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what's the problem you are having with the code? What does it do that it isn't supposed to, or what doesn't it do that it is supposed to?
 
Aaron Ng
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steve Luke wrote:So what's the problem you are having with the code? What does it do that it isn't supposed to, or what doesn't it do that it is supposed to?


if the subject field of the item finds any of the following word it should remove it or not post it in the server but i'm not sure on how to get that to work
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aaron Ng wrote:
Steve Luke wrote:So what's the problem you are having with the code? What does it do that it isn't supposed to, or what doesn't it do that it is supposed to?


if the subject field of the item finds any of the following word it should remove it or not post it in the server but i'm not sure on how to get that to work


This doesn't add any information to your original post. In exactly what way does it not work? For example, if you provide it a MailItem with a subject of "Fake Watches", then, assuming getSubject() does what its name suggests, the method will return true, which I would expect is the correct result.

So, what exactly is the problem?

 
Aaron Ng
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff Verdegan wrote:
Aaron Ng wrote:
Steve Luke wrote:So what's the problem you are having with the code? What does it do that it isn't supposed to, or what doesn't it do that it is supposed to?


if the subject field of the item finds any of the following word it should remove it or not post it in the server but i'm not sure on how to get that to work


This doesn't add any information to your original post. In exactly what way does it not work? For example, if you provide it a MailItem with a subject of "Fake Watches", then, assuming getSubject() does what its name suggests, the method will return true, which I would expect is the correct result.

So, what exactly is the problem?



it won't do what its suppose to do like when i test it the following



the test will fail and it won't return true unless i'm doing something wrong
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aaron Ng wrote:
it won't do what its suppose to do


Yes, you've mentioned that.



the test will fail and it won't return true unless i'm doing something wrong

Ah, NOW we're getting somewhere.

So, presumably you're expecting this test:

to evaluate to true, because of "SHOP AT OUR ONLINE PHARMACY", right?

Two questions:

1) Are you sure that parameter corresponds to the subject of the MailItem?

2) If it does, do you think that "SHOP AT OUR ONLINE PHARMACY".equals("Online Pharmacy") should be true? That is, do you think that "SHOP AT OUR ONLINE PHARMACY" is in fact equal to "Online Pharmacy"?

I'm hoping that this will make it clear to you what the nature of your logic error is. If it does, then your next step is to search through the docs for java.lang.String and see what methods it has that might more closely match what you're really trying to do. If you still don't understand the problem, post again.
 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aaron Ng wrote:if the subject field of the item finds any of the following word it should remove it or not post it in the server but i'm not sure on how to get that to work

Aaron, what does the caller method do with the returned boolean? Can you post that method? That is the method with code to handle the messages. All this method does is return boolean.

I'm curious to know: Is this a project where you persist actual messages, or is this just an exercise passing an object around a few methods?
 
Aaron Ng
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff Verdegan wrote:
Aaron Ng wrote:
it won't do what its suppose to do


Yes, you've mentioned that.



the test will fail and it won't return true unless i'm doing something wrong


Ah, NOW we're getting somewhere.

So, presumably you're expecting this test:

to evaluate to true, because of "SHOP AT OUR ONLINE PHARMACY", right?

Two questions:

1) Are you sure that parameter corresponds to the subject of the MailItem?

2) If it does, do you think that "SHOP AT OUR ONLINE PHARMACY".equals("Online Pharmacy") should be true? That is, do you think that "SHOP AT OUR ONLINE PHARMACY" is in fact equal to "Online Pharmacy"?

I'm hoping that this will make it clear to you what the nature of your logic error is. If it does, then your next step is to search through the docs for java.lang.String and see what methods it has that might more closely match what you're really trying to do. If you still don't understand the problem, post again.


i got it all working for that part now thanks
now the second question is how do i implement it when i tried it it says that a static content won't work on non static content
here is the code (from the MailServer Class) unless i am implementing the method in the wrong place


 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!