Here is the User class with two fields: firstName and lastName.
Implement two null-safety setters and one calculated getter in the following ways:
- both setters should accept and set a value if it is not
nullor an empty string""; - the getter should return the full name of the user by concatenating
firstNameandlastNameusing a single space between them. If one of the parts was not set, the getter should return only the other part without additional spaces. If both parts are empty, the getter should return the word"Unknown".
There are two examples below:
User tim = new User();
tim.setFirstName("Tim");
tim.setLastName("Towler");
System.out.println(tim.getFullName()); // Tim Towler
User katie = new User();
katie.setFirstName("Katie");
katie.setLastName(null);
System.out.println(katie.getFullName()); // Katie (without additional spaces)