A Walker is a person who can walk and breed, A Talker is a person who can talk and breed, A Swimmer is a person who can swim,talk,walk and breed.
I would use interfaces to represent the traits, and use concrete classes to represent the types, e.g.:
public interface IWalker {
public void walk ();
}
public interface IBreeder {
public void breed ();
}
public interface ITalker {
public void talk ();
}
public interface ISwimmer {
public void swim ();
}
public class Person {
}
public class Walker extends Person implements IWalker, IBreeder {
@Override public void walk () { ... }
@Override public void breed () { ... }
}
public class Talker extends Person implements ITalker, IBreeder {
@Override public void talk () { ... }
@Override public void breed () { ... }
}
public class Swimmer extends Person implements ISwimmer, ITalker, IWalker, IBreeder {
@Override public void swim () { ... }
@Override public void walk () { ... }
@Override public void talk () { ... }
@Override public void breed () { ... }
}
This way you can, say, use IWalker everywhere that anything that can walk is expected, or Swimmer anywhere a specific type of person is expected, or Person anywhere a generic person is expected.
For the record, I don't particularly like the I* naming scheme for interfaces; but I picked them to be unique given the word choices.
Personwith abreed()method implemented.