Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CodominantPopulation<O extends CodominantOrganism> extends SexualPopulation<O> {
- public CodominantPopulation(List<O> organisms) {
- super(organisms);
- }
- ...
- }
- public class SexualPopulation<O extends SexualOrganism> extends Population<O> {
- public SexualPopulation(List<O> organisms){
- super(organisms);
- }
- ...
- }
- // in CodominantPopulation
- for (O organism : population){
- // organism must be a CodominantOrganism
- CodominantGenotype.Dominance dominance = organism.getTraitDominance(trait);
- ...
- }
- Exception in thread "main" java.lang.ClassCastException: SexualOrganism cannot be cast to util.CodominantOrganism
- at CodominantPopulation.countDominance(CodominantPopulation.java:xx)
- ...
- public class Population<O extends Organism> {
- List<O> population;
- public Population(List<O> organisms){
- this.population = new ArrayList<>();
- this.population.addAll(organisms);
- }
- ...
- }
- class A
- A (X y) { f(y); }
- protected void f(X x) { }
- class B
- B (X y) { super(y); f(y); }
- @Override
- protected void f(X x) { }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement