• Post Reply Bookmark Topic Watch Topic
  • New Topic

Boolean and main methods help  RSS feed

 
Daniel Hoang
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, so for one of my assignments, Im supposed to use all the methods in my Person class and integrate them all into a test. I am stuck on using some of the methods, such as the booleans, toString, and anything else i dont see that i am missing. Any hints as to how i can implement these? I know im obviously supposed to compare the new people, but im not exactly sure how to start doing that yet. Thanks

Test so far
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right now your question is rather vague and all over the place. You need to narrow it down.

Pick one thing that is giving you trouble, and TellTheDetails(←click) about what you're trying to do and what specific problems you're having.

Once we get that one resolved, you can move on to the next thing.
 
Daniel Hoang
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok my mistake. Im stuck on trying to figure out how to implement the booleans into my main method. I need a way to test all of these in my main, comparing a person entered with another person.
 
Daniel Hoang
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EDIT - So i managed to implement the boolean statements, but they seem to have nothing to the ones in the Person class. Am i missing something important?
 
Paul Clapham
Sheriff
Posts: 22844
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Those methods look perfectly good to me, is there some particular reason why you think they are wrong?
 
Daniel Hoang
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah i thought they looked ok after double checking. But when i delete the methods in the Person class, nothing changes in the test. What did i do wrong?
 
Paul Clapham
Sheriff
Posts: 22844
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess that must mean that your test code wasn't calling them. Certainly the code in your original post doesn't call them, and I can't tell from the fragments you've posted since then what your actual test code looks like.

EDIT: Actually even the code you posted later only calls the equals(Person) method and not the other three boolean methods.
 
Daniel Hoang
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My entire code is now. I have a low understanding of boolean usage in test classes. Can you give me like a basic example of how i could call for them? It just seems redundant to find if something equals another thing in both classes, so im sure im doing something wrong.
 
Paul Clapham
Sheriff
Posts: 22844
43
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your problem isn't specifically about booleans, it's generally about methods. Here's a line of your test code:



You wrote an isOlderThan(Person) method -- why don't you use it here?
 
Daniel Hoang
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh wow... im stupid haha. I got those methods to work. Thanks. Now my last method, toString(), i have no idea what this is.

Edit - figured it out. Thanks a lot Paul
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!