CpsEdge.java 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. package classes;
  2. public class CpsEdge {
  3. float maxCapacity;
  4. float flow;
  5. boolean isWorking;
  6. boolean infinite;
  7. CpsObject A;
  8. CpsObject B;
  9. public CpsEdge(CpsObject A, CpsObject B){
  10. setA(A);
  11. setB(B);
  12. this.A.AddConnection(this);
  13. this.B.AddConnection(this);
  14. this.maxCapacity = 100;
  15. flow = 0;
  16. isWorking = true;
  17. }
  18. public CpsEdge(CpsObject A, CpsObject B, float maxCap){
  19. setA(A);
  20. setB(B);
  21. this.A.AddConnection(this);
  22. this.B.AddConnection(this);
  23. this.maxCapacity = maxCap;
  24. flow = 0;
  25. isWorking = true;
  26. }
  27. /**
  28. * @return the capacity
  29. */
  30. public float getCapacity() {
  31. return maxCapacity;
  32. }
  33. /**
  34. * @param cap the Capacity to set
  35. */
  36. public void setCapacity(float cap) {
  37. this.maxCapacity = cap;
  38. }
  39. /**
  40. * @return the flow
  41. */
  42. public float getFlow() {
  43. return flow;
  44. }
  45. /**
  46. * @param flow the flow to set
  47. */
  48. public void setFlow(float flow) {
  49. this.flow = flow;
  50. if(flow > maxCapacity){
  51. isWorking = false;
  52. }else{
  53. isWorking = true;
  54. }
  55. }
  56. /**
  57. * @return the a
  58. */
  59. public CpsObject getA() {
  60. return A;
  61. }
  62. /**
  63. * @param a the a to set
  64. */
  65. public void setA(CpsObject a) {
  66. A = a;
  67. }
  68. /**
  69. * @return the b
  70. */
  71. public CpsObject getB() {
  72. return B;
  73. }
  74. /**
  75. * @param b the b to set
  76. */
  77. public void setB(CpsObject b) {
  78. B = b;
  79. }
  80. public boolean getState(){
  81. return isWorking;
  82. }
  83. public void setInfinite(boolean inf){
  84. infinite = inf;
  85. }
  86. public boolean getInfinite(){
  87. return infinite;
  88. }
  89. }