/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package theaterpeople; import java.util.Scanner; import java.io.File; import java.io.FileNotFoundException; /** * * @author jcmt */ public class Actor extends TheaterPeople implements calculatePay { private String roleName; private int shirtSize; private int clothesGender; // 1 = female, 0= male, -1 = genderless; private double hoursWorked; public Actor(String roleName, int shirtSize, int clothesGender, String lastName, String firstName, dateDMY dateOfBirth) { super(lastName, firstName, dateOfBirth); this.roleName = roleName; this.shirtSize = shirtSize; this.clothesGender = clothesGender; } public Actor(String roleName, int shirtSize, int clothesGender, String lastName, String firstName, int day, int month, int year) { super(lastName, firstName, day, month, year); this.roleName = roleName; this.shirtSize = shirtSize; this.clothesGender = clothesGender; } public Actor(String inputFile) { super(); File inFile = new File(inputFile); try { Scanner input = new Scanner(inFile); } catch(FileNotFoundException f) { System.out.println("File does not exist"); } if (inFile.exists()){ System.out.printf("\nPlease enter the actor's last name: "); this.setLastName(getString(inFile)); System.out.printf("\nPlease enter the actor's first name: "); this.setFirstName(getString()); System.out.printf("\nPlease enter the actor's birthdate in the number format\n DD MM YYYY : "); this.setDateOfBirth(getInt(), getInt(), getInt()); //input.nextLine(); //super(lastname, "Julia", 23, 3, 2014); System.out.printf("\nPlease enter the actor's role in the play: "); this.roleName = getString(); System.out.printf("\nPlease enter the actor's gender in the play as an int: 1 for female, 0 for male, -1 for genderless: "); this.setClothesGender(getInt()); System.out.printf("\nPlease enter the actor's shirt size: "); this.setShirtSize(getInt()); } } public Actor() { super(); Scanner input = new Scanner(System.in); System.out.printf("\nPlease enter the actor's last name: "); this.setLastName(getString()); System.out.printf("\nPlease enter the actor's first name: "); this.setFirstName(getString()); System.out.printf("\nPlease enter the actor's birthdate in the number format\n DD MM YYYY : "); this.setDateOfBirth(getInt(), getInt(), getInt()); //input.nextLine(); //super(lastname, "Julia", 23, 3, 2014); System.out.printf("\nPlease enter the actor's role in the play: "); this.roleName = getString(); System.out.printf("\nPlease enter the actor's gender in the play as an int: 1 for female, 0 for male, -1 for genderless: "); this.setClothesGender(getInt()); System.out.printf("\nPlease enter the actor's shirt size: "); this.setShirtSize(getInt()); } public String getString(File inFile) { String temp = new String(); try { Scanner sscan = new Scanner(inFile); temp = sscan.nextLine(); } catch (Exception e) { System.out.printf("Exception reading string"); return ""; } return temp; } public String getString() { String temp = new String(); Scanner sscan = new Scanner(System.in); try { temp = sscan.nextLine(); } catch (Exception e) { System.out.printf("Exception reading string"); return ""; } return temp; } public int getInt() { int temp; Scanner sscan = new Scanner(System.in); try { temp = sscan.nextInt(); } catch (NumberFormatException e) { System.out.printf("Exception reading int"); return 0; } return temp; } public String getRoleName() { return roleName; } public void setRoleName(String roleName) { this.roleName = roleName; } public int getShirtSize() { return shirtSize; } public void setShirtSize(int shirtSize) { this.shirtSize = shirtSize; } public int getClothesGender() { return clothesGender; } public void setClothesGender(int clothesGender) { if ((clothesGender == 0) || (clothesGender == 1) || (clothesGender == -1)) { this.clothesGender = clothesGender; } else { this.clothesGender = -1; } } public double getHoursWorked() { return hoursWorked; } public void setHoursWorked(double hoursWorked) { if (hoursWorked > 0) { this.hoursWorked = hoursWorked; } } @Override public double getCalculatedPay() { double equityPayPerHour = 8.75; int equityLevel = 2; return hoursWorked * equityPayPerHour + hoursWorked * (equityPayPerHour / equityLevel); } public String toString() { return String.format("%s in the role %s wears %s size %d", super.toString(), roleName, ((clothesGender == 1) ? "women's" : "men's"), shirtSize); } }