Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. public class CodominantPopulation<O extends CodominantOrganism> extends SexualPopulation<O> {
  2.  
  3. public CodominantPopulation(List<O> organisms) {
  4. super(organisms);
  5. }
  6. ...
  7. }
  8.  
  9. public class SexualPopulation<O extends SexualOrganism> extends Population<O> {
  10. public SexualPopulation(List<O> organisms){
  11. super(organisms);
  12. }
  13. ...
  14. }
  15.  
  16. // in CodominantPopulation
  17. for (O organism : population){
  18. // organism must be a CodominantOrganism
  19. CodominantGenotype.Dominance dominance = organism.getTraitDominance(trait);
  20. ...
  21. }
  22.  
  23. Exception in thread "main" java.lang.ClassCastException: SexualOrganism cannot be cast to util.CodominantOrganism
  24. at CodominantPopulation.countDominance(CodominantPopulation.java:xx)
  25. ...
  26.  
  27. public class Population<O extends Organism> {
  28. List<O> population;
  29.  
  30. public Population(List<O> organisms){
  31. this.population = new ArrayList<>();
  32. this.population.addAll(organisms);
  33. }
  34. ...
  35. }
  36.  
  37. class A
  38. A (X y) { f(y); }
  39. protected void f(X x) { }
  40.  
  41. class B
  42. B (X y) { super(y); f(y); }
  43. @Override
  44. protected void f(X x) { }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement