View Javadoc
1   package org.woehlke.simulation.evolution.dom;
2   
3   /**
4    * (C) 2006 - 2008 Thomas Woehlke
5    * http://www.thomas-woehlke.de
6    * @author Thomas Woehlke
7    * Date: 04.02.2006
8    * Time: 23:12:31
9    */
10  public class SimGenLifeCycle implements ISimGenLifeCycle {
11      private int fat;
12      private int age;
13      private int hunger;
14      private int maxFat = 1500;
15      private int maxHunger = 200;
16      private int fullAge = 800;
17      private int fatMinimumForPregnancy = 1000;
18      private int fatAtBirthDefault = 50;
19      private int fatPerFood = 5;
20  
21      public SimGenLifeCycle() {
22          hunger = 0;
23          age = 0;
24          fat = fatAtBirthDefault;
25      }
26  
27      public SimGenLifeCycle(int fatAtBirth) {
28          hunger = 0;
29          age = 0;
30          fat = fatAtBirth;
31      }
32  
33      public boolean move() {
34          age++;
35          if (fat > 0) {
36              fat--;
37              return true;
38          } else {
39              hunger++;
40              return false;
41          }
42      }
43  
44      public void haveSex() {
45          fat /= 2;
46          age = 0;
47      }
48  
49      public int getFatPerFood() {
50          return fatPerFood;
51      }
52  
53      public void setFatPerFood(int fatPerFood) {
54          this.fatPerFood = fatPerFood;
55      }
56  
57      public int getFatMinimumForPregnancy() {
58          return fatMinimumForPregnancy;
59      }
60  
61      public void setFatMinimumForPregnancy(int fatMinimumForPregnancy) {
62          this.fatMinimumForPregnancy = fatMinimumForPregnancy;
63      }
64  
65      public int getFullAge() {
66          return fullAge;
67      }
68  
69      public void setFullAge(int fullAge) {
70          this.fullAge = fullAge;
71      }
72  
73      public int getMaxHunger() {
74          return maxHunger;
75      }
76  
77      public void setMaxHunger(int maxHunger) {
78          this.maxHunger = maxHunger;
79      }
80  
81      public int getMaxFat() {
82          return maxFat;
83      }
84  
85      public void setMaxFat(int maxFat) {
86          this.maxFat = maxFat;
87      }
88  
89  
90      public boolean isFatEnoughForSex() {
91          return fat >= fatMinimumForPregnancy;
92      }
93  
94      public boolean isPregnant() {
95          return isOldEnoughForSex() && isFatEnoughForSex();
96      }
97  
98      public boolean isOldEnoughForSex() {
99          return age >= fullAge;
100     }
101 
102     public boolean isDead() {
103         return hunger >= maxHunger;
104     }
105 
106     public void eat() {
107         if (fat + fatPerFood <= maxFat) {
108             fat += fatPerFood;
109         }
110     }
111 
112     public boolean isNotDyingForHunger() {
113         return fat > 0;
114     }
115 
116     public int getFat() {
117         return fat;
118     }
119 
120     public int getFatAtBirthDefault() {
121         return fatAtBirthDefault;
122     }
123 
124     public void setFatAtBirthDefault(int fatAtBirthDefault) {
125         this.fatAtBirthDefault = fatAtBirthDefault;
126     }
127 }