HolonElement.java 2.8 KB

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