Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started