Page 576 - Introduction to Programming with Java: A Problem Solving Approach
P. 576

                542 Chapter 13 Inheritance and Polymorphism
 /***************************************************************
*
Employee3.java
Dean & Dean
This abstract class describes employees and it includes
social-security tax calculation.
***************************************************************/
*
*
*
*
public abstract class Employee3
{
}
// end class Employee3
public abstract double getPay();
private String name;
private final static double FICA_TAX_RATE = 0.08; // fraction
private final static double FICA_MAX = 90000;
// dollars
// total year-to-date income
//************************************************************
public Employee3(String name)
private double ytdIncome;
{
}
{
this.name = name;
//****************A**p**a**g**o****P*D**F****E**n**h**a**n**c**e*r************ public void printPay(int date)
System.out.printf("%2d %10s: %8.2f\n",
date, name, getPay());
} // end printPay
  //**************************************
 protected double getFICA(double pay)
{
}
double increment, tax;
ytdIncome += pay;
increment = FICA_MAX - ytdIncome;
tax = FICA_TAX_RATE *
(pay < increment ? pay : (increment > 0 ? increment : 0));
return tax;
// end getFICA
**********************
This limits accessibility to classes in subtree or in same package.
 Figure 13.20
Employee3 class which includes protected
getFICA method


















































   574   575   576   577   578