HolonObject.java 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package classes;
  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(String ObjName) {
  22. super(ObjName);
  23. }
  24. public HolonObject(CpsObject obj) {
  25. super(obj.objName);
  26. /*
  27. this.consumers = obj.consumers;
  28. this.producers = obj.producers;
  29. */
  30. }
  31. public void addConsumer(HolonElement consumer){
  32. consumers.add(consumer);
  33. }
  34. public void addProducer(HolonElement producer){
  35. producers.add(producer);
  36. }
  37. public void deleteConsumer(int idx){
  38. consumers.remove(idx);
  39. }
  40. public void deleteProducer(int idx){
  41. producers.remove(idx);
  42. }
  43. public float calculateCurrentEnergy(){
  44. return currentEnergy;
  45. }
  46. }