HolonElement.java 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. package classes;
  2. public class HolonElement {
  3. /* Name of the gadget */
  4. String eleName;
  5. /* Quantity */
  6. int amount;
  7. /* Energy per gadget */
  8. float energy;
  9. /* If the gadget is working xor not (true xor false) */
  10. boolean active;
  11. /* Total Energy */
  12. float totalEnergy;
  13. /* Path of the image for the Obj. */
  14. String image;
  15. /* +: for Consumers and -: Producers */
  16. char sign;
  17. String stored;
  18. /*
  19. * Energy at each point of the graph with 50 predefined points. At the
  20. * beginning, it starts with all values at energy
  21. */
  22. float[] energyAt = new float[49];
  23. public HolonElement(String eleName, float energy, int amount) {
  24. setEleName(eleName);
  25. setAmount(amount);
  26. setEnergy(energy);
  27. setActive(true);
  28. setSign(energy);
  29. setEnergyAt(energy);
  30. }
  31. public HolonElement(HolonElement element) {
  32. setEleName(element.getEleName());
  33. setAmount(element.getAmount());
  34. setEnergy(element.getEnergy());
  35. setActive(element.getActive());
  36. setSign(element.getEnergy());
  37. setEnergyAt(element.getEnergy());
  38. }
  39. public float[] getEnergyAt() {
  40. return energyAt;
  41. }
  42. public void setEnergyAt(float energy) {
  43. for (int i = 0; i < 49; i++) {
  44. this.energyAt[i] = energy;
  45. }
  46. }
  47. public void setEnergyAt(int pos, float energy) {
  48. this.energyAt[pos] = energy;
  49. }
  50. /**
  51. * @return the name
  52. */
  53. public String getEleName() {
  54. return eleName;
  55. }
  56. /**
  57. * @param name
  58. * the name to set
  59. */
  60. public void setEleName(String name) {
  61. this.eleName = name;
  62. }
  63. /**
  64. * @return the amount
  65. */
  66. public int getAmount() {
  67. return amount;
  68. }
  69. /**
  70. * @param amount
  71. * the amount to set
  72. */
  73. public void setAmount(int amount) {
  74. this.amount = amount;
  75. }
  76. /**
  77. * @return the energy
  78. */
  79. public float getEnergy() {
  80. return energy;
  81. }
  82. /**
  83. * @param energy
  84. * the energy to set
  85. */
  86. public void setEnergy(float energy) {
  87. this.energy = energy;
  88. }
  89. /**
  90. * @return the active
  91. */
  92. public boolean getActive() {
  93. return active;
  94. }
  95. /**
  96. * @param active
  97. * the active to set
  98. */
  99. public void setActive(boolean active) {
  100. this.active = active;
  101. }
  102. /**
  103. * @return the image
  104. */
  105. public String getImage() {
  106. return image;
  107. }
  108. /**
  109. * @param image
  110. * the image to set
  111. */
  112. public void setImage(String image) {
  113. this.image = image;
  114. }
  115. /**
  116. * Multiply the amount of gadgets, given by the user, and the
  117. * consumption/production. If the switch isWorking is turned off for on
  118. * gadget, the energy of this gadget have to be subtracted
  119. *
  120. * @return totalEnergy (actual)
  121. */
  122. public float getTotalEnergy() {
  123. totalEnergy = ((float) amount) * energy;
  124. return totalEnergy;
  125. }
  126. /**
  127. * @return the sign
  128. */
  129. public char getSign() {
  130. return sign;
  131. }
  132. /**
  133. * @param energy
  134. * the sign to set
  135. */
  136. public void setSign(float energy) {
  137. if (energy < 0)
  138. this.sign = '-';
  139. else
  140. this.sign = '+';
  141. }
  142. /**
  143. * @return the stored
  144. */
  145. public String getStored() {
  146. return stored;
  147. }
  148. /**
  149. * @param stored the stored to set
  150. */
  151. public void setStored(String stored) {
  152. this.stored = stored;
  153. }
  154. }