View Single Post
  #5 (permalink)  
Old 05-07-2008, 06:35 PM
Azzia Azzia is offline
Member
 
Join Date: May 2008
Location: Ohio
Posts: 20
Azzia is on a distinguished road
Send a message via AIM to Azzia Send a message via MSN to Azzia
Code:
Employee employee = new Employee(theName, hoursWorked, hourlyPayRate); System.out.printf( "Employee Name: %s, Weekly pay is $%d%n", employee.name, employee.getWeeklyPay() ); } } } class Employee { String name; int hours; int hourlyPayRate; int weeklyPay; public Employee(String name, int hours, int rate) { this.name = name; this.hours = hours; hourlyPayRate = rate; computeWeeklyPay(); } private void computeWeeklyPay() { weeklyPay = hours * hourlyPayRate; } public int getWeeklyPay() { return weeklyPay; } }
This is the part I am unsure about. I have created the class but when I try and implement the constructor in my above code it will not work. The error is about variables but the variables I have used are declared in my code which again makes no sense to me.
Reply With Quote