HolonElement.java 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. package classes;
  2. public class HolonElement {
  3. /* Name of the gadget */
  4. String name;
  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 isWorking;
  11. /* Total Energy */
  12. float totalEnergy;
  13. /* Path of the image for the Obj. */
  14. String image;
  15. public HolonElement(String name, int amount, float energy) {
  16. this.name = name;
  17. this.amount = amount;
  18. this.energy = energy;
  19. this.isWorking = true;
  20. // System.out.println("You create some " + name + "'s. The amount is:" +
  21. // amount);
  22. // System.out.println("It's actual status is: " + isWorking);
  23. }
  24. public HolonElement(HolonElement hol) {
  25. this.name = hol.getName();
  26. this.amount = hol.getAmount();
  27. this.energy = hol.getEnergy();
  28. this.isWorking = true;
  29. // System.out.println("You create some " + name + "'s. The amount is:" +
  30. // amount);
  31. // System.out.println("It's actual status is: " + isWorking);
  32. }
  33. public String getName() {
  34. return name;
  35. }
  36. public void setName(String name) {
  37. this.name = name;
  38. }
  39. public int getAmount() {
  40. return amount;
  41. }
  42. public void setAmount(int amount) {
  43. this.amount = amount;
  44. }
  45. public float getEnergy() {
  46. return energy;
  47. }
  48. public void setEnergy(float energy) {
  49. this.energy = energy;
  50. }
  51. public void switchGadget(boolean bool) {
  52. this.isWorking = bool;
  53. }
  54. public boolean getState() {
  55. return isWorking;
  56. }
  57. /* Image path */
  58. public String getImage() {
  59. return image;
  60. }
  61. public void setImage(String image) {
  62. this.image = image;
  63. }
  64. /**
  65. * Multiply the amount of gadgets, given by the user, and the
  66. * consumption/production. If the switch isWorking is turned off for on
  67. * gadget, the energy of this gadget have to be subtracted
  68. *
  69. * @return totalEnergy (actual)
  70. */
  71. public float getTotalEnergy() {
  72. totalEnergy = ((float) amount) * energy;
  73. return totalEnergy;
  74. }
  75. }