Question: JAVA create a new class called Instructor. Create the following attributes: firstName (String) lastName (String) email (String) Create the getters & setters. Create a toString(

JAVA

create a new class called Instructor.

Create the following attributes:

firstName (String)

lastName (String)

email (String)

Create the getters & setters.

Create a toString( ) method.

Create a method called makeEmailAddress( ) that takes two parameters first & last name. In the method, create an email address by pulling the first character of the firstname plus the last name and add @icucc.edu at the end. Your method should return a String which represents the new email address. Note that you are not setting the email address in this method just creating it.

Create a default, no-arg constructor.

Create a two non-default constructors

The first one takes all three attributes and sets them accordingly

The second one takes in a first name & last name and sets those attributes accordingly. Then it passes the first & last name to the makeEmailAddress( ) method, which returns a String for you to use 1) in the setEmail( ) method or 2) by setting this.email equal to the results of the method.

THEN Writing the Test

Inside of our testMakeEmailAddress( ) method, lets create an empty instructor object. We know by using the default, no-arg constructor that no instance variables are set. Then we can create an call our test.

Instructor test = new Instructor(); assertEquals("kcat@icucc.edu", test.makeEmailAddress("kit", "cat")); assertEquals("kcat@icucc.edu", test.makeEmailAddress("KIT", "CAT"));

Notice the we are only testing this method. Were not testing the constructor. Were not testing the other instance variables. We are only testing to see that if we pass in two strings, do we get the result that we expect. This is key to unit testing. Dont test the whole class in one unit test. Break it apart so that if something else fails, you can find it.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!