need attached assignment done in java. In zipped file.

1 answer below »
need attached assignment done in java. In zipped file.
Answered Same DayOct 08, 2021

Answer To: need attached assignment done in java. In zipped file.

Sonu answered on Oct 12 2021
140 Votes
Java Solution/Auto.java
Java Solution/Auto.java
import javax.validation.constraints.Pattern;
public class Auto extends Policy {
    private static final double EXPOSURE_RATE = 0.0051;
    private String autoModel;
    private int autoYear;
    @Pattern(regexp= "^[A-Z0-9][^IOQ]og${17}")
    private String autoVin;
 
   private int[] autoLimits = new int[3];
    private int autoDeductible;
    public Auto() {
        super();
    }
    public Auto(String own, String insd, String nbr, double prem, String model, 
            int year, 
            String id, 
            int[] lims, 
            int ded) throws PolicyException{

        super(own, insd, nbr, prem);
        setAutoModel(model);
        setAutoYear(year);
        setAutoVin(id);
        setAutoLimits(lims);
        setAutoDeductible(ded);

        throw new PolicyException("must include all value offered to the constructor");
    }

    public String getAutoModel() {
        return autoModel;
    }
    public void setAutoModel(String autoModel) {
        this.autoModel = autoModel;
    }
    public int getAutoYear() {
        return autoYear;
    }
    public void setAutoYear(int autoYear) {
        if(autoYear>2009 && autoYear<=2021)
            this.autoYear = autoYear;
    }
    public String getAutoVin() {
        return autoVin;
    }
    public void setAutoVin(String autoVin) {
        this.autoVin = autoVin;
    }
    public int[] getAutoLimits() {
        return autoLimits;
    }
    public void setAutoLimits(int[] autoLimits) {
        this.autoLimits = autoLimits;
    }
    public int getAutoDeductible() {
        return autoDeductible;
    }
    public void setAutoDeductible(int autoDeductible) {
        this.autoDeductible = autoDeductible;
    }
    public static double getExposureRate() {
        return EXPOSURE_RATE;
    }
    public String produceLimitsTxt() {
        int[] limits = getAutoLimits();
        return String.format("Collision: $%s.00,Comprehensive: $%s.00, UIM: $%s.00,", limits[0] * 1000,
                limits[1] * 1000, limits[2] * 1000);
    }
    public double calcExposure() {
        int limits[] = getAutoLimits();
        double sumOfLimits = 0.0;
        for (int lm : limits) {
            sumOfLimits = sumOfLimits + (lm * 1000);
        } 
        return sumOfLimits;
    }
    public double calcCurrentValue() {
        return getPolPremium() - (calcExposure() * EXPOSURE_RATE);
    }
    public String toString() {
        String superMsg = super.toString();

        String value;
        value = String.format(getPolOwner() + " owns Policy " + getPolNumber() + " insuring " + getPolInsured()
                + ", with a premium of " + getPolPremium() + ". \nThis " + (getClass().getSimpleName())
                + " policy insures a " + getAutoYear() + " " + getAutoModel() + ", VIN " + getAutoVin()
                + ", with limits " + produceLimitsTxt() + " and a $" + getAutoDeductible() + ".00.\n");
        StringBuilder builder = new StringBuilder();
        builder.append(superMsg).append(value);

        return builder.toString();
    }
}
Java Solution/Customer.java
Java...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here