Attributes private owner: Strin private insured: String private polNbr: Strin pr
ID: 3877121 • Letter: A
Question
Attributes private owner: Strin private insured: String private polNbr: Strin private polType: int Notes Policy owner's full, legal name Full, legal name of named insured on policy Unique identifier for specific poli Integer code indicated type of policy: 1: Auto 2: Homeowners rivate polPrem: double Annual premium amount for Operations public Policy( String own, Description Constructor accepts five (5) parameter values, calls set methods and establishes instance variable values as appropriate String insd, String nbr, int type, double prem): Policy public Policy( ): Policy public setowner( String own): void Null constructor; establishes no instance variable values Accepts a String reference; assigns reference to owner instance variable Accepts a String reference: assigns reference to insured instance variable Accepts a String reference; assigns reference to polNbr instance variable Accepts an integer value; assigns value to polT Accepts a double value; assigns value to polPrem instance variable ublic setInsured String insd): void public setPolNbr( String nbr): void public setPolType( int type): void instance variable ublic setPrem( double void public getOwner(): Strin public getInsured : Strin ublic getPolNbrO: Strin public getPolType( ): int public getPrem(): double Returns a reference to the Strin Returns a reference to the Strin Returns a reference to the String object holding the Returns the int value associated with Returns the double value representing the policy t holding policy owner name t holding policy insured's name number/identifier amount public txtPolTypel ): String Returns a String reference to the translaged policy type: "AUTO" or "HOMEOWNERS" Returns a String reference to a formatted description of the Policy object: owner owns Policy polNbr, a(n) txtPolType policy, insuring insured, with a premium of polPrem. public toString: String NOTES: When output in the toString, polPrem must displayed with correct currency formatting, including thousands separatorExplanation / Answer
here is your code : ------------------------->>>>>>>>>>>>>>>>>>>
public class Policy{
private String owner;
private String insured;
private String polNbr;
private int polType;
private double polPrem;
public Policy(){
owner = "";
insured = "";
polType = 0;
polNbr = "";
polPrem = 0.0;
}
public Policy(String own,String insd,String nbr,int type,double prem){
setOwner(own);
setInsured(insd);
setPolNbr(nbr);
setPolType(type);
setPolPrem(prem);
}
//setter methods
public final void setInsured(String insd){
insured = insd;
}
public final void setOwner(String own){
owner = own;
}
public final void setPolPrem(double prem){
polPrem = prem;
}
public final void setPolType(int type){
polType = type;
}
public final void setPolNbr(String nbr){
polNbr = nbr;
}
//getter methods
public final int getPolType(){
return polType;
}
public final double getPolPrem(){
return polPrem;
}
public final String getPolNbr(){
return polNbr;
}
public final String getOwner(){
return owner;
}
public final String getInsured(){
return insured;
}
//txtPolType
public String txtPolType(){
if(polType == 1){
return "AUTO";
}
if(polType == 2){
return "HOMEOWNERS";
}
return null;
}
public String toString(){
if(getPolType() == 1){
return getOwner()+" owns Policy "+getPolNbr()+", a"+txtPolType()+" policy, insuring "+getInsured()+", with a premium of "+getPolPrem();
}
if(getPolType() == 2){
return getOwner()+" owns Policy "+getPolNbr()+", an"+txtPolType()+" policy, insuring "+getInsured()+", with a premium of "+getPolPrem();
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.