Hi everyone!
I have some problems with my Java class. When I call function (for exmaple int getCapacity(Edge e)) it changes my object (chagne Edge e) and I don’t want to do that. Shouldn’t only void functions change objects? Any help?
public class Edge {
private int start;
private int end;
private int capacity;
private int flow;
public Edge(int p, int k, int cap) {
this.start = p;
this.end = k;
this.capacity = cap;
this.flow=0;
}
public void setStart(int s){
this.start = s;
public static int getCapacity(Edge e){
e.setStart(-1);
return e.capacity;
}
public static void main(String[] args){
Edge e= new Edge();
int k=getCapacity(e));
e.print();
}
}
Thanks!