Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

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 otherwise public boolean isPasswordCorrect(String password) // sets the active flag for the account public void setActive(boolean active) // returns true if the account is active; false if not public 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 Graded 1. Your program has the requested fields and methods 2. The constructor initializes the fields specified in the requirements 3. All JUnit tests specified in this requirement are present and pass 4. 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database Design A Practical Approach

Authors: Marilyn Campbell

1st Edition

1587193175, 978-1587193170

More Books

Students also viewed these Databases questions

Question

What will you do or say to Anthony about this issue?

Answered: 1 week ago