Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

problem with super in java program

By: fathershuma on Feb 19th, 2013  |  syntax: Java  |  size: 2.61 KB  |  views: 29  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. public class StaffMember {
  2.  
  3. public String name;
  4. public String address;
  5. public String phoneNum;
  6. public String socSecNum;
  7. public String payRate;
  8. String output= " ";
  9.  
  10.    public StaffMember(String name, String address, String phoneNum, String socsecNum, String payRate){
  11.        this.name= name;
  12.        this.address= address;
  13.        this.phoneNum= phoneNum;
  14.        this.socSecNum= socsecNum;
  15.        this.payRate= payRate;
  16.    }
  17.    public String getName(){
  18.        return name;
  19.    }
  20.    
  21.    public String getAddress(){
  22.        return address;
  23.     }
  24.    
  25.    public String getPhoneNum(){
  26.        return phoneNum;
  27.    }
  28.  
  29.    public void pay(){
  30.        System.out.println(getName()+" was paid $100.");
  31.    }
  32.  
  33.    public String toString(){
  34.        output += getName()+" "+getAddress()+" "+getPhoneNum();
  35.    return output;
  36.    }
  37. }
  38.  
  39.  
  40.  
  41. public class Employee extends StaffMember{
  42.     double payRate;
  43.    public Employee(){
  44.        super(name);
  45.        super(address);
  46.        super(phoneNum);
  47.        
  48.  
  49.     }
  50.     public double getPayRate(double payRate){
  51.         return payRate;
  52.     }
  53.     public String toString(){
  54.         super.toString()+" is paid at a rate of "+ getPayRate();
  55.     }
  56. }
  57.  
  58.  
  59. public class Staff {
  60.  
  61.    StaffMember[] staffList= new StaffMember[10];
  62.  
  63.    public Staff(){
  64.        // paid staff
  65.        staffList[0]= new StaffMember("Curly Howard", "222 Stooge Street", "8675309", "947-88-2222", "100");
  66.        staffList[1]= new StaffMember("Moe Howard", "222 Stooge Street", "8675309", "999-98-1418", "100");
  67.        staffList[2]= new StaffMember("Larry Fine", "123 Fine Street", "2435555", "955- 85-9090", "100");
  68.        staffList[3]= new StaffMember("Dan Marino", "1972 Dolphin Street", "9991972", "932-77-8684", "100");
  69.        staffList[4]= new StaffMember("Don Shula", "1974 Dolphin Street", "9891973", "953-00-4499", "100");
  70.  
  71.        // volunteers
  72.        staffList[5]= new StaffMember("Scuba Steve", "Scuba Avenue", "9782345", "413-66-9798", "0");
  73.        staffList[6]= new StaffMember("Diver Dan", "Ocean Avenue", "9752298", "318-75-9999", "0");
  74.        staffList[7]= new StaffMember("Zach", " 21 Jump Street", "9091487", "487-74-9788", "0");
  75.        staffList[8]= new StaffMember("Jon", "Scotch Avenue", "9582745", "495-66-9088", "0");
  76.        staffList[9]= new StaffMember("Jim Bob", "Shuffle Street", "9182005", "413-66-9798", "0");
  77.    }
  78.  
  79.    public String toString(){
  80.        String result= "";
  81.        for(StaffMember n: staffList){
  82.            result += n.toString();
  83.        }
  84.        return result;
  85.    }
  86.    
  87.    public void payDay(){
  88.      for(int n =0; n< 5; n++){
  89.          staffList[n].pay();
  90.      }
  91.    }
  92. }
clone this paste RAW Paste Data