Adding some slight changes to Graph logic
This commit is contained in:
@@ -28,4 +28,14 @@ public class Graph {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void changeRoute(String src, String dst, int value) {
|
||||
for(int i = 0; i < graph.size(); i++) {
|
||||
String source = graph.get(i).source.getName();
|
||||
String destination = graph.get(i).destination.getName();
|
||||
if (source.equals(src) && destination.equals(dst)) {
|
||||
graph.get(i).weight = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,9 +65,11 @@ public class Main {
|
||||
String source = scanner.nextLine();
|
||||
System.out.print("Destination: ");
|
||||
String destination = scanner.nextLine();
|
||||
System.out.println("What is the new value?");
|
||||
System.out.println("<------------------------------>");
|
||||
int value = graph.findRoute(source, destination);
|
||||
System.out.println("Route Cost: " + value);
|
||||
int value = scanner.nextInt();
|
||||
graph.changeRoute(source, destination, value);
|
||||
System.out.println("Route Changed!");
|
||||
// END: Graphs
|
||||
|
||||
// System.out.println(addTotals(2.5, 2.5));
|
||||
|
||||
Reference in New Issue
Block a user