From 7ceece79d2a9019457b06913fe3a9a9817464f09 Mon Sep 17 00:00:00 2001 From: Frank Date: Mon, 1 Sep 2025 23:57:13 -0600 Subject: [PATCH] Adding some slight changes to Graph logic --- src/Graph.java | 10 ++++++++++ src/Main.java | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Graph.java b/src/Graph.java index 59c6213..19693e2 100644 --- a/src/Graph.java +++ b/src/Graph.java @@ -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; + } + } + } } diff --git a/src/Main.java b/src/Main.java index 1f7adbb..415a4b1 100644 --- a/src/Main.java +++ b/src/Main.java @@ -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));