Question: I just need little help in this java assignment. Basically there are theree floors in the house. In each floor, there are some rooms that

 I just need little help in this java assignment. Basically there are theree floors in the house. In each floor, there are some rooms that are connected to each other. Our job is to navigate rooms in a maze. Or in our case, a maze-like house with multiple floors and an unreasonably large number of rooms. or not by using all--> Queue , Array_lists, Map, and set data structure. Note: --> our task is to implement doesPathExist. The method takes in a list of Rooms (constructed from the layout.txt file as described above), as well as the names of a start room and an end room. It should return true if, from the start room, you can repeatedly move to a connected neighboring room until you reach the end room, or false if that is not possible --> Every room is reachable from every other room on the same floor, but youll notice theres no way to move between floors. If you ask whether a path exists between a ground floor room and a basement room, for example, the answer should be false. Breadth-First Search  The algorithm well use to determine whether we can find a path from a start location to a destination is called breadth-first search. 1. Begin at the start location (the starting room). 2 . Look at every location that is one step away. Are any of these the destination? 3. Look at every location that is one step away from the rooms in #2. Are any of these the destination? 4. Look at every location that is one step away from the rooms in #3. Are any of these the destination? 5. etc. At any point in this process, if a location youre looking at is the destination, then youve found a path and youre finished! But if you continue searching and eventually exhaust all of your search options without finding the destination, you can safely say that no such path exists. In the Room Navigator program, the locations that are one step away from a room are all its connected neighbors. We will use the getConnectedRooms() method in implementing breadth-first search! But first If you need layout for each floor of the house, I can provide you in the reply section . Here is my classes and .txt file Room class  package edu.csc220.navigator; import java.util.ArrayList; /** * Represents a single room in the RoomNavigator program. Each room keeps track of a name, as well as a list of the * names of the other rooms it's connected to. */ public class Room { private String name; private ArrayList connectedRooms; public Room(String name) { this.name = name; this.connectedRooms = new ArrayList<>(); } public String getName() { return name; } public ArrayList getConnectedRooms() { return new ArrayList<>(connectedRooms); } public void addConnectedRoom(String roomName) { connectedRooms.add(roomName); } } 
 RoomNavigator class  package edu.csc220.navigator; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; public class RoomNavigator { /** * Returns true if and only if a path exists between the start room and the end room, based on the description of * rooms provided by the allRooms list. The start and end rooms are specified by their names. */ public boolean doesPathExist(ArrayList allRooms, String startRoom, String endRoom) { // TODO: Implement. Step 1: create and populate your Room map with everything from the rooms list. // TODO: Implement. Step 2: create your breadth-first search queue and start it off with the initial room. // TODO: Implement. Step 3: in a loop, repeatedly process the next Room in the queue. return false; } /** Program execution begins here. */ public static void main(String[] args) { ArrayList allRooms = readRooms(); RoomNavigator navigator = new RoomNavigator(); // Paths between rooms that are on the same floor (expecting 'true'): lookForPath(navigator, allRooms, "Larder", "Gardens"); lookForPath(navigator, allRooms, "Upper Landing", "Attic"); lookForPath(navigator, allRooms, "Chapel", "Wine Cellar"); // Paths between rooms that are on different floors (expecting 'false'): lookForPath(navigator, allRooms, "Patio", "Game Room"); lookForPath(navigator, allRooms, "Tower", "Crypt"); lookForPath(navigator, allRooms, "Underground Lake", "Library"); } /** * Reads the "layout.txt" file and creates a list of Room objects with their connections set up accordingly. You * should not modify this method in any way. */ private static ArrayList readRooms() { ArrayList rooms = new ArrayList<>(); try { BufferedReader bufferedReader = new BufferedReader(new FileReader("layout.txt")); String line; while ((line = bufferedReader.readLine()) != null) { if (line.strip().isEmpty()) { continue; } int splitIndex = line.indexOf(';'); if (splitIndex < 0) { throw new RuntimeException( "Invalid layout file! Missing ';' to separate room from its connected neighbors: " + line); } Room currentRoom = new Room(line.substring(0, splitIndex).strip()); for (String connectedRoom: line.substring(splitIndex + 1).split(",")) { currentRoom.addConnectedRoom(connectedRoom.strip()); } rooms.add(currentRoom); } bufferedReader.close(); } catch (IOException exception) { throw new RuntimeException(exception); } return rooms; } /** * Tests your doesPathExist implementation against the given start and end rooms. You can run your own check by * calling lookForPath in main, similar to the existing calls. */ private static void lookForPath( RoomNavigator navigator, ArrayList allRooms, String startRoom, String endRoom) { System.out.printf( "Path from '%s' to '%s': %s%n", startRoom, endRoom, navigator.doesPathExist(allRooms, startRoom, endRoom)); } } 

layout.txt

Entrance Hall; Foyer Foyer; Entrance Hall, Library, Dining Hall, Conservatory Conservatory; Foyer, Graveyard, Gardens Graveyard; Conservatory Gardens; Conservatory Library; Foyer, Storeroom Storeroom; Library, Larder Larder; Storeroom, Kitchen Kitchen; Larder, Charred Room, Dining Hall Charred Room; Kitchen Dining Hall; Kitchen, Patio, Foyer, Ballroom Ballroom; Dining Hall Patio; Dining Hall Upper Landing; Dusty Hallway Dusty Hallway; Upper Landing, Game Room, Collapsed Room, Bedroom Game Room; Dusty Hallway Collapsed Room; Dusty Hallway Bedroom; Dusty Hallway, Junk Room, Balcony, Creaky Hallway Balcony; Bedroom Junk Room; Bedroom, Abandoned Room Creaky Hallway; Bedroom, Abandoned Room, Chasm Chasm; Creaky Hallway, Tower Tower; Chasm Abandoned Room; Creaky Hallway, Junk Room, Attic Attic; Abandoned Room Basement Landing; Catacombs Catacombs; Basement Landing, Chapel, Crypt, Statuary Corridor Chapel; Catacombs Crypt; Catacombs Statuary Corridor; Catacombs, Underground Lake, Furnace Room, Gallery Underground Lake; Statuary Corridor Furnace Room; Statuary Corridor Gallery; Statuary Corridor, Research Laboratory, Vault Research Laboratory; Gallery Vault; Gallery, Wine Cellar Wine Cellar; Vault

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!