Advertisement
Guest User

Untitled

a guest
May 21st, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. package fakarava.ecosystem;
  2.  
  3. import fakarava.controls.Clock;
  4.  
  5. import java.util.Collection;
  6.  
  7. public class Fish implements Clock {
  8. /**
  9. * @attribute
  10. */
  11. private Integer age;
  12.  
  13. /**
  14. * @attribute
  15. * @associates <{Integer}>
  16. */
  17. private Integer[] position;
  18.  
  19. /**
  20. * @attribute
  21. */
  22. private Integer numberOfFish;
  23.  
  24. /**
  25. * @attribute
  26. */
  27. private String name;
  28.  
  29. /**
  30. * @attribute
  31. */
  32. private Integer id;
  33.  
  34. /**
  35. * @attribute
  36. */
  37. private Real weight;
  38.  
  39. public Fish(String name, Double weight) {
  40. this.name=name;
  41. this.weight=weight;
  42. this.id=id+1;
  43.  
  44. numberOfFish++;
  45. }
  46.  
  47. public Fish(String name, Double weight, Integer age, Collection position) {
  48. this.name=name;
  49. this.weight=weight;
  50. this.id=id+1;
  51. this.age=age;
  52. numberOfFish++;
  53. //this.position=;
  54. }
  55.  
  56. public Fish clone(Fish toClone) {
  57. Fish newFish = new Fish("FilsDe"+ toClone.getName(), toClone.getWeight(), toClone.getage(), toClone.getPosition());
  58. return newFish;
  59. }
  60.  
  61. public Boolean isOverpopulated() {
  62. if(checkCapacity() == Lagun.getDENSITY_MAX())
  63. return true;
  64. else return false;
  65. }
  66.  
  67. public void checkGame(){
  68. if(isOverpopulated())
  69. {
  70. System.out.println("Le lagon est surpeuplé. \n\r Fin de simulation.");
  71. System.exit(0); //exit app
  72. }
  73. }
  74.  
  75. public Integer checkCapacity() {
  76. return numberOfFish;
  77. }
  78.  
  79. public void setAge(Integer age) {
  80. this.age = age;
  81. }
  82.  
  83. public Integer getAge() {
  84. return age;
  85. }
  86.  
  87. public void setPosition(Integer[] position) {
  88. this.position = position;
  89. }
  90.  
  91. public Integer[] getPosition() {
  92. return position;
  93. }
  94.  
  95. public void setName(String name) {
  96. this.name = name;
  97. }
  98.  
  99. public String getName() {
  100. return name;
  101. }
  102.  
  103. public void setId(Integer id) {
  104. this.id = id;
  105. }
  106.  
  107. public Integer getId() {
  108. return id;
  109. }
  110.  
  111. public void setage(Integer age) {
  112. this.age = age;
  113. }
  114.  
  115. public Integer getage() {
  116. return age;
  117. }
  118. public void setWeight(Double weight) {
  119. this.weight = weight;
  120. }
  121.  
  122. public Double getWeight() {
  123. return weight;
  124. }
  125.  
  126. @Override
  127. public void tictock() {
  128. // TODO Implement this method
  129. }
  130.  
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement