From b6d9d00e23b0a3a98c2841d65a936f0652151455 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Tue, 24 Sep 2024 20:48:02 -0500 Subject: [PATCH] Remove @SuppressWarnings annotations and add documentation Removed redundant @SuppressWarnings annotations from multiple classes and enhanced codebase documentation. The changes add clarity to the functionality of classes and methods through JavaDocs, improving maintainability and readability. --- .../personnel/divorce/AbstractDivorce.java | 10 +- .../personnel/divorce/RandomDivorce.java | 21 +- .../personnel/enums/PersonnelStatus.java | 203 ++++++++++++++++-- .../personnel/enums/RandomDivorceMethod.java | 38 +++- .../personnel/enums/RandomMarriageMethod.java | 36 +++- .../enums/RandomProcreationMethod.java | 36 +++- .../personnel/marriage/AbstractMarriage.java | 10 - .../personnel/marriage/RandomMarriage.java | 22 +- .../procreation/RandomProcreation.java | 34 +-- .../divorce/AbstractDivorceTest.java | 23 -- 10 files changed, 357 insertions(+), 76 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/personnel/divorce/AbstractDivorce.java b/MekHQ/src/mekhq/campaign/personnel/divorce/AbstractDivorce.java index cf5b9a2fa7..1d4642f854 100644 --- a/MekHQ/src/mekhq/campaign/personnel/divorce/AbstractDivorce.java +++ b/MekHQ/src/mekhq/campaign/personnel/divorce/AbstractDivorce.java @@ -173,7 +173,7 @@ public void setUseRandomPrisonerDivorce(final boolean useRandomPrisonerDivorce) /** * This is a standardization method for the divorce surname style to use when a person's spouse * dies. - * + *

* TODO : I should be part of AbstractDeath * * @param campaign the campaign the person is in @@ -300,6 +300,14 @@ public void divorce(final Campaign campaign, final LocalDate today, final Person MekHQ.triggerEvent(new PersonChangedEvent(origin)); } + /** + * Processes divorce events that occur as part of a character's background. + * + * @param campaign the campaign associated with the divorce + * @param today the current date of the divorce + * @param origin the person whose background is being divorced + * @param style the splitting surname style to be applied + */ public void backgroundDivorce(final Campaign campaign, final LocalDate today, final Person origin, final SplittingSurnameStyle style) { final Person spouse = origin.getGenealogy().getSpouse(); diff --git a/MekHQ/src/mekhq/campaign/personnel/divorce/RandomDivorce.java b/MekHQ/src/mekhq/campaign/personnel/divorce/RandomDivorce.java index bbe0a163a1..5226acc6c6 100644 --- a/MekHQ/src/mekhq/campaign/personnel/divorce/RandomDivorce.java +++ b/MekHQ/src/mekhq/campaign/personnel/divorce/RandomDivorce.java @@ -22,25 +22,42 @@ import mekhq.campaign.CampaignOptions; import mekhq.campaign.personnel.enums.RandomDivorceMethod; +/** + * The {@link RandomDivorce} class is an implementation of the {@link AbstractDivorce} class that + * represents a divorce method based on random chance. + * The divorce outcome is determined by rolling a die with a specified number of sides. + */ public class RandomDivorce extends AbstractDivorce { //region Variable Declarations private int divorceDiceSize; //endregion Variable Declarations //region Constructors + /** + * The {@link RandomDivorce} class is an implementation of the {@link AbstractDivorce} class that + * represents a divorce method based on random chance. + */ public RandomDivorce(final CampaignOptions options) { super(RandomDivorceMethod.DICE_ROLL, options); setDivorceDiceSize(options.getRandomDivorceDiceSize()); } //endregion Constructors + /** + * Retrieves the size of the divorce dice. + * + * @return The size of the divorce dice as an integer. + */ //region Getters/Setters - @SuppressWarnings(value = "unused") public int getDivorceDiceSize() { return divorceDiceSize; } - @SuppressWarnings(value = "unused") + /** + * Sets the size of the divorce dice. + * + * @param divorceDiceSize the size of the dice used to determine divorce outcomes + */ public void setDivorceDiceSize(final int divorceDiceSize) { this.divorceDiceSize = divorceDiceSize; } diff --git a/MekHQ/src/mekhq/campaign/personnel/enums/PersonnelStatus.java b/MekHQ/src/mekhq/campaign/personnel/enums/PersonnelStatus.java index 005baf2f40..5d7794974b 100644 --- a/MekHQ/src/mekhq/campaign/personnel/enums/PersonnelStatus.java +++ b/MekHQ/src/mekhq/campaign/personnel/enums/PersonnelStatus.java @@ -27,7 +27,7 @@ import java.util.stream.Stream; /** - * TODO : Add PoW, On Leave and AWOL implementations + * Enum class representing personnel status. */ public enum PersonnelStatus { // region Enum Declarations @@ -91,6 +91,14 @@ public enum PersonnelStatus { // endregion Variable Declarations // region Constructors + /** + * Initializes a new instance of the {@link PersonnelStatus} class with the given parameters. + * + * @param name the name of the personnel status + * @param toolTipText the tooltip text for the personnel status + * @param reportText the report text for the personnel status + * @param logText the log text for the personnel status + */ PersonnelStatus(final String name, final String toolTipText, final String reportText, final String logText) { final ResourceBundle resources = ResourceBundle.getBundle("mekhq.resources.Personnel", @@ -102,131 +110,296 @@ public enum PersonnelStatus { } // endregion Constructors + /** + * Retrieves the tooltip text for a given component. + * + * @return The tooltip text of the component, or null if no tooltip text is set. + */ // region Getters public String getToolTipText() { return toolTipText; } + /** + * Retrieves the report text. + * + * @return The report text as a string. + */ public String getReportText() { return reportText; } + /** + * Retrieves the log text. + * + * @return The log text. + */ public String getLogText() { return logText; } // endregion Getters // region Boolean Comparison Methods + /** + * Checks if the character has the {@code ACTIVE} personnel status. + * + * @return {@code true} if the character has the {@code ACTIVE} personnel status {@code false} + * otherwise. + */ public boolean isActive() { return this == ACTIVE; } + /** + * Checks if the character has the {@code MIA} personnel status. + * + * @return {@code true} if the character has the {@code MIA} personnel status {@code false} + * otherwise. + */ public boolean isMIA() { return this == MIA; } + /** + * Checks if the character has the {@code POW} personnel status. + * + * @return {@code true} if the character has the {@code POW} personnel status {@code false} + * otherwise. + */ public boolean isPoW() { return this == POW; } + /** + * Checks if the character has the {@code ON_LEAVE} personnel status. + * + * @return {@code true} if the character has the {@code ON_LEAVE} personnel status {@code false} + * otherwise. + */ public boolean isOnLeave() { return this == ON_LEAVE; } + /** + * Checks if the character has the {@code ON_MATERNITY_LEAVE} personnel status. + * + * @return {@code true} if the character has the {@code ON_MATERNITY_LEAVE} personnel status + * {@code false} otherwise. + */ public boolean isOnMaternityLeave() { return this == ON_MATERNITY_LEAVE; } + /** + * Checks if the character has the {@code AWOL} personnel status. + * + * @return {@code true} if the character has the {@code AWOL} personnel status {@code false} + * otherwise. + */ public boolean isAwol() { return this == AWOL; } + /** + * Checks if the character has the {@code RETIRED} personnel status. + * + * @return {@code true} if the character has the {@code RETIRED} personnel status {@code false} + * otherwise. + */ public boolean isRetired() { return this == RETIRED; } + /** + * Checks if the character has the {@code RESIGNED} personnel status. + * + * @return {@code true} if the character has the {@code RESIGNED} personnel status {@code false} + * otherwise. + */ public boolean isResigned() { return this == RESIGNED; } + /** + * Checks if the character has the {@code SACKED} personnel status. + * + * @return {@code true} if the character has the {@code SACKED} personnel status {@code false} + * otherwise. + */ public boolean isSacked() { return this == SACKED; } + /** + * Checks if the character has the {@code LEFT} personnel status. + * + * @return {@code true} if the character has the {@code LEFT} personnel status {@code false} + * otherwise. + */ public boolean isLeft() { return this == LEFT; } + /** + * Checks if the character has the {@code DESERTED} personnel status. + * + * @return {@code true} if the character has the {@code DESERTED} personnel status {@code false} + * otherwise. + */ public boolean isDeserted() { return this == DESERTED; } + /** + * Checks if the character has the {@code DEFECTED} personnel status. + * + * @return {@code true} if the character has the {@code DEFECTED} personnel status {@code false} + * otherwise. + */ public boolean isDefected() { return this == DEFECTED; } + /** + * Checks if the character has the {@code STUDENT} personnel status. + * + * @return {@code true} if the character has the {@code STUDENT} personnel status {@code false} + * otherwise. + */ public boolean isStudent() { return this == STUDENT; } + /** + * Checks if the character has the {@code MISSING} personnel status. + * + * @return {@code true} if the character has the {@code MISSING} personnel status {@code false} + * otherwise. + */ public boolean isMissing() { return this == MISSING; } + /** + * Checks if the character has the {@code KIA} personnel status. + * + * @return {@code true} if the character has the {@code KIA} personnel status {@code false} + * otherwise. + */ public boolean isKIA() { return this == KIA; } + /** + * Checks if the character has the {@code HOMICIDE} personnel status. + * + * @return {@code true} if the character has the {@code HOMICIDE} personnel status {@code false} + * otherwise. + */ public boolean isHomicide() { return this == HOMICIDE; } + /** + * Checks if the character has the {@code WOUNDS} personnel status. + * + * @return {@code true} if the character has the {@code WOUNDS} personnel status {@code false} + * otherwise. + */ public boolean isWounds() { return this == WOUNDS; } + /** + * Checks if the character has the {@code DISEASE} personnel status. + * + * @return {@code true} if the character has the {@code DISEASE} personnel status {@code false} + * otherwise. + */ public boolean isDisease() { return this == DISEASE; } + /** + * Checks if the character has the {@code ACCIDENTAL} personnel status. + * + * @return {@code true} if the character has the {@code ACCIDENTAL} personnel status {@code false} + * otherwise. + */ public boolean isAccidental() { return this == ACCIDENTAL; } + /** + * Checks if the character has the {@code NATURAL_CAUSES} personnel status. + * + * @return {@code true} if the character has the {@code NATURAL_CAUSES} personnel status {@code false} + * otherwise. + */ public boolean isNaturalCauses() { return this == NATURAL_CAUSES; } + /** + * Checks if the character has the {@code OLD_AGE} personnel status. + * + * @return {@code true} if the character has the {@code OLD_AGE} personnel status {@code false} + * otherwise. + */ public boolean isOldAge() { return this == OLD_AGE; } + /** + * Checks if the character has the {@code MEDICAL_COMPLICATIONS} personnel status. + * + * @return {@code true} if the character has the {@code MEDICAL_COMPLICATIONS} personnel status + * {@code false} otherwise. + */ public boolean isMedicalComplications() { return this == MEDICAL_COMPLICATIONS; } + /** + * Checks if the character has the {@code PREGNANCY_COMPLICATIONS} personnel status. + * + * @return {@code true} if the character has the {@code PREGNANCY_COMPLICATIONS} personnel status + * {@code false} otherwise. + */ public boolean isPregnancyComplications() { return this == PREGNANCY_COMPLICATIONS; } + /** + * Checks if the character has the {@code UNDETERMINED} personnel status. + * + * @return {@code true} if the character has the {@code UNDETERMINED} personnel status {@code false} + * otherwise. + */ public boolean isUndetermined() { return this == UNDETERMINED; } + /** + * Checks if the character has the {@code SUICIDE} personnel status. + * + * @return {@code true} if the character has the {@code SUICIDE} personnel status {@code false} + * otherwise. + */ public boolean isSuicide() { return this == SUICIDE; } /** - * @return true if a person is currently absent from the core force, otherwise - * false + * @return {@code true} if a person is currently absent from the core force, otherwise + * {@code false} */ public boolean isAbsent() { return isMIA() || isPoW() || isOnLeave() || isOnMaternityLeave() || isAwol() || isStudent() || isMissing(); } /** - * @return true if a person has left the unit, otherwise false + * @return {@code true} if a person has left the unit, otherwise {@code false} */ public boolean isDepartedUnit() { return isDead() || isRetired() || isResigned() || isSacked() || isDeserted() || isDefected() || isMissing() @@ -234,7 +407,7 @@ public boolean isDepartedUnit() { } /** - * @return true if a person is dead, otherwise false + * @return {@code true} if a person is dead, otherwise {@code false} */ public boolean isDead() { return isKIA() || isHomicide() || isWounds() || isDisease() || isAccidental() @@ -243,13 +416,16 @@ public boolean isDead() { } /** - * @return true if a person is dead or MIA, otherwise false + * @return {@code true} if a person is dead or MIA, otherwise {@code false} */ public boolean isDeadOrMIA() { return isDead() || isMIA(); } // endregion Boolean Comparison Methods + /** + * @return The list of implemented personnel statuses. + */ public static List getImplementedStatuses() { return Stream.of(values()) .collect(Collectors.toList()); @@ -257,15 +433,16 @@ public static List getImplementedStatuses() { // region File I/O /** - * @param text containing the PersonnelStatus - * @return the saved PersonnelStatus + * Parses a string representation of {@link PersonnelStatus} into a {@link PersonnelStatus} object. + * If the string representation cannot be parsed, it returns the default {@code PersonnelStatus.ACTIVE}. + * + * @param text The {@link String} representation of {@link PersonnelStatus} + * @return The parsed {@link PersonnelStatus} object or {@code PersonnelStatus.ACTIVE} if parsing fails */ public static PersonnelStatus parseFromString(final String text) { try { return valueOf(text); - } catch (Exception ignored) { - - } + } catch (Exception ignored) {} try { switch (Integer.parseInt(text)) { @@ -320,11 +497,11 @@ public static PersonnelStatus parseFromString(final String text) { default: break; } - } catch (Exception ignored) { + } catch (Exception ignored) {} - } String message = String.format("Unable to parse %s into a PersonnelStatus. Returning ACTIVE.", text); + MMLogger.create(PersonnelStatus.class).error(message); return ACTIVE; } diff --git a/MekHQ/src/mekhq/campaign/personnel/enums/RandomDivorceMethod.java b/MekHQ/src/mekhq/campaign/personnel/enums/RandomDivorceMethod.java index d328296a06..db526631d2 100644 --- a/MekHQ/src/mekhq/campaign/personnel/enums/RandomDivorceMethod.java +++ b/MekHQ/src/mekhq/campaign/personnel/enums/RandomDivorceMethod.java @@ -28,6 +28,15 @@ import static megamek.client.ui.WrapLayout.wordWrap; +/** + * An enumeration representing the available random divorce methods. + *

+ * The {@link RandomDivorceMethod} enum is used to specify the method of randomly generating a divorce. + * It supports two methods: {@code NONE} and {@code DICE_ROLL}. + *

+ * The {@code NONE} method represents no random divorce generation, and the {@code DICE_ROLL} method + * represents randomly generated divorce using dice rolls. + */ public enum RandomDivorceMethod { //region Enum Declarations NONE("RandomDivorceMethod.NONE.text", "RandomDivorceMethod.NONE.toolTipText"), @@ -40,6 +49,13 @@ public enum RandomDivorceMethod { //endregion Variable Declarations //region Constructors + /** + * Constructor for the {@link RandomDivorceMethod} class. + * Initializes the name and toolTipText variables using the specified name and toolTipText resources. + * + * @param name the name resource key used to retrieve the name from the resource bundle + * @param toolTipText the tooltip text resource key used to retrieve the tool tip text from the resource bundle + */ RandomDivorceMethod(final String name, final String toolTipText) { final ResourceBundle resources = ResourceBundle.getBundle("mekhq.resources.Personnel", MekHQ.getMHQOptions().getLocale()); @@ -49,24 +65,40 @@ public enum RandomDivorceMethod { //endregion Constructors //region Getters - @SuppressWarnings(value = "unused") + /** + * @return the tooltip text for the current object + */ public String getToolTipText() { return toolTipText; } //endregion Getters //region Boolean Comparisons - @SuppressWarnings(value = "unused") + /** + * Checks if the current {@link RandomDivorceMethod} is {@code NONE}. + * + * @return {@code true} if the current {@link RandomDivorceMethod} is {@code NONE}, + * {@code false} otherwise. + */ public boolean isNone() { return this == NONE; } - @SuppressWarnings(value = "unused") + /** + * Checks if the current {@link RandomDivorceMethod} is {@code DICE_ROLL}. + * + * @return {@code true} if the current {@link RandomDivorceMethod} is {@code DICE_ROLL}, + * {@code false} otherwise. + */ public boolean isDiceRoll() { return this == DICE_ROLL; } //endregion Boolean Comparisons + /** + * @param options the {@link CampaignOptions} object used to initialize the {@link AbstractDivorce} instance + * @return an instance of {@link AbstractDivorce} based on the {@link RandomDivorceMethod} + */ public AbstractDivorce getMethod(final CampaignOptions options) { if (this == DICE_ROLL) { return new RandomDivorce(options); diff --git a/MekHQ/src/mekhq/campaign/personnel/enums/RandomMarriageMethod.java b/MekHQ/src/mekhq/campaign/personnel/enums/RandomMarriageMethod.java index 9c8bddbac2..aa9bd9d8dc 100644 --- a/MekHQ/src/mekhq/campaign/personnel/enums/RandomMarriageMethod.java +++ b/MekHQ/src/mekhq/campaign/personnel/enums/RandomMarriageMethod.java @@ -28,6 +28,13 @@ import static megamek.client.ui.WrapLayout.wordWrap; +/** + * The {@link RandomMarriageMethod} enum represents different methods of getting random marriages. + *

+ * The available methods are: + * - {@code NONE}: No random marriage method. + * - {@code DICE_ROLL}: Random marriage method using dice roll. + */ public enum RandomMarriageMethod { //region Enum Declarations NONE("RandomMarriageMethod.NONE.text", "RandomMarriageMethod.NONE.toolTipText"), @@ -39,6 +46,13 @@ public enum RandomMarriageMethod { private final String toolTipText; //endregion Variable Declarations + /** + * Constructor for the {@link RandomMarriageMethod} class. + * Initializes the name and toolTipText variables using the specified name and toolTipText resources. + * + * @param name the name resource key used to retrieve the name from the resource bundle + * @param toolTipText the tooltip text resource key used to retrieve the tool tip text from the resource bundle + */ //region Constructors RandomMarriageMethod(final String name, final String toolTipText) { final ResourceBundle resources = ResourceBundle.getBundle("mekhq.resources.Personnel", @@ -48,25 +62,41 @@ public enum RandomMarriageMethod { } //endregion Constructors + /** + * @return The tooltip text associated with the current instance of the class. + */ //region Getters - @SuppressWarnings(value = "unused") public String getToolTipText() { return toolTipText; } //endregion Getters //region Boolean Comparison Methods - @SuppressWarnings(value = "unused") + /** + * Checks if the current {@link RandomMarriageMethod} is {@code NONE}. + * + * @return {@code true} if the current {@link RandomMarriageMethod} is {@code NONE}, + * {@code false} otherwise. + */ public boolean isNone() { return this == NONE; } - @SuppressWarnings(value = "unused") + /** + * Checks if the current {@link RandomMarriageMethod} is {@code DICE_ROLL}. + * + * @return {@code true} if the current {@link RandomMarriageMethod} is {@code DICE_ROLL}, + * {@code false} otherwise. + */ public boolean isDiceRoll() { return this == DICE_ROLL; } //endregion Boolean Comparison Methods + /** + * @param options the {@link CampaignOptions} object used to initialize the {@link AbstractMarriage} instance + * @return an instance of {@link AbstractMarriage} based on the {@link RandomMarriageMethod} + */ public AbstractMarriage getMethod(final CampaignOptions options) { if (this == DICE_ROLL) { return new RandomMarriage(options); diff --git a/MekHQ/src/mekhq/campaign/personnel/enums/RandomProcreationMethod.java b/MekHQ/src/mekhq/campaign/personnel/enums/RandomProcreationMethod.java index 471bfabc8a..2cef0e7441 100644 --- a/MekHQ/src/mekhq/campaign/personnel/enums/RandomProcreationMethod.java +++ b/MekHQ/src/mekhq/campaign/personnel/enums/RandomProcreationMethod.java @@ -28,6 +28,13 @@ import static megamek.client.ui.WrapLayout.wordWrap; +/** + * The {@link RandomProcreationMethod} enum represents different methods of getting random procreation. + *

+ * The available methods are: + * - {@code NONE}: No random procreation method. + * - {@code DICE_ROLL}: Random procreation method using dice roll. + */ public enum RandomProcreationMethod { //region Enum Declarations NONE("RandomProcreationMethod.NONE.text", "RandomProcreationMethod.NONE.toolTipText"), @@ -40,6 +47,13 @@ public enum RandomProcreationMethod { //endregion Variable Declarations //region Constructors + /** + * Constructor for the {@link RandomProcreationMethod} class. + * Initializes the name and toolTipText variables using the specified name and toolTipText resources. + * + * @param name the name resource key used to retrieve the name from the resource bundle + * @param toolTipText the tooltip text resource key used to retrieve the tool tip text from the resource bundle + */ RandomProcreationMethod(final String name, final String toolTipText) { final ResourceBundle resources = ResourceBundle.getBundle("mekhq.resources.Personnel", MekHQ.getMHQOptions().getLocale()); @@ -49,24 +63,40 @@ public enum RandomProcreationMethod { //endregion Constructors //region Getters - @SuppressWarnings(value = "unused") + /** + * @return The tooltip text associated with the current instance of the class. + */ public String getToolTipText() { return toolTipText; } //endregion Getters //region Boolean Comparison Methods - @SuppressWarnings(value = "unused") + /** + * Checks if the current {@link RandomProcreationMethod} is {@code NONE}. + * + * @return {@code true} if the current {@link RandomProcreationMethod} is {@code NONE}, + * {@code false} otherwise. + */ public boolean isNone() { return this == NONE; } - @SuppressWarnings(value = "unused") + /** + * Checks if the current {@link RandomProcreationMethod} is {@code DICE_ROLL}. + * + * @return {@code true} if the current {@link RandomProcreationMethod} is {@code DICE_ROLL}, + * {@code false} otherwise. + */ public boolean isDiceRoll() { return this == DICE_ROLL; } //endregion Boolean Comparison Methods + /** + * @param options the {@link CampaignOptions} object used to initialize the {@link AbstractProcreation} instance + * @return an instance of {@link AbstractProcreation} based on the {@link RandomProcreationMethod} + */ public AbstractProcreation getMethod(final CampaignOptions options) { if (this == DICE_ROLL) { return new RandomProcreation(options); diff --git a/MekHQ/src/mekhq/campaign/personnel/marriage/AbstractMarriage.java b/MekHQ/src/mekhq/campaign/personnel/marriage/AbstractMarriage.java index 15e1f24fd0..536434303c 100644 --- a/MekHQ/src/mekhq/campaign/personnel/marriage/AbstractMarriage.java +++ b/MekHQ/src/mekhq/campaign/personnel/marriage/AbstractMarriage.java @@ -65,47 +65,38 @@ protected AbstractMarriage(final RandomMarriageMethod method, final CampaignOpti //endregion Constructors //region Getters/Setters - @SuppressWarnings(value = "unused") public RandomMarriageMethod getMethod() { return method; } - @SuppressWarnings(value = "unused") public boolean isUseClanPersonnelMarriages() { return useClanPersonnelMarriages; } - @SuppressWarnings(value = "unused") public void setUseClanPersonnelMarriages(final boolean useClanPersonnelMarriages) { this.useClanPersonnelMarriages = useClanPersonnelMarriages; } - @SuppressWarnings(value = "unused") public boolean isUsePrisonerMarriages() { return usePrisonerMarriages; } - @SuppressWarnings(value = "unused") public void setUsePrisonerMarriages(final boolean usePrisonerMarriages) { this.usePrisonerMarriages = usePrisonerMarriages; } - @SuppressWarnings(value = "unused") public boolean isUseRandomClanPersonnelMarriages() { return useRandomClanPersonnelMarriages; } - @SuppressWarnings(value = "unused") public void setUseRandomClanPersonnelMarriages(final boolean useRandomClanPersonnelMarriages) { this.useRandomClanPersonnelMarriages = useRandomClanPersonnelMarriages; } - @SuppressWarnings(value = "unused") public boolean isUseRandomPrisonerMarriages() { return useRandomPrisonerMarriages; } - @SuppressWarnings(value = "unused") public void setUseRandomPrisonerMarriages(final boolean useRandomPrisonerMarriages) { this.useRandomPrisonerMarriages = useRandomPrisonerMarriages; } @@ -113,7 +104,6 @@ public void setUseRandomPrisonerMarriages(final boolean useRandomPrisonerMarriag /** * This is used to determine if a person can marry - * @param campaign the campaign the person is a part of * @param today the current date * @param person the person to determine for * @param randomMarriage if this is for random marriage or manual marriage diff --git a/MekHQ/src/mekhq/campaign/personnel/marriage/RandomMarriage.java b/MekHQ/src/mekhq/campaign/personnel/marriage/RandomMarriage.java index 9b8a3242b9..dbb82764c0 100644 --- a/MekHQ/src/mekhq/campaign/personnel/marriage/RandomMarriage.java +++ b/MekHQ/src/mekhq/campaign/personnel/marriage/RandomMarriage.java @@ -22,12 +22,23 @@ import mekhq.campaign.CampaignOptions; import mekhq.campaign.personnel.enums.RandomMarriageMethod; +/** + * {@link RandomMarriage} class represents a type of marriage where the result is determined by + * rolling a die. + * It extends the {@link AbstractMarriage} class. + */ public class RandomMarriage extends AbstractMarriage { //region Variable Declarations private int marriageDiceSize; //endregion Variable Declarations //region Constructors + /** + * Constructs a {@link RandomMarriage} object. This object is used to manage randomly determined + * marriages. + * + * @param options the {@link CampaignOptions} object that contains current game campaign settings. + */ public RandomMarriage(final CampaignOptions options) { super(RandomMarriageMethod.DICE_ROLL, options); @@ -36,12 +47,11 @@ public RandomMarriage(final CampaignOptions options) { //endregion Constructors //region Getters/Setters - @SuppressWarnings(value = "unused") - public int getMarriageDiceSize() { - return marriageDiceSize; - } - - @SuppressWarnings(value = "unused") + /** + * Sets the size of the marriage dice used in a random marriage. + * + * @param marriageDiceSize the size of the marriage dice to set + */ public void setMarriageDiceSize(final int marriageDiceSize) { this.marriageDiceSize = marriageDiceSize; } diff --git a/MekHQ/src/mekhq/campaign/personnel/procreation/RandomProcreation.java b/MekHQ/src/mekhq/campaign/personnel/procreation/RandomProcreation.java index 1e78c3142f..8a30e6ecc2 100644 --- a/MekHQ/src/mekhq/campaign/personnel/procreation/RandomProcreation.java +++ b/MekHQ/src/mekhq/campaign/personnel/procreation/RandomProcreation.java @@ -23,6 +23,9 @@ import mekhq.campaign.personnel.Person; import mekhq.campaign.personnel.enums.RandomProcreationMethod; +/** + * Represents a random procreation method that is based on dice rolls. + */ public class RandomProcreation extends AbstractProcreation { //region Variable Declarations private int relationshipDieSize; @@ -30,6 +33,12 @@ public class RandomProcreation extends AbstractProcreation { //endregion Variable Declarations //region Constructors + /** + * Constructor to create a {@link RandomProcreation} object. This object is used to manage + * randomly determined procreation events within the game's campaign. + * + * @param options the campaign settings. + */ public RandomProcreation(final CampaignOptions options) { super(RandomProcreationMethod.DICE_ROLL, options); setRelationshipDieSize(options.getRandomProcreationRelationshipDiceSize()); @@ -38,22 +47,23 @@ public RandomProcreation(final CampaignOptions options) { //endregion Constructors //region Getters/Setters - @SuppressWarnings(value = "unused") - public double getRelationshipDieSize() { - return relationshipDieSize; - } - - @SuppressWarnings(value = "unused") + /** + * Sets the size of the relationship die. + * The relationship die size determines the probability of procreation for a person who has a spouse. + * + * @param relationshipDieSize the size of the relationship die + */ public void setRelationshipDieSize(final int relationshipDieSize) { this.relationshipDieSize = relationshipDieSize; } - @SuppressWarnings(value = "unused") - public double getRelationshiplessDieSize() { - return relationshiplessDieSize; - } - - @SuppressWarnings(value = "unused") + /** + * Sets the size of the relationshipless die. + * The relationship die size determines the probability of procreation for a person who does not + * have a spouse. + * + * @param relationshiplessDieSize the size of the relationship die + */ public void setRelationshiplessDieSize(final int relationshiplessDieSize) { this.relationshiplessDieSize = relationshiplessDieSize; } diff --git a/MekHQ/unittests/mekhq/campaign/personnel/divorce/AbstractDivorceTest.java b/MekHQ/unittests/mekhq/campaign/personnel/divorce/AbstractDivorceTest.java index b2e8a695b3..773a4198c6 100644 --- a/MekHQ/unittests/mekhq/campaign/personnel/divorce/AbstractDivorceTest.java +++ b/MekHQ/unittests/mekhq/campaign/personnel/divorce/AbstractDivorceTest.java @@ -54,29 +54,6 @@ public void beforeEach() { lenient().when(mockCampaign.getCampaignOptions()).thenReturn(mockCampaignOptions); } - //region Getters/Setters - @Disabled // FIXME : Windchild : Test Missing - @Test - public void testGettersAndSetters() { -/* - when(mockCampaignOptions.isUseClanPersonnelDivorce()).thenReturn(false); - when(mockCampaignOptions.isUsePrisonerDivorce()).thenReturn(false); - when(mockCampaignOptions.isUseRandomSameSexDivorce()).thenReturn(false); - when(mockCampaignOptions.isUseRandomClanPersonnelDivorce()).thenReturn(false); - when(mockCampaignOptions.isUseRandomPrisonerDivorce()).thenReturn(false); - - final AbstractDivorce disabledDivorce = new DisabledRandomDivorce(mockCampaignOptions); - - assertEquals(RandomDivorceMethod.NONE, disabledDivorce.getMethod()); - assertFalse(disabledDivorce.isUseClanPersonnelDivorce()); - assertFalse(disabledDivorce.isUsePrisonerDivorce()); - assertFalse(disabledDivorce.isUseRandomSameSexDivorce()); - assertFalse(disabledDivorce.isUseRandomClanPersonnelDivorce()); - assertFalse(disabledDivorce.isUseRandomPrisonerDivorce()); -*/ - } - //endregion Getters/Setters - @Disabled // FIXME : Windchild : Test Missing @Test public void testCanDivorce() {