Question
JAVA First Assignment The UserAccount Class You will need to create a class called UserAccount to represent an account on a social networking site. We
JAVA
First Assignment The UserAccount Class
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 accounts password, false otherwise
public void deactivateAccount() // make this account inactive
As explained in this lessons 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 weeks 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
- The program compiles and runs
- The program is clearly written and follows standard coding conventions
- Note: If your program does not compile, you will receive a score of 0 on the entire assignment
- Note: If you program compiles but does not run, you will receive a score of 0 on the entire assignment
- Note: If your Eclipse project is not exported and uploaded to the eLearn drop box correctly, you will receive a score of 0 on the entire assignment
- Note: If you do not submit code that solves the problem for this particular assignment, you will not receive any points for the programs compiling, the programs running, or following standard coding conventions.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started