Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In Java: Create a JavaFX GUI that represents the streets of Pamplona. You do not

ID: 3824801 • Letter: I

Question

In Java:

Create a JavaFX GUI that represents the streets of Pamplona. You do not need to consult an actual map of Pamplona, although you may if you want to.

Do the styling (coding of the details of the appearance of the GUI, such as colors and font sizes) using CSS, not the JavaFX setters, wherever possible. Make the start and finish squares appear different from other squares.

Here are some of the classes you will need. This is not a complete list, and each class will need more than the basics I specify below:

A Coordinate class with an int row, an int column, and a char representing the value of the coordinate (this week, you will use four values for the Coordinates: blank (' ') for an empty space, W for a wall, S for the starting point, and E for the exit.) Provide getters and setters.

A StreetMap class with a two-dimensional array of Coordinates but no GUI code.

A JavaFX GUI class called MazeGUIPane. Since the constructor for Scene takes a Pane as a parameter, this class should extend one of the Pane classes, most likely BorderPane. It should also contain a GridPane with a two-dimensional grid of Labels. One label in the GridPane corresponds to one Coordinate in the StreetMap. Note this important distinction: the MazeGUIPane is for the the user interface while the StreetMap is for data.

The outer edges of the grid should consist of walls, except for one starting square and one exit square. When the game starts, squares that are not on the edges should be randomly set to wall and space squares (use about 20% walls.) Note that this does not guarantee that it is possible to escape the bulls at all; that is why you need to be able to toggle between walls and spaces.

Clicking on a label that is not on the edge of the board toggles the label between wall and empty space. The event handling code must update the StreetMap when the squares toggle. It must also change the css class of the Label in order to change its appearance.

You will also need a game reset button. You do not need to make the button work yet. In my solution, this button is in an HBox contained in the MazeGUIPane.

You may use this GUI as a model if you like, but feel free to create a different one:

Map of Pamplona Run

Explanation / Answer

package com.lynden.gmapsexampleapp; import com.lynden.gmapsfx.GoogleMapView; import com.lynden.gmapsfx.MapComponentInitializedListener; import com.lynden.gmapsfx.javascript.object.GoogleMap; import com.lynden.gmapsfx.javascript.object.LatLong; import com.lynden.gmapsfx.javascript.object.MapOptions; import com.lynden.gmapsfx.javascript.object.MapType; import com.lynden.gmapsfx.javascript.object.Marker; import com.lynden.gmapsfx.javascript.object.MarkerOptions; import javafx.application.Application; import static javafx.application.Application.launch; import javafx.scene.Scene; import javafx.stage.Stage; public class MainApp extends Application implements MapComponentInitializedListener { GoogleMapView mapView; GoogleMap map; @Override public void start(Stage stage) throws Exception { //Create the JavaFX component and set this as a listener so we know when //the map has been initialized, at which point we can then begin manipulating it. mapView = new GoogleMapView(); mapView.addMapInializedListener(this); Scene scene = new Scene(mapView); stage.setTitle("JavaFX and Google Maps"); stage.setScene(scene); stage.show(); } @Override public void mapInitialized() { //Set the initial properties of the map. MapOptions mapOptions = new MapOptions(); mapOptions.center(new LatLong(47.6097, -122.3331)) .mapType(MapType.ROADMAP) .overviewMapControl(false) .panControl(false) .rotateControl(false) .scaleControl(false) .streetViewControl(false) .zoomControl(false) .zoom(12); map = mapView.createMap(mapOptions); //Add a marker to the map MarkerOptions markerOptions = new MarkerOptions(); markerOptions.position( new LatLong(47.6, -122.3) ) .visible(Boolean.TRUE) .title("My Marker"); Marker marker = new Marker( markerOptions ); map.addMarker(marker); } public static void main(String[] args) { launch(args); } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote