Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write an abstract class called Staff Member that has two protected String fields

ID: 3807990 • Letter: W

Question

Write an abstract class called Staff Member that has two protected String fields called name and phone, and it also has a two argument constructor that sets those two fields. Don't worry about creating getters and setters for those field values, but you must create a to String method that returns a String with the two values. And include an abstract method in this class called pay () that returns a double. After writing that class, write another class called Volunteer, which inherits from the Staff Member class and has no additional fields. The Volunteer class has a two argument constructor that sets the two field values of its parent class, and it has a pay() method that just returns the value of zero, and it has a to String() method that returns the String "Volunteer: " followed by what the toString() method of the parent class returns.

Explanation / Answer


public abstract class StaffMember {
   protected String name;
   protected String phone;
  
   StaffMember(String name, String phone)
   {
       this.name = name;
       this.phone = phone;
   }

   @Override
   public String toString() {
       return name + " " + phone ;
   }
  
   public abstract double pay();
}


public class Volunteer extends StaffMember{

   Volunteer(String name, String phone) {
       super(name, phone);
   }

   @Override
   public double pay() {
       return 0;
   }

   @Override
   public String toString() {
       return "Volunteer: " + super.toString();
   }
  
  
  

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote