Created
June 17, 2020 21:36
-
-
Save luissilvazup/44036ce61e6a2c38f3d9b810d8a90b81 to your computer and use it in GitHub Desktop.
DIP Solution Part 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class D_DependencyInversionSolution { | |
private static class AuthenticateLogin { | |
private final Authentication authentication; | |
private AuthenticateLogin(Authentication authentication) { | |
this.authentication = authentication; | |
} | |
public boolean login(User user){ | |
return authentication.login(user); | |
} | |
} | |
public static void main(String[] args) { | |
User user = new User("email@mail.com", "123"); | |
AuthenticateLogin authenticateLogin = new AuthenticateLogin(new AuthenticationLinkedin()); | |
authenticateLogin.login(user); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment