Follow these steps to implement the example:
- Create a class named UserValidator that will implement the process of user validation:
public class UserValidator {
- Declare a private String attribute called name that will store the name of the user validation system:
private final String name;
- Implement the constructor of the class that initializes its attributes:
public UserValidator(String name) { this.name=name; }
- Implement the validate() method. It receives two String parameters with the name and password of the user you want to validate:
public boolean validate(String name, String password) {
- Create a Random object named random:
Random random=new Random();
- Wait for a random period of time to simulate ...