Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Project This project is made up of two source folders; src and test. Both source folders contain an edu.institution package. The src folder is

image text in transcribed

image text in transcribed

image text in transcribed

The Project This project is made up of two source folders; src and test. Both source folders contain an edu.institution package. The src folder is where you will place source code for the assignment. The test folder is where you will place your unit tests for the assignment. All code should be placed in the edu.institution package. Create a class called, User Account, and place it in the edu.institution package within the src folder. The User Account class 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 Methods A constructor accepting two strings; one to initiate the user name and the other to initiate the password. // a constructor accepting two Strings; one to initiate the user name and the other to // initiate the password public UserAccount (String username, string password) // returns the user name supplied on the constructor public String getUsername() // return true if the argument is the same as this account's password, // false otherwise public boolean is PasswordCorrect(String password) // 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 user names are identical @Override public boolean equals (object o) User AccountTest Package: edu.institution Create a class called, User AccountTest and place this class in the edu.institution package within the test folder. The User AccountTest class will contain your JUnit test methods. Each test method should be annotated with the @Test annotation. For example: import org.junit. Test; Test public void testSomeAction() { // place test code here Create the following tests within the User AccountTest class: Construct User Account with a user name and password and assert that the getUserName method is returning the supplied user name Construct User Account with a user name and password. Call the isPassword Correct method, passing a correct password and assert the return value is true Construct User Account with a user name and password. Call the isPasswordCorrect method, passing an incorrect password and assert the return value is false Construct User Account with a user name and password. Call the isPassword Correct method, passing a null password and assert the return value is false Construct User Account 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 User Account with a user name and password. Call the equals method, suppling a different object than UserAccount. Assert the returned value is false Construct User Account with a user name and password. Call the hashCode method and assert that the value returned is not equal to zero

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

Databases Illuminated

Authors: Catherine Ricardo

2nd Edition

1449606008, 978-1449606008

More Books

Students also viewed these Databases questions

Question

3. How would you address the problems that make up the situation?

Answered: 1 week ago

Question

2. What recommendations will you make to the city council?

Answered: 1 week ago