JAVA CODE can you help to change this code to do not make a

JAVA CODE

can you help to change this code to ( do not make a new one, need to use this old code )

Running of the Bulls game.

In our version of the Running of the Bulls, one fool runs through Pamplona trying to avoid some number of bulls. If the fool makes it to the exit square without being gored, he wins; if a bull catches him first, he loses. When one of these events occurs, a message should appear next to the Run button.

The fool\'s movement must be controlled by the four scroll keys (use an event handler that handles a KeyEvent and find the key strokes using the the KeyCode enum). Make sure he cannot move through walls. Use a Coordinate variable to track the fool\'s location. I did not use a Fool class, but you may use one if you like.

You will need a Bull class. Among other things, it will contain a method to determine the bull\'s next step. If he can see the fool, he moves towards him. If the bull cannot see the fool, he moves toward the fool\'s last known location if possible, otherwise he moves randomly. Like the fool, the bulls cannot move through walls.

The bulls should move faster than the fool. The best way to implement this is for the bulls to take more than one move for each fool move. You can code this by writing a method in StreetMap that calls each bull\'s move method, and calling the StreetMap method some number of times from inside the fool move event handler (the one that responds to the scroll keys.) Since the bulls move faster, the fool should get a few free moves before the Bulls begin moving.

Use css to make it obvious at all times where the bulls and the fool are.

Create an event handler for the run button which returns both the fool and the bulls to the starting point. You may also have the button also create a new map.

Experiment with the game to make it difficult, but still possible, for the fool to escape unharmed. Design Main so that you can set parameters there for the number of turns in the head start, the number of bulls, and the number of bull moves per fool move. If you want more practice with GUI building, provide a way to set these parameters with user input.

///////////////////////////////////////////////////////////////

MazeGuiPane.java

import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class MazeGuiPane extends Application {
private GridPane grid = new GridPane();
private BorderPane border = new BorderPane();
private Scene sc = new Scene(border);
public Label[][] labelGridArray = new Label[20][20];
private StreetMap map = new StreetMap();
int col;
int row;

public void start(Stage primary) {

sc.getStylesheets().add(\"style.css\");
grid.getStyleClass().add(\"grid-style\");
border.getStyleClass().add(\"border-style\");
Label mainTitle = new Label(\"Map Of Pamplona\");
mainTitle.getStyleClass().add(\"white-text\");
Button butt = new Button(\"RUN!\");
VBox vBox = new VBox();
HBox buttHBox = new HBox();
HBox titleBox = new HBox();
VBox titleVBox = new VBox();
VBox buttVBox = new VBox();

map.makeGrid();

for (col = 0; col < 20; col++) {
for (row = 0; row < 20; row++) {
Label square = new Label();
if (map.gridArray[col][row].getValue() == \' \'){
square.getStyleClass().add(\"default-box\");
}
else if(map.gridArray[col][row].getValue() == \'S\') {
square.setText(\"Start\");
square.getStyleClass().add(\"start-end\");
}
else if(map.gridArray[col][row].getValue() == \'E\') {
square.setText(\"End\");
square.getStyleClass().add(\"start-end\");
}
else {
square.getStyleClass().add(\"wall\");
}
// System.out.println(map.gridArray[col][row]);
// System.out.println(\"label: \" + labelGridArray[col][row] );

square.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent t) {
row = grid.getRowIndex(square);
col = grid.getColumnIndex(square);
if(map.gridArray[col][row].getValue() == \'W\'){
square.getStyleClass().removeAll(\"wall\");
square.getStyleClass().add(\"default-box\");
map.gridArray[col][row].setTier(row); map.gridArray[col][row].setColumn(col); map.gridArray[col][row].setValue(\' \');
}
else {
square.getStyleClass().removeAll(\"default-box\");
square.getStyleClass().add(\"wall\");
map.gridArray[col][row].setTier(row); map.gridArray[col][row].setColumn(col); map.gridArray[col][row].setValue(\'W\');
}
}
});

labelGridArray[col][row] = square;
grid.add(square, col, row);
}
}
titleBox.getStyleClass().add(\"title\");
titleBox.getChildren().add(mainTitle);
titleVBox.getChildren().add(titleBox);

buttHBox.getStyleClass().add(\"button-style\");
buttHBox.getChildren().add(butt);
buttVBox.getChildren().add(buttHBox);

vBox.getChildren().add(grid);

border.setTop((titleBox));
border.setCenter(vBox);
border.setBottom(buttVBox);


primary.setScene(sc);
primary.show();
}


public static void main (String[] args) {
launch(args);
}}

=========================================================

Coordinate.java

==================================================================

StreetMap.java

==================================================================

style.css

Solution

import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class MazeGuiPane extends Application {
private GridPane grid = new GridPane();
private BorderPane border = new BorderPane();
private Scene sc = new Scene(border);
public Label[][] labelGridArray = new Label[20][20];
private StreetMap map = new StreetMap();
int col;
int row;

public void start(Stage primary) {

sc.getStylesheets().add(\"style.css\");
grid.getStyleClass().add(\"grid-style\");
border.getStyleClass().add(\"border-style\");
Label mainTitle = new Label(\"Map Of Pamplona\");
mainTitle.getStyleClass().add(\"white-text\");
Button butt = new Button(\"RUN!\");
VBox vBox = new VBox();
HBox buttHBox = new HBox();
HBox titleBox = new HBox();
VBox titleVBox = new VBox();
VBox buttVBox = new VBox();

map.makeGrid();

for (col = 0; col < 20; col++) {
for (row = 0; row < 20; row++) {
Label square = new Label();
if (map.gridArray[col][row].getValue() == \' \'){
square.getStyleClass().add(\"default-box\");
}
else if(map.gridArray[col][row].getValue() == \'S\') {
square.setText(\"Start\");
square.getStyleClass().add(\"start-end\");
}
else if(map.gridArray[col][row].getValue() == \'E\') {
square.setText(\"End\");
square.getStyleClass().add(\"start-end\");
}
else {
square.getStyleClass().add(\"wall\");
}
// System.out.println(map.gridArray[col][row]);
// System.out.println(\"label: \" + labelGridArray[col][row] );

square.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent t) {
row = grid.getRowIndex(square);
col = grid.getColumnIndex(square);
if(map.gridArray[col][row].getValue() == \'W\'){
square.getStyleClass().removeAll(\"wall\");
square.getStyleClass().add(\"default-box\");
map.gridArray[col][row].setTier(row); map.gridArray[col][row].setColumn(col); map.gridArray[col][row].setValue(\' \');
}
else {
square.getStyleClass().removeAll(\"default-box\");
square.getStyleClass().add(\"wall\");
map.gridArray[col][row].setTier(row); map.gridArray[col][row].setColumn(col); map.gridArray[col][row].setValue(\'W\');
}
}
});

labelGridArray[col][row] = square;
grid.add(square, col, row);
}
}
titleBox.getStyleClass().add(\"title\");
titleBox.getChildren().add(mainTitle);
titleVBox.getChildren().add(titleBox);

buttHBox.getStyleClass().add(\"button-style\");
buttHBox.getChildren().add(butt);
buttVBox.getChildren().add(buttHBox);

vBox.getChildren().add(grid);

border.setTop((titleBox));
border.setCenter(vBox);
border.setBottom(buttVBox);


primary.setScene(sc);
primary.show();
}


public static void main (String[] args) {
launch(args);
}}

JAVA CODE can you help to change this code to ( do not make a new one, need to use this old code ) Running of the Bulls game. In our version of the Running of t
JAVA CODE can you help to change this code to ( do not make a new one, need to use this old code ) Running of the Bulls game. In our version of the Running of t
JAVA CODE can you help to change this code to ( do not make a new one, need to use this old code ) Running of the Bulls game. In our version of the Running of t
JAVA CODE can you help to change this code to ( do not make a new one, need to use this old code ) Running of the Bulls game. In our version of the Running of t
JAVA CODE can you help to change this code to ( do not make a new one, need to use this old code ) Running of the Bulls game. In our version of the Running of t

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site