HolonObject.java 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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(HolonObject obj) {
  25. super(obj.objName);
  26. this.consumers = obj.consumers;
  27. this.producers = obj.producers;
  28. }
  29. public void addConsumer(HolonElement consumer){
  30. consumers.add(consumer);
  31. }
  32. public void addProducer(HolonElement producer){
  33. producers.add(producer);
  34. }
  35. public void deleteConsumer(int idx){
  36. consumers.remove(idx);
  37. }
  38. public void deleteProducer(int idx){
  39. producers.remove(idx);
  40. }
  41. public float calculateCurrentEnergy(){
  42. return currentEnergy;
  43. }
  44. }