added documentation for Rent

This commit is contained in:
Yvonne Schmidt 2024-12-02 08:40:02 +01:00
parent 459a54ac5d
commit cc157a3cf3

View File

@ -28,20 +28,43 @@ import java.util.Set;
import java.util.stream.Collectors;
/**
* RepayMortage is a popup which appears when a player clicks on the "Repay Mortage"-button in the BuildingAdminMenu
* RepayMortage is a popup that appears when a player selects the "Repay Mortgage" option
* in the Building Administration Menu.
* <p>
* This popup allows the player to select mortgaged properties and repay their mortgages,
* showing the total cost of the repayment. Includes options to confirm or cancel the repayment.
* </p>
*/
public class RepayMortage extends Dialog {
/** Reference to the Monopoly application instance. */
private final MonopolyApp app;
/** Main container for the mortgage repayment menu. */
private final Container repayMortageContainer;
/** Background container providing a border for the popup. */
private final Container backgroundContainer;
private TextField selectionDisplay; // TextField to display selections
/** Text field to display selected properties. */
private TextField selectionDisplay;
/** Reference to track property selections in the dropdown menu. */
private VersionedReference<Set<Integer>> selectionRef;
/** Dropdown menu for selecting mortgaged properties. */
private Selector<String> propertySelector;
/** Set of selected properties for mortgage repayment. */
private Set<String> selectedProperties = new HashSet<>();
/** Label displaying the total repayment cost. */
private Label cost = new Label("0", new ElementId("label-Text"));
/**
* Constructs the RepayMortage popup for handling mortgage repayment.
*
* @param app the Monopoly application instance
*/
public RepayMortage(MonopolyApp app) {
super(app.getDialogManager());
this.app = app;
@ -154,6 +177,7 @@ public class RepayMortage extends Dialog {
return dropdownContainer;
}
/**
* Retrieves the list of properties owned by the current player.
*
@ -170,6 +194,11 @@ public class RepayMortage extends Dialog {
.collect(Collectors.toList());
}
/**
* Updates the UI based on selection changes in the dropdown menu.
*
* @param delta the time elapsed since the last update
*/
@Override
public void update(float delta) {
if(selectionRef.update()) {
@ -178,7 +207,9 @@ public class RepayMortage extends Dialog {
}
/**
* Handles property selection changes.
* Handles changes in the property selection and updates the total repayment cost.
*
* @param playerProperties the dropdown menu for selecting properties
*/
private void onDropdownSelectionChanged(Selector<String> playerProperties) {
String selected = playerProperties.getSelectedItem();
@ -201,7 +232,7 @@ public class RepayMortage extends Dialog {
}
/**
* Schließt das Menü und entfernt die GUI-Elemente.
* Closes the popup and removes its associated GUI elements.
*/
@Override
public void close() {
@ -210,6 +241,9 @@ public class RepayMortage extends Dialog {
super.close();
}
/**
* Opens the settings menu when the escape key is pressed.
*/
@Override
public void escape() {
new SettingsMenu(app).open();