Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to check your password and accordingly assign your message.</p> <pre><code>if( Password.check(null) == true) // This just passes null instead of the password string to the check method. </code></pre> <p>You need to send the actual password string to the check method, instead of null.</p> <pre><code>if( Password.check(yourPasswordString) == true) // Send your password value got from the user </code></pre> <p>To simplify it even more, you can remove the <code>==</code> check.</p> <pre><code>if( Password.check(yourPasswordString)) </code></pre> <p>And to simplify it even further, you can use the ternary operator as <a href="https://stackoverflow.com/a/20041528/2024761">David</a> mentioned and something like this</p> <pre><code>String myMessage = Password.check(yourPasswordString) ? "Your password is valid" : "You failed"; </code></pre> <p><strong>Edit:</strong></p> <p>After seeing your edit, this is what you need to do.</p> <p>Pass the boolean result to the <code>getDisplay()</code> method.</p> <pre><code>// inside init() method boolean pass= Password.check(userInput); Password mess= new Password(); passwordLabel.setText(mess.getDisplay(pass)); // passing the boolean to the getDisplay method ... // getDisplay method. public String getDisplay(boolean result) { return result ? "The Password meets the requirements" : "Your password does not match the requirements"; } </code></pre> <p>You could even make your <code>getDisplay()</code> as a <code>static</code> method and call it like this.</p> <pre><code>// inside init() method boolean pass= Password.check(userInput); // static method, hence mess object is not required. passwordLabel.setText(Password.getDisplay(pass)); // passing the boolean to the getDisplay method ... // getDisplay method. public static String getDisplay(boolean result) { // static method return result ? "The Password meets the requirements" : "Your password does not match the requirements"; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload