Here are a couple of things that might make this easier.
First, readability. Try to think of simple methods you can add to your Person class to let the Person control the details. For example, you have
What happens when you change gender to store "M" or "F" or turn it into an integer using constants? Sure, you won't do that in this program, but if you get used to coding defensively, your design will improve.
The Person class is just begging for "boolean isMale()" and "boolean isFemale()" Second, from what I recall of your ealier description, two people are compatible if and only if one is male and the other is female. So, once you pass that first
test, you know you've got one male and one female. Instead of contantly checking which is which, why not set up two local variables to hold them?
Notice how each test has two mirrored if-tests depending on whether "this" happens to be the male or female. This will simplify your if tests later on.
Remember, all great programmers are
lazy at heart and love to save typing, even if they have to spend hours thinking about a way to save that time. Make sure to cultivate this "skill."
Now, you may be thinking, but "this" is one Person and "N" is the other (What does N that mean?), and you can't very well switch "this". True, that's why you declare two new local Person references. You'll assign "this" and "N" to these new references and use them instead.
In any case, you said you've got it working so just consider these points for future projects. Good job!
