/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package theaterpeople; import java.util.Scanner; /** * * @author jcmt */ public class Producer extends TheaterPeople implements calculatePay { private String typeOfProducer; private double howMuchInvested; private int activityLevel; private double upFrontFee; private double percentageOfGross; public Producer(String typeOfProducer, double howMuchInvested, int activityLevel, String lastName, String firstName, int day, int month, int year) { super(lastName, firstName, day, month, year); this.setTypeOfProducer(typeOfProducer); this.setHowMuchInvested(howMuchInvested); this.setActivityLevel(activityLevel); this.makeCalculatedPay(); } public String getTypeOfProducer() { return typeOfProducer; } public void setTypeOfProducer(String typeOfProducer) { if (typeOfProducer.equalsIgnoreCase("Executive")) { this.typeOfProducer = typeOfProducer; } else { this.typeOfProducer = ""; } } public double getHowMuchInvested() { return howMuchInvested; } public void setHowMuchInvested(double howMuchInvested) { if (howMuchInvested > 10000) { this.howMuchInvested = howMuchInvested; } else { this.howMuchInvested = 5000; } } public int getActivityLevel() { return activityLevel; } public void setActivityLevel(int activityLevel) { switch (activityLevel) { case 0: case 1: case 2: this.activityLevel = activityLevel; default: this.activityLevel = 0; } } public double getUpFrontFee() { return upFrontFee; } public void setUpFrontFee(double upFrontFee) { this.upFrontFee = upFrontFee; } public double getPercentageOfGross() { return percentageOfGross; } public void setPercentageOfGross(double percentageOfGross) { this.percentageOfGross = percentageOfGross; } public void setCalculatedPay(double cPay) { if (cPay >= 0) { super.setCalculatedPay(cPay); } super.setCalculatedPay(0); } public double getCalculatedPay() { return super.getCalculatedPay(); } @Override public double makeCalculatedPay() { Scanner input = new Scanner(System.in); double gross; double fee; System.out.println("How much money did it make?"); gross = input.nextDouble(); try { fee = (percentageOfGross / gross); } catch (ArithmeticException ae) { fee = 0; System.out.print(ae); } setCalculatedPay(fee); return getCalculatedPay(); } public String toString() { return String.format("%s is the %s producer and invested %f", super.toString(), this.typeOfProducer, this.howMuchInvested); } }