R
rleroux
Hello,
I have an inherited class where I'm acceptting input and setting the
input to my private variables in my superclass (in my acceptPay
method). If I display the variable by using the get method (see rem'd
line in the acceptPay method) there's no issue.
However, when I try to display the variable in my displayinfo method,
I get 0.0 instead of the value that should be in the variable.
What am I overlooking in the example below?
Tnx.
class CalPayroll extends Pay
{
//Display output
public void displayinfo()
{
System.out.println(getHours());
System.out.println();
}
//Accept input
public void acceptPay()throws IOException
{
//Set variables to use
float HoursWorked;
int StraightHours;
float HourlyRate;
char ex;
System.out.print("Enter number of hours worked (00.0):");
//Create a new object to access the acceptinputFloat in the Accept
Class
Accept passHoursWorked = new Accept();
HoursWorked = passHoursWorked.acceptInputFloat();
setHours(HoursWorked);
//System.out.println(getHours()); //THIS WORKS TO GET THE
HOURS THAT WAS SET ABOVE
CalPayroll display = new CalPayroll();
display.displayinfo();
}
}
I have an inherited class where I'm acceptting input and setting the
input to my private variables in my superclass (in my acceptPay
method). If I display the variable by using the get method (see rem'd
line in the acceptPay method) there's no issue.
However, when I try to display the variable in my displayinfo method,
I get 0.0 instead of the value that should be in the variable.
What am I overlooking in the example below?
Tnx.
class CalPayroll extends Pay
{
//Display output
public void displayinfo()
{
System.out.println(getHours());
System.out.println();
}
//Accept input
public void acceptPay()throws IOException
{
//Set variables to use
float HoursWorked;
int StraightHours;
float HourlyRate;
char ex;
System.out.print("Enter number of hours worked (00.0):");
//Create a new object to access the acceptinputFloat in the Accept
Class
Accept passHoursWorked = new Accept();
HoursWorked = passHoursWorked.acceptInputFloat();
setHours(HoursWorked);
//System.out.println(getHours()); //THIS WORKS TO GET THE
HOURS THAT WAS SET ABOVE
CalPayroll display = new CalPayroll();
display.displayinfo();
}
}