Question: Write tests for the followingYour tests must be written using JUnit 5 . - Customer Class Constructing a Customer Getting and setting first and last
Write tests for the followingYour tests must be written using JUnit
Customer Class
Constructing a Customer
Getting and setting first and last names
Getting customer number
equals
Checking that the customer number autoincrements with each new customer object created
toString
public class Customer
private static int nextNumber ;
private int number;
private String firstName;
private String lastName;
Represents a customer with customer number autogenerated first and last name.
@param firstName
@param lastName
public CustomerString firstName, String lastName
this.number nextNumber;
this.firstName firstName;
this.lastName lastName;
Returns the first name
@return the first name
public String getFirstName
return firstName;
Returns the last name
@return the last name
public String getLastName
return lastName;
Sets the first name
@param firstName
public void setFirstNameString firstName
this.firstName firstName;
Sets the last name
@param lastName
public void setLastNameString lastName
this.lastName lastName;
Returns the customer number
@return the customer number
public int getNumber
return number;
@Override
public String toString
return "Customer number number name firstName lastName ;
Customers are equal only if their customer numbers are equal
@see java.lang.Object#equalsjavalang.Object
@Override
public boolean equalsObject obj
if this obj
return true;
if obj null
return false;
if getClass obj.getClass
return false;
Customer other Customer obj;
if number other.number
return false;
return true;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
