New answers tagged

2

The Algorithm The method logIn can be chunked into small steps: public boolean logIn(String name, String password) { if( /* user is logged in already? */) for (/* every user */) if ( /* has name and password */) if (/* no match found */) for (/* every user */) if ( /* can find user with the given name? */ ) } The logic is ...


0

toString() instead of getName() i think you can improve with your validation on names/passwords user.toString().equals(name) and user.getPassword().equals(password) i would put this not into the isLoginValid context but more back to your User class (single responsibility - since the User knows its name and can provide information if a given name matches ...


0

Putting security to the side... A few points When you find what you're looking for in a loop, you can exit / return. In your case, rather than login = true, you could just return true;. You function returns login, however login is only ever true when it is returned. The function should be void, or return something meaningful, such as the logged in user. ...


Top 50 recent answers are included