← Unit 3 · all exercises
Saved in this browser only

A password checker

Write a Password class holding a value. isLongEnough returns true when it has 8 or more characters. matches takes a guess and returns whether it is the same, comparing with equals.

class Password { Password(String value); boolean isLongEnough(); boolean matches(String guess); }

Password.java
Loading editor…
Results

Examples

  • new Password("hunter22").isLongEnough() → true
  • new Password("short").isLongEnough() → false

There are also 4 hidden tests you can't see. Solve the problem, not the examples.