HolonElement.java 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package ui.model;
  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. public HolonElement(String name, int amount, float energy) {
  14. this.name = name;
  15. this.amount = amount;
  16. this.energy = energy;
  17. this.isWorking = true;
  18. System.out.println("You create some " + name + "'s. The amount is:" + amount);
  19. System.out.println("It's actual status is: " + isWorking);
  20. }
  21. public String getName() {
  22. return name;
  23. }
  24. public void setName(String name) {
  25. this.name = name;
  26. }
  27. public int getAmount() {
  28. return amount;
  29. }
  30. public void setAmount(int amount) {
  31. this.amount = amount;
  32. }
  33. public float getEnergy() {
  34. return energy;
  35. }
  36. public void setEnergy(float energy) {
  37. this.energy = energy;
  38. }
  39. public void switchGadget(boolean bool) {
  40. this.isWorking = bool;
  41. }
  42. public boolean getState() {
  43. return isWorking;
  44. }
  45. /**
  46. * Multiply the amount of gadgets, given by the user, and the
  47. * consumption/production. If the switch isWorking is turned off for on
  48. * gadget, the energy of this gadget have to be subtracted
  49. *
  50. * @return totalEnergy (actual)
  51. */
  52. public float getTotalEnergy() {
  53. totalEnergy = ((float)amount)*energy;
  54. return totalEnergy;
  55. }
  56. }