Advertisement
fathershuma

java chp 9.2

Feb 28th, 2013
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.96 KB | None | 0 0
  1.  
  2. public class FirmStaff{
  3.     Volunteer[] staffList= new Volunteer[3];
  4.     Payable[] sList= new Payable[2];
  5.     double payReturn;
  6.     double payAmount=0;
  7.    
  8.    public FirmStaff(){
  9.      
  10.        
  11.        staffList[0]= new Volunteer("Curley Howard", "222 Stooge Street", "8675309", "183457612", 8.75);
  12.        staffList[1]= new Volunteer("Moe Howard", "222 Stooge Street", "8675309", "177645555", 7.50);
  13.        staffList[2]= new Volunteer("Larry Fine", "123 Fine Street", "2435555", "155649889", 25.00);
  14.  
  15.        sList[0]= new Hourly("Dan Marino", "1972 Dolphin Street", "9991972", "15843928", 7.50, 15.50);
  16.        sList[1]= new Admin("Don Shula", "1974 Dolphin Street", "9891973", "198583834", 27.50, 29.5, 1875.75);
  17.    }
  18.  
  19.    public String toString(){
  20.        String result= "";
  21.        for(Payable n: sList){
  22.            result += n.toString();
  23.        }
  24.        return result;
  25.    }
  26.  
  27.    public double Pay(){
  28.     double payAmount=0;
  29.  
  30.       for (int count=0; count < sList.length; count++)
  31.       {
  32.          System.out.println (sList[count]);
  33.  
  34.          payAmount = sList[count].Pay();
  35.  
  36.          if (payAmount == 0.0)
  37.             System.out.println("Thanks!");
  38.          else
  39.             System.out.println ("Paid: " + payAmount);
  40.  
  41.          System.out.println ("-----------------------------------");
  42.       }
  43.     return payAmount;
  44.    }
  45. }
  46.    
  47.  
  48.  
  49.  
  50. public class Employee extends FirmStaff implements Payable{
  51.     double payRate;
  52.     String name;
  53.     String address;
  54.     String phoneNum;
  55.     String socsecNum;
  56.     String ssNum;
  57.     double payrate;
  58.  
  59.    public Employee(String name, String address, String phoneNum, String socsecNum, double hours){
  60.        super( name, address, phoneNum);
  61.        this.socsecNum= ssNum;
  62.     }
  63.  
  64.     public double Pay(){
  65.         return(getPayRate());
  66.     }
  67.  
  68.     public double getPayRate(){
  69.         return payRate;
  70.     }
  71.  
  72.     public String toString(){
  73.         return name+" is paid at a rate of "+ getPayRate();
  74.     }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement