JAVA wrok
Copyright © 2017, 2018 Sinclair Community College. All Rights Reserved.
01. 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 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
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
Copyright © 2017, 2018 Sinclair Community College. All Rights Reserved.
Note: If you do not submit code that solves the problem for this particular assignment, you will not receive any points for the program’s compiling, the program’s running, or following standard coding conventions.