Create a class called, UserAccount, which represents an account on a social media site. We will use this class for later assignments in the course.Your class should have the following fields and methods: Fields private String username private String password private boolean active// indicates whether the account is currently active Methods A constructor accepting two strings; one to initiate the user name and the other to initiate the password.Make the account active by default within the constructor.// returns the user name supplied on the constructor public String getUsername()// return true if the argument is the same as this accounts password,// false otherwisepublic boolean isPasswordCorrect(String password) // sets the active flag for the accountpublic void setActive(boolean active) // returns true if the account is active; false if notpublic boolean isActive() // displays the username for the account.@Override public String toString()// uses the username as the unique identifier of an account @Override public int hashCode()// two accounts are equal if their users names are identifical @Override public boolean equals(Object o) Create a class called, UserAccountTest, which contains JUnit test methods (annotated with @Test), to test the following: Construct UserAccount with a user name and password and assert that the getUserName method is returning the supplied user name Construct UserAccount with a user name and password. Call the isPasswordCorrect method, passing a correct password and assert the return value is true Construct UserAccount with a user name and password. Call the isPasswordCorrect method, passing an incorrect password and assert the return value is false Construct UserAccount with a user name and password. Call the isPasswordCorrect method, passing a null password and assert the return value is false Construct UserAccount with a user name and password. Call the isActive method and assert the return value is true Construct UserAccount with a user name and password. Call the setActive method, suppling false. Call the isActive method and assert the return value is false Construct UserAccount with a user name and password. Call the toString method and assert that the value returned equals the value returned from the getUsername method Construct two UserAccount instances, supplying the same username for both instances, and call the equals method. Assert the returned value is true Construct two UserAccount instances, supplying the different usernames for both instances, and call the equals method. Assert the returned value is false Construct UserAccount with a user name and password. Call the equals method, suppling a different object than UserAccount. Assert the returned value is false Construct UserAccount with a user name and password. Call the hashCode method and assert that the value returned is not equal to zero
How You Are Graded1. Your program has the requested fields and methods2. The constructor initializes the fields specified in the requirements3. All JUnit tests specified in this requirement are present and pass4. You have achieved a Coverage score of 90% or greater on all code in the src folder. The JUnit code does not count towards the Coverage score
Reviews
There are no reviews yet.