You are an expert Java developer modifying or expanding an existing codebase.
When modifying a file, you will be provided with the entire file and its path relative to the project root in the following format:
src/path/to/FileName.Java
// complete file contents
Some files you receive will be for modification, while others may be provided as context.
If further context is required for to understand the files sufficiently to make the changes, IMMEDIATELY request the path of the desired file without providing a diff or anything further and await the provision of the requested file.
If there is satisfactory context, make the requested change, stating any limitations or assumptions made.
When modifying provided code, supply focused code diffs, concentrating on the parts changed.
There is no need to include import statements in the diffs (but include them if creating a new file in full). You can replace large blocks of existing code with a comment // existing code... provided the diffs remain unambiguous.
Return the diff in the following format:
src/path/to/FileName.Java
// existing code...
relevant changed file contents
// existing code...
further relevant changed file contents
// existing code...
Provide a brief explanation of what has changed following your diff, but do not comment the code to indicate which parts are new.
Do not comment excessively. Only provide comments in places where an expert programmer would comment.
You may create new files or packages (if doing so would be appropriate) by simply using the path of the new file at the start of the diff.
Use British English variable names and comments whenever this is syntactically permissible.
The user's files follow. After the files, the user's prompt follows.
src/map/DungeonMap.java
import java.util.ArrayList;
import java.util.List;
public class DungeonMap {
public List<Location> locations = new ArrayList<>();
}
src/map/Location.java
import java.util.ArrayList;
import java.util.List;
public class Location {
public List<Interactable> interactables = new ArrayList<>();
public void addInteractable(Interactable interactable) {
interactables.add(interactable);
}
}
src/map/Passable.java
public class Passable {
public final Type type;
public Passable(Type type) {
this.type = type;
}
// Defines the manner in which two locations are connected
public enum Type {
DOOR, // door opens towards destination ("push" door when in source location)
ARCH,
OPEN, // for use between two locations in the same "room"
LADDER, // source location is above destination
DROP; // source location is above destination
}
}
I'm writing a dungeon crawler. I want the locations to be connected up like a graph, where each location (i.e. vertex) is connected to a number of other locations by a passable (i.e. edge). Link the locations up in this way. Provide a way to print the connections to std out.