-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLocationManager.java
More file actions
48 lines (40 loc) · 1.31 KB
/
LocationManager.java
File metadata and controls
48 lines (40 loc) · 1.31 KB
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
44
45
46
47
48
public class LocationManager {
private Graph graph;
private AVLTree tree;
public LocationManager() {
graph = new Graph();
tree = new AVLTree();
}
public void addLocation(String name) {
// We can add logic here to check if it already exists
tree.insert(name);
graph.addLocation(name);
System.out.println("Location added: " + name);
}
public void removeLocation(String name) {
// FIX: Now removes from both data structures
graph.removeLocation(name);
tree.delete(name);
System.out.println("Location removed: " + name);
}
public void addRoad(String from, String to) {
graph.addRoad(from, to);
System.out.println("Road added between " + from + " and " + to);
}
public void removeRoad(String from, String to) {
graph.removeRoad(from, to);
System.out.println("Road removed between " + from + " and " + to);
}
public void showConnections() {
graph.displayConnections();
}
public void showAllLocations() {
System.out.print("Locations (from AVL Tree): ");
tree.inOrder();
System.out.println();
}
// NEW: Exposes the graph's pathfinding
public void findPath(String from, String to) {
graph.findPath(from, to);
}
}