HolonElement.java 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. String sign;
  17. public HolonElement(String eleName, float energy, int amount) {
  18. setEleName(eleName);
  19. setAmount(amount);
  20. setEnergy(energy);
  21. setActive(true);
  22. if (energy < 0) {
  23. setSign("-");
  24. } else {
  25. setSign("+");
  26. }
  27. }
  28. /**
  29. * @return the name
  30. */
  31. public String getEleName() {
  32. return eleName;
  33. }
  34. /**
  35. * @param name
  36. * the name to set
  37. */
  38. public void setEleName(String name) {
  39. this.eleName = name;
  40. }
  41. /**
  42. * @return the amount
  43. */
  44. public int getAmount() {
  45. return amount;
  46. }
  47. /**
  48. * @param amount
  49. * the amount to set
  50. */
  51. public void setAmount(int amount) {
  52. this.amount = amount;
  53. }
  54. /**
  55. * @return the energy
  56. */
  57. public float getEnergy() {
  58. return energy;
  59. }
  60. /**
  61. * @param energy
  62. * the energy to set
  63. */
  64. public void setEnergy(float energy) {
  65. this.energy = energy;
  66. }
  67. /**
  68. * @return the active
  69. */
  70. public boolean setActive() {
  71. return active;
  72. }
  73. /**
  74. * @param active
  75. * the active to set
  76. */
  77. public void setActive(boolean active) {
  78. this.active = active;
  79. }
  80. /**
  81. * @return the image
  82. */
  83. public String getImage() {
  84. return image;
  85. }
  86. /**
  87. * @param image
  88. * the image to set
  89. */
  90. public void setImage(String image) {
  91. this.image = image;
  92. }
  93. /**
  94. * Multiply the amount of gadgets, given by the user, and the
  95. * consumption/production. If the switch isWorking is turned off for on
  96. * gadget, the energy of this gadget have to be subtracted
  97. *
  98. * @return totalEnergy (actual)
  99. */
  100. public float getTotalEnergy() {
  101. totalEnergy = ((float) amount) * energy;
  102. return totalEnergy;
  103. }
  104. public void setSign(String s) {
  105. this.sign = s;
  106. }
  107. public String getSign() {
  108. return sign;
  109. }
  110. }