package components;

import javafx.scene.control.Label;
import javafx.scene.layout.HBox;

public class FloatStatRow extends HBox {
    String text;
    float value;

    Label textLabel = new Label();
    Label valueLabel = new Label();

    public FloatStatRow(String text, float value) {
        this.text = text;
        this.value = value;

        textLabel.setText(text);
        valueLabel.setText(String.valueOf(value));
        this.getChildren().add(textLabel);
        this.getChildren().add(valueLabel);
    }

    public void increaseValue() {
        value++;
        updateValueLabel();
    }

    public void decreaseValue() {
        value--;
        updateValueLabel();
    }

    public void increaseValue(float valueToAdd) {
        value += valueToAdd;
        updateValueLabel();
    }

    public void decreaseValue(float valueToSubtract) {
        value -= valueToSubtract;
        updateValueLabel();
    }

    private void updateValueLabel() {
        valueLabel.setText(String.valueOf(value));
    }


    public float getValue() {
        return value;
    }
}