I do have some suggestions for your Behavior
1. Don't create a new Random
number generator each time you call the method. You generally only need ONE of them per object.
2. Make ALL your member fields private
. ALWAYS. ... or at least for the next year or so.
3. Your randomBehavior()
method contains a return
statement that returns a String
, but the method is declared to return a void
4. Rather than a big "select" statement, why not have an array
s called 'behaviour
' and just return the element that corresponds to the random number you create.
ie, something like this:
See how much simpler it is? You were on the right lines, but you're overthinking stuff by a country mile.
Think about what you want to do, and then write the simplest code possible
to do it.