Abstract class variable help
The variable gross is still 0 after I gave it another number. Manager is a subclass of Employee and computePay is abstract. The gross in the toString method is 0. I tried to do gross = (pay/24); in the toString method of manager and it worked, but I need to put that in computePay and have it work there.
Code :
import java.util.Scanner;
import java.io.*;
import java.util.ArrayList;
public abstract class Employee
{
protected String name;
protected double grossPay;
protected double netPay;
protected String job;
public Employee(String person, String title)
{
name = person;
job = title;
}
abstract public void computePay();
public void computeTax()
{
}
public String toString()
{
String s = "s";
return s;
}
}
Code :
public class Manager extends Employee implements Bonus
{
private String title;
private double pay;
private double gross;
public Manager(String name, String title, String dprtmt, double salary)
{
super(name, title);
gross = 0;
pay = salary;
}
public double calcBonus()
{
return gross*0.01;
}
public void computePay()
{
gross = (pay/24);
}
public String toString()
{
String s = name + " title: " + job + " Pay: "+ Double.toString(pay) + " Gross: " +Double.toString(gross);
return s;
}
}
Re: Abstract class variable help
If you want help, you'll have to provide an SSCCE that demonstrates exactly what you're doing. As of now, we have no idea how this code is being called, what the expected output is, or what the actual output is instead.