Question: package programs; / * * * This class represents a person's passport. It has three instance variables * representing the first, last and middle name
package programs;
This class represents a person's passport. It has three instance variables
representing the first, last and middle name all are String variables A
character instance variable representing a separator to be used for
formatting purposes is also part of the class. In addition, the class has a
StringBuffer instance variable that represents the passport stamps the person
has received.
For this class you need to define and use a private method called
validateAndFormat that takes a character as a parameter.
The class will keep track of the number of instances created by using a
private static field called objectCount.
@author CS
public class Passport
public PassportString firstname, String middlename, String lastname
throw new UnsupportedOperationExceptionImplement this method";
public String toString
throw new UnsupportedOperationExceptionImplement this method";
public PassportString firstname, String lastname
throw new UnsupportedOperationExceptionImplement this method";
public Passport
throw new UnsupportedOperationExceptionImplement this method";
public PassportPassport passport
throw new UnsupportedOperationExceptionImplement this method";
public Passport addStampString stamp
throw new UnsupportedOperationExceptionImplement this method";
public StringBuffer getStamps
throw new UnsupportedOperationExceptionImplement this method";
public char getSeparator
throw new UnsupportedOperationExceptionImplement this method";
public boolean setSeparatorchar separator
throw new UnsupportedOperationExceptionImplement this method";
public boolean equalsObject obj
throw new UnsupportedOperationExceptionImplement this method";
public int compareToPassport passport
throw new UnsupportedOperationExceptionImplement this method";
public static int getNumberOfPassportObjects
throw new UnsupportedOperationExceptionImplement this method";
public static void resetNumberOfPassportObjects
throw new UnsupportedOperationExceptionImplement this method";
public static Passport normalizePassport passport, boolean uppercase
throw new UnsupportedOperationExceptionImplement this method";
public boolean changeLastnameString lastname
throw new UnsupportedOperationExceptionImplement this method";
This method will generate and return a formatted string in lowercase with the
first character in uppercase. The parameter is valid if it is not null and it
is not blank according to the string method isBlank If the parameter is
invalid, the method will return null and perform no further processing. If
the parameter is valid, spaces surrounding the parameter will be removed, the
string will be converted to lowercase, and the first character of the string
after spaces have been removed will be in upper case. The following methods
can be helpful during the implementation of this method:
Character.toUpperCase, and the string methods charAt and substring.
You can test this method by initially defining it public; once you have
tested it make it private.
private static String validateAndFormatString name
throw new UnsupportedOperationExceptionImplement this method";
public class Driver
public static void mainString args
Passport.resetNumberOfPassportObjects;
Passport passport new Passportclaudia "I.", "smith";
System.out.printlnpassport;
Passport passport new PassportJohn "RoberTs";
System.out.printlnpassport;
Passport passport new Passport;
System.out.printlnpassport;
System.out.println;
passportaddStampSpain;
passportaddStampLondon;
System.out.printlnStamps for passport passportgetStamps;
passportsetSeparator#;
System.out.printlnpassport;
Passport passport new PassportCLAUDIA "I.", "smith";
System.out.printlnpassport same to passport passportequalspassport;
System.out.println;
System.out.printlnComparing;
System.out.printlnComp: passportcompareTopassport;
System.out.printlnComp: passportcompareTopassport;
System.out.printlnComp: passportcompareTopassport;
System.out.println;
System.out.printlnNormalizing;
Passport normalized Passport.normalizepassport true;
System.out.printlnNormalize #: normalized;
System.out.printlnNormalize #: Passport.normalizepassport false;
System.out.printlnNormalize #: Passport.normalizepassport false;
System.out.printlnNumber of objects: Passport.getNumberOfPassportObjects;
Output
Smith, Claudia, I.
Roberts, John
Samplelastname, Samplefirstname, Samplemiddlename
Stamps for Smith, Claudia, I.SpainLondon
Smith#Claudia#I.
Smith#Claudia#I. same to Smith, Claudia, I.? true
Comparing
Comp: true
Comp: true
Comp: true
Normalizing
Normalize #: SMITH#CLAUDIA#I.
Normalize #: smith#cl Specifications
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
