// ###########################################
// ACHTUNG: SIE DÜRFEN DIESE KLASSE NICHT
//          VERÄNDERN, SONST WIRD IHR GEHIRN
//          AUSGESAUGT.
//
//          GRÜSSE, DIE ALIEN OVERLORDS
// ###########################################
package pr2.vererbung.password.rules;

/**
 * Base class for all rules that can be used to check
 * passwords against.
 */
public abstract class Rule {

    /**
     * Points for a bad password.
     */
    public static final int BAD = -20;

    /**
     * Points for a fair password.
     */
    public static final int FAIR = 10;

    /**
     * Points for a good password.
     */
    public static final int GOOD = 20;

    /**
     * Checks a password and returns an evaluation in the form of
     * points. Higher points indicate better passwords.
     *
     * @param password the password to check
     * @return the result of the check
     */
    public abstract int checkPassword(String password);

    /**
     * Return the quality value as a string.
     *
     * @param quality the quality value.     *
     * @return a string representation.
     */
    public static String qualityToString(int quality) {
        return switch (quality) {
            case BAD -> "bad";
            case FAIR -> "fair";
            case GOOD -> "good";
            default -> "<unknown>";
        };
    }

    /**
     * Return the name of the rule.
     * @return the name of the rule.
     */
    @Override
    public String toString() {
        return "<undefined>";
    }
}
