SubNet.java 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. package classes;
  2. import java.util.ArrayList;
  3. /**
  4. * The class "subNet" represents ....
  5. *
  6. * @author Gruppe14
  7. *
  8. */
  9. public class SubNet {
  10. private ArrayList<HolonObject> subNetObjects;
  11. private ArrayList<Edge> subNetEdges;
  12. private ArrayList<HolonSwitch> subNetSwitches;
  13. private ArrayList<HolonBattery> subNetBatteries;
  14. /**
  15. * Constructor for a Subnet.
  16. *
  17. * @param objects
  18. * Objects in the Subnet
  19. * @param edges
  20. * Edges in the Subnet
  21. * @param switches
  22. * Switches in the Subnet
  23. */
  24. public SubNet(ArrayList<HolonObject> objects, ArrayList<Edge> edges, ArrayList<HolonSwitch> switches, ArrayList<HolonBattery> batteries) {
  25. subNetObjects = objects;
  26. subNetEdges = edges;
  27. subNetSwitches = switches;
  28. subNetBatteries = batteries;
  29. }
  30. /**
  31. * Return all Objects in the Subnet.
  32. *
  33. * @return all Objects in the Subnet
  34. */
  35. public ArrayList<HolonObject> getObjects() {
  36. return subNetObjects;
  37. }
  38. /**
  39. * Return all Edges in the Subnet.
  40. *
  41. * @return all Edges in the Subnet
  42. */
  43. public ArrayList<Edge> getEdges() {
  44. return subNetEdges;
  45. }
  46. /**
  47. * Return all Switches in the Subnet.
  48. *
  49. * @return all Switches in the Subnet
  50. */
  51. public ArrayList<HolonSwitch> getSwitches() {
  52. return subNetSwitches;
  53. }
  54. public ArrayList<HolonBattery> getBatteries() {
  55. return subNetBatteries;
  56. }
  57. public String toString(int timeStep) {
  58. StringBuilder sb = new StringBuilder();
  59. sb.append(" Objects:");
  60. for (int j = 0; j < getObjects().size(); j++) {
  61. HolonObject hl = getObjects().get(j);
  62. sb.append(" " + hl.getName() + " " + hl.getId());
  63. }
  64. sb.append(" Edges:");
  65. for (int j = 0; j < getEdges().size(); j++) {
  66. Edge edge = getEdges().get(j);
  67. sb.append(" " + edge.getA().getName() + " connected To " + edge.getB().getName());
  68. }
  69. sb.append(" Switches:");
  70. for (int j = 0; j < getSwitches().size(); j++) {
  71. HolonSwitch sw = getSwitches().get(j);
  72. sb.append(" " + sw.getName() + " " + sw.getId() + " State:" + sw.getState(timeStep));
  73. }
  74. return sb.toString();
  75. }
  76. public String toString() {
  77. StringBuilder sb = new StringBuilder();
  78. sb.append("\nObjects:");
  79. for (HolonObject hl: getObjects()) {
  80. sb.append(" " + hl.getName() + "[ID:" + hl.getId()+ "]");
  81. }
  82. sb.append("\nEdges:");
  83. for (Edge edge :getEdges()) {
  84. sb.append(" " + edge.getA().getName() + " connected To " + edge.getB().getName());
  85. }
  86. sb.append("\nSwitches:");
  87. for (HolonSwitch sw : getSwitches()) {
  88. sb.append(" " + sw.getName() + "[ID:" + sw.getId()+ "]");
  89. }
  90. sb.append("\nBatteries:");
  91. for (HolonBattery hB: getBatteries()) {
  92. sb.append(" " + hB.getName() + "[ID:" + hB.getId()+ "]");
  93. }
  94. return sb.toString();
  95. }
  96. }