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
UserAccount(String username, String password) // constructor to initialize the username and password, make the account active public boolean checkPassword(String 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 rubric (each item is worth one point):
The UserAccount class has the requested fields and methods
The constructor initialize 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 the methods in the UserAccount class
The program compiles and runs
The program is clearly written and follows standard coding conventions
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference
and should not be submitted as is. We are not held liable for any misuse of the solutions.
Please see the frequently asked questions page
for further questions and inquiries.
Kindly complete the form.
Please provide a valid email address and we will get back to you within 24 hours.
Payment is through PayPal, Buy me a Coffee
or Cryptocurrency.
We are a nonprofit organization however we need funds to keep this organization operating
and to be able to complete our research and development projects.