HolonObject.java 1016 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package ui.controller;
  2. import java.util.ArrayList;
  3. public class HolonObject extends CpsObject {
  4. /*Array of all consumers*/
  5. private ArrayList<HolonElement> consumers;
  6. /*Array of all producers*/
  7. private ArrayList<HolonElement> producers;
  8. /*Total of consumption*/
  9. private float currentEnergy;
  10. /**
  11. * State of the building:
  12. * 0 = fully supplied (currentEnergy == 0)
  13. * 1 = not enough energy (currentEnergy > 0)
  14. * 2 = oversupplied (currentEnergy < 0)
  15. */
  16. int state;
  17. /**
  18. * Constructor
  19. * Set by default the name of the object equals to the category name, until the user changes it.
  20. */
  21. public HolonObject() {
  22. super();
  23. }
  24. public void addConsumer(HolonElement consumer){
  25. consumers.add(consumer);
  26. }
  27. public void addProducer(HolonElement producer){
  28. producers.add(producer);
  29. }
  30. public void deleteConsumer(int idx){
  31. consumers.remove(idx);
  32. }
  33. public void deleteProducer(int idx){
  34. producers.remove(idx);
  35. }
  36. public float calculateCurrentEnergy(){
  37. return currentEnergy;
  38. }
  39. }