Question: You will need to create a class called UserAccount to represent an account on a social networking site. We will use this class for later
You will need to create a class called UserAccount to represent an account on a social networking 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 or not the account is currently active
Methods:
UserAccountString username, String password constructor to initialize the username and password, make the account active
public boolean checkPasswordString password return true if the argument is the same as this account's password, false otherwise
public void deactivateAccount make this account inactive
As explained in this lesson's videos, create a toString method that displays the username of this account. Also, create hashCode and equals methods that consider two UserAccount objects to be equivalent if they have the same username. Write a driver program that creates at least two UserAccount objects and exercises all of the methods in the class. See the xBankDriver class in this week's jar file for an example.
You will be graded according to the following rubric each item is worth one point:
The UserAccount class has the requested fields and methods
The constructor initializes the fields as specified in the requirements
The checkPassword method works correctly for positive and negative test cases
The deactivateAccount method sets the active field to false
The toString method is correct and gets automatically called by System.out.println in the driver program
The equals method is correct
The driver program creates at least two UserAccount objects
The driver program exercises all of the methods in the UserAccount class
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
