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 Passport(String firstname, String middlename, String lastname){
throw new UnsupportedOperationException("Implement this method");
}
public String toString(){
throw new UnsupportedOperationException("Implement this method");
}
public Passport(String firstname, String lastname){
throw new UnsupportedOperationException("Implement this method");
}
public Passport(){
throw new UnsupportedOperationException("Implement this method");
}
public Passport(Passport passport){
throw new UnsupportedOperationException("Implement this method");
}
public Passport addStamp(String stamp){
throw new UnsupportedOperationException("Implement this method");
}
public StringBuffer getStamps(){
throw new UnsupportedOperationException("Implement this method");
}
public char getSeparator(){
throw new UnsupportedOperationException("Implement this method");
}
public boolean setSeparator(char separator){
throw new UnsupportedOperationException("Implement this method");
}
public boolean equals(Object obj){
throw new UnsupportedOperationException("Implement this method");
}
public int compareTo(Passport passport){
throw new UnsupportedOperationException("Implement this method");
}
public static int getNumberOfPassportObjects(){
throw new UnsupportedOperationException("Implement this method");
}
public static void resetNumberOfPassportObjects(){
throw new UnsupportedOperationException("Implement this method");
}
public static Passport normalize(Passport passport, boolean uppercase){
throw new UnsupportedOperationException("Implement this method");
}
public boolean changeLastname(String lastname){
throw new UnsupportedOperationException("Implement 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 validateAndFormat(String name){
throw new UnsupportedOperationException("Implement this method");
}
}
public class Driver {
public static void main(String[] args){
Passport.resetNumberOfPassportObjects();
Passport passport1= new Passport("claudia", "I.", "smith");
System.out.println(passport1);
Passport passport2= new Passport("John", "RoberTs");
System.out.println(passport2);
Passport passport3= new Passport();
System.out.println(passport3);
System.out.println("=============");
passport1.addStamp("Spain");
passport1.addStamp("London");
System.out.println("Stamps for "+ passport1+"-->"+ passport1.getStamps());
passport1.setSeparator('#');
System.out.println(passport1);
Passport passport4= new Passport("CLAUDIA", "I.", "smith");
System.out.println(passport1+" same to "+ passport4+"?"+ passport1.equals(passport4));
System.out.println("=============");
System.out.println("Comparing");
System.out.println("Comp1: "+(passport1.compareTo(passport2)>0));
System.out.println("Comp2: "+(passport2.compareTo(passport1)0));
System.out.println("Comp3: "+(passport1.compareTo(passport4)==0));
System.out.println("=============");
System.out.println("Normalizing");
Passport normalized1= Passport.normalize(passport1, true);
System.out.println("Normalize #1: "+ normalized1);
System.out.println("Normalize #2: "+ Passport.normalize(passport1, false));
System.out.println("Normalize #3: "+ Passport.normalize(passport4, false));
System.out.println("Number 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
Comp1: true
Comp2: true
Comp3: true
===========
Normalizing
Normalize \#1: SMITH\#CLAUDIA\#I.
Normalize \#2: smith\#cl Specifications
package programs; / * * * This class represents a

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 Programming Questions!