-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEdge.java
43 lines (33 loc) · 889 Bytes
/
Edge.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import java.io.Serializable;
// *** VT2021, Inlämningsuppgift, del 2
// Grupp 096
// joas47
public class Edge<T> implements Serializable {
private T destination;
private int weight;
private String name;
public Edge(T destination, int weight, String name) {
this.destination = destination;
this.weight = weight;
this.name = name;
}
public T getDestination() {
return destination;
}
public int getWeight() {
return weight;
}
public void setWeight(int weight) {
if (weight < 0) {
throw new IllegalArgumentException("Error: Weight can't be negative!");
}
this.weight = weight;
}
public String getName() {
return name;
}
@Override
public String toString() {
return "to " + destination + " by " + name + " takes " + weight;
}
}