Java クラスに問題があります。関数 (たとえば int getCapacity(Edge e)) を呼び出すと、オブジェクト (chagne Edge e) が変更されますが、そうしたくありません。オブジェクトを変更するのは void 関数だけではありませんか? 何か助けはありますか?
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();
}
}
ありがとう!