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

can you write the documentation of the code? public class Color { static boolean

ID: 3838994 • Letter: C

Question

can you write the documentation of the code?

public class Color {

   static boolean result;

public boolean chooseColorPane(Monster[] enemies) {

  

   Stage PickColorStage = new Stage();

   BorderPane mainPane = new BorderPane();

VBox listOfHydrons = new VBox();

VBox listOfZexors = new VBox();

HBox hydronsSide = new HBox();

HBox zexorsSide = new HBox();

RadioButton hydron1 = new RadioButton("Hyrdon Fred");

RadioButton hydron2 = new RadioButton("Hyrdon Miguel");

RadioButton hydron3 = new RadioButton("Hyrdon Samo");

RadioButton zexor1 = new RadioButton("Zexor Mark");

RadioButton zexor2 = new RadioButton("Zexor Sally");

RadioButton zexor3 = new RadioButton("Zexor Nista");

Button gameStart = new Button("start");

gameStart.setPrefWidth(200);

gameStart.setMinWidth(gameStart.getPrefWidth()/2);

Text color = new Text("HYDRONS");

Text color1 = new Text("ZEXORS");

gameStart.setAlignment(Pos.CENTER);

gameStart.setStyle("-fx-font: 12 verdana; -fx-base: #FFD732; -fx-font-weight: bold");

listOfHydrons.setStyle("-fx-border-color: black;-fx-border-width: 2px");

listOfZexors.setStyle("-fx-border-color: black;-fx-border-width: 2px");

listOfHydrons.setPadding(new Insets(15, 12, 15, 12));

listOfHydrons.setSpacing(40);

listOfZexors.setPadding(new Insets(15, 12, 15, 12));

listOfZexors.setSpacing(40);

listOfHydrons.getChildren().addAll(color, hydron1, hydron2, hydron3);

listOfZexors.getChildren().addAll(color1, zexor1, zexor2, zexor3);

  

hydronsSide.setPadding(new Insets(15, 12, 15, 250));

hydronsSide.setSpacing(10);

zexorsSide.setPadding(new Insets(15, 12, 15, 250));

zexorsSide.setSpacing(10);

hydronsSide.getChildren().addAll(enemies[0], enemies[1], enemies[2]);

zexorsSide.getChildren().addAll(enemies[3], enemies[4], enemies[5]);

  

ToggleGroup group = new ToggleGroup();

hydron1.setToggleGroup(group);

hydron2.setToggleGroup(group);

hydron3.setToggleGroup(group);

zexor1.setToggleGroup(group);

zexor2.setToggleGroup(group);

zexor3.setToggleGroup(group);

color.setFont(new Font("verdana", 18));

color.setFill(javafx.scene.paint.Color.LAVENDER);

color1.setFont(new Font("verdana", 18));

color1.setFill(javafx.scene.paint.Color.LAVENDER);

hydron1.setOnAction((ActionEvent event) -> {

if (hydron1.isSelected()) {

displayColorPicker(enemies[0]);

}

});

hydron2.setOnAction((ActionEvent event) -> {

if (hydron2.isSelected()) {

displayColorPicker(enemies[1]);

}

});

hydron3.setOnAction((ActionEvent event) -> {

if (hydron3.isSelected()) {

displayColorPicker(enemies[2]);

}

});

zexor1.setOnAction((ActionEvent event) -> {

if (zexor1.isSelected()) {

displayColorPicker(enemies[3]);

}

});

zexor2.setOnAction((ActionEvent event) -> {

if (zexor2.isSelected()) {

displayColorPicker(enemies[4]);

}

});

zexor3.setOnAction((ActionEvent event) -> {

if (zexor3.isSelected()) {

displayColorPicker(enemies[5]);

}

});

gameStart.setOnAction(e -> result = true; PickColorStage.close(); });

Pane background = new Pane();

Scene mainScene = new Scene(background, 900, 600);

background.setStyle("-fx-background-color: #4682B4;");

background.getChildren().add(mainPane);

mainPane.setPrefHeight(600);

mainPane.setPrefWidth(900);

mainPane.setPadding(new Insets(5, 5, 5, 5));

mainPane.setLeft(listOfHydrons);

mainPane.setRight(listOfZexors);

mainPane.setBottom(hydronsSide);

mainPane.setTop(zexorsSide);

mainPane.setCenter(gameStart);

PickColorStage.setTitle("Color Picker");

PickColorStage.setScene(mainScene);

PickColorStage.showAndWait();

return result;

}

private void displayColorPicker(Monster obj) {

javafx.scene.control.ColorPicker colorPicker = new javafx.scene.control.ColorPicker();

Button gameFinish = new Button("OK");

gameFinish.setPrefWidth(200);

gameFinish.setMinWidth(gameFinish.getPrefWidth()/2);

VBox colorBox = new VBox(10);

Scene colorScene = new Scene(colorBox, 250, 250);

Stage colorStage = new Stage();

Label color = new Label("COLOR ");

gameFinish.setStyle("-fx-font: 12 verdana; -fx-base:#FFD732; -fx-font-weight: bold;");

colorBox.setStyle("-fx-font: 12 verdana; -fx-base:#4682B4; -fx-font-weight: bold;");

colorBox.setPadding(new Insets(50, 50, 50, 50));

colorBox.getChildren().add(color);

colorBox.getChildren().add(colorPicker);

colorBox.setAlignment(Pos.CENTER);

colorBox.getChildren().add(gameFinish);

gameFinish.setOnAction(e -> {

if (obj instanceof Zexor) {

((Zexor) obj).getSquare().setFill(colorPicker.getValue());

} else if (obj instanceof Hydron) {

((Hydron) obj).getTriangle().setFill(colorPicker.getValue());

}

colorStage.close();

});

colorStage.setScene(colorScene);

colorStage.showAndWait();

}

Explanation / Answer

Here is the documention of the given code. Please find as inline comment for this.

// Class declaration as Color
public class Color {
// static boolean value as result to store final answer
static boolean result;
// boolean function with type Monster as array
public boolean chooseColorPane(Monster[] enemies) {
// Class stage new object declaration
Stage PickColorStage = new Stage();
//New object mainPane for BorderPane Class
BorderPane mainPane = new BorderPane();
// VBOX class objects as listOfHydrons, listOfZexors
VBox listOfHydrons = new VBox();
VBox listOfZexors = new VBox();
// HBOX class object declaration
HBox hydronsSide = new HBox();
HBox zexorsSide = new HBox();
//RadioButton for choosing different options like Hyrdon Fred, Hyrdon Miguel, Hyrdon Samo, Zexor Mark, Zexor Sally, Zexor Nista
RadioButton hydron1 = new RadioButton("Hyrdon Fred");
RadioButton hydron2 = new RadioButton("Hyrdon Miguel");
RadioButton hydron3 = new RadioButton("Hyrdon Samo");
RadioButton zexor1 = new RadioButton("Zexor Mark");
RadioButton zexor2 = new RadioButton("Zexor Sally");
RadioButton zexor3 = new RadioButton("Zexor Nista");
// Button class to creation start button
Button gameStart = new Button("start");
//Setting predeifned width of game
gameStart.setPrefWidth(200);
//Setting min width
gameStart.setMinWidth(gameStart.getPrefWidth()/2);
// Displat Text as HYDRONS vS Zexors
Text color = new Text("HYDRONS");
Text color1 = new Text("ZEXORS");
// alignment according to center
gameStart.setAlignment(Pos.CENTER);
// Setting up stype of game with text as verdana and font weight as bold
gameStart.setStyle("-fx-font: 12 verdana; -fx-base: #FFD732; -fx-font-weight: bold");
// Setting up Stylem padding and spacing for Hydrons and Zexrons
listOfHydrons.setStyle("-fx-border-color: black;-fx-border-width: 2px");
listOfZexors.setStyle("-fx-border-color: black;-fx-border-width: 2px");
listOfHydrons.setPadding(new Insets(15, 12, 15, 12));
listOfHydrons.setSpacing(40);
listOfZexors.setPadding(new Insets(15, 12, 15, 12));
listOfZexors.setSpacing(40);
//Setting color for radio buttons
listOfHydrons.getChildren().addAll(color, hydron1, hydron2, hydron3);
listOfZexors.getChildren().addAll(color1, zexor1, zexor2, zexor3);
//Setting up padding and spacing
hydronsSide.setPadding(new Insets(15, 12, 15, 250));
hydronsSide.setSpacing(10);
zexorsSide.setPadding(new Insets(15, 12, 15, 250));
zexorsSide.setSpacing(10);
hydronsSide.getChildren().addAll(enemies[0], enemies[1], enemies[2]);
zexorsSide.getChildren().addAll(enemies[3], enemies[4], enemies[5]);
// Create a toggle group to select from
ToggleGroup group = new ToggleGroup();
// Hydron1,2,3 and Zexrons1,2,3 belong to togglegroup as group, can now select one from them
hydron1.setToggleGroup(group);
hydron2.setToggleGroup(group);
hydron3.setToggleGroup(group);
zexor1.setToggleGroup(group);
zexor2.setToggleGroup(group);
zexor3.setToggleGroup(group);
//Setting up Font and size with color and color1
color.setFont(new Font("verdana", 18));
color.setFill(javafx.scene.paint.Color.LAVENDER);
color1.setFont(new Font("verdana", 18));
color1.setFill(javafx.scene.paint.Color.LAVENDER);
// defining action
//if hyron1 is selected displaycolorpicker function is called with enemies value at 0
hydron1.setOnAction((ActionEvent event) -> {
if (hydron1.isSelected()) {
displayColorPicker(enemies[0]);
}
});
//if hyron2 is selected displaycolorpicker function is called with enemies value at 1
hydron2.setOnAction((ActionEvent event) -> {
if (hydron2.isSelected()) {
displayColorPicker(enemies[1]);
}
});
//if hyron3 is selected displaycolorpicker function is called with enemies value at 2
hydron3.setOnAction((ActionEvent event) -> {
if (hydron3.isSelected()) {
displayColorPicker(enemies[2]);
}
});
//if zexron1 is selected displaycolorpicker function is called with enemies value at 1
zexor1.setOnAction((ActionEvent event) -> {
if (zexor1.isSelected()) {
displayColorPicker(enemies[3]);
}
});
//if zexron2 is selected displaycolorpicker function is called with enemies value at 4
zexor2.setOnAction((ActionEvent event) -> {
if (zexor2.isSelected()) {
displayColorPicker(enemies[4]);
}
});
//if zexron3 is selected displaycolorpicker function is called with enemies value at 5
zexor3.setOnAction((ActionEvent event) -> {
if (zexor3.isSelected()) {
displayColorPicker(enemies[5]);
}
});
//Start Game
gameStart.setOnAction(e -> result = true; PickColorStage.close(); });
// Created background of whole scene
Pane background = new Pane();
//Created new scene by passing background object
Scene mainScene = new Scene(background, 900, 600);
// Setting up style
background.setStyle("-fx-background-color: #4682B4;");
// Add mainPane
background.getChildren().add(mainPane);
//Setting up predefined height and width
mainPane.setPrefHeight(600);
mainPane.setPrefWidth(900);
// setting up padding all around
mainPane.setPadding(new Insets(5, 5, 5, 5));
// Hydron will be on left
mainPane.setLeft(listOfHydrons);
// Zexrons will be on right
mainPane.setRight(listOfZexors);
//On Bottom will show hyron side
mainPane.setBottom(hydronsSide);
// On top will show zexron side
mainPane.setTop(zexorsSide);
// In center will be gamestart object
mainPane.setCenter(gameStart);
//Setting title to start
PickColorStage.setTitle("Color Picker");
//Setting up main scene
PickColorStage.setScene(mainScene);
// Start
PickColorStage.showAndWait();
return result;
}
// displaycolorpicker def declaration
private void displayColorPicker(Monster obj) {
// Color picker object declartion
javafx.scene.control.ColorPicker colorPicker = new javafx.scene.control.ColorPicker();
// Button creation with title ok
Button gameFinish = new Button("OK");
// As game finish width 200
gameFinish.setPrefWidth(200);
// Mini width setting
gameFinish.setMinWidth(gameFinish.getPrefWidth()/2);
// VBOX object creation
VBox colorBox = new VBox(10);
// Scene creation
Scene colorScene = new Scene(colorBox, 250, 250);
Stage colorStage = new Stage();
// Text display as Label
Label color = new Label("COLOR ");
// Setting up style
gameFinish.setStyle("-fx-font: 12 verdana; -fx-base:#FFD732; -fx-font-weight: bold;");
colorBox.setStyle("-fx-font: 12 verdana; -fx-base:#4682B4; -fx-font-weight: bold;");
//Setting up padding
colorBox.setPadding(new Insets(50, 50, 50, 50));
colorBox.getChildren().add(color);
colorBox.getChildren().add(colorPicker);
// alignment to center
colorBox.setAlignment(Pos.CENTER);
colorBox.getChildren().add(gameFinish);
// If object is instance of Zerox fill with its color
gameFinish.setOnAction(e -> {
if (obj instanceof Zexor) {
((Zexor) obj).getSquare().setFill(colorPicker.getValue());
}
// If object is instance of Hydron sfill with its color
else if (obj instanceof Hydron) {
((Hydron) obj).getTriangle().setFill(colorPicker.getValue());
}
colorStage.close();
});
colorStage.setScene(colorScene);
colorStage.showAndWait();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote