In your method you have access to the size of the current CyberPet, and you also have access to the size of the other CyberPet that is passed as a parameter, so you can write a couple of if tests comparing those two things to decide what String to return. You may be looking for something difficult, but this is more simple than you realise.
Here's a starting point:
you method signature is invalid. It should be something like
public String encounter( CyberPet other )
JamesCherrill
Posting Genius
6,370 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
Your encounter can occur outside of the CyberPet class, using a collaboration pattern. Basically, create another class that has some method which accepts a list of CyberPet objects, compares them, and prints out (or returns) the result.
dononelson
Junior Poster in Training
62 posts since Mar 2010
Reputation Points: 13
Solved Threads: 15
Then, in your TestCyberPet class, instantiate two CyberPet objects. Your "encounter" method signature should look something like
public String encounter( CyberPet aCyberPet) {
...
}
In the encounter method, the incoming CyberPet's size with it's own, and print the result. This way, your test method can decide which CyberPet's instance is "contolling" the encounter; IOW, you could pass a large CyberPet to a small one, or vise-versa.
dononelson
Junior Poster in Training
62 posts since Mar 2010
Reputation Points: 13
Solved Threads: 15