لسلام عليكم ...
انا عندي مشكله لما انادي للفنكشن في كلاس ثاني يطلع لي غلط وماني عارفه كيف اصلح ذا الغلط
هنا يطلعلي error
EmployeeList.setEmployee();
وفي ذا كمان ...
EmployeeList.display();
وهذا الكود حقي الكلاس
package employee;
import java.util.Scanner;
/**
*
* @author Com net
*/
public class Employee {
private String FirstName;
private String LastName;
private double MonthlySalary;
private double Rate;
private double[]nhours=new double[4];
//
//
public Employee()
{
FirstName=null;
LastName=null;
MonthlySalary=0.0;
Rate=0.0;
for( int j=0;j<4;j++)
nhours[j]=0.0;
}
void Employee (String firstName,String lastName,double monthlySalary,double hoursOfWork,double hourlyRate)
{
FirstName=firstName;
LastName=lastName;
MonthlySalary=monthlySalary;
for(int j=0;j<4;j++)
nhours[j]=hoursOfWork;
Rate=hourlyRate;
}
double MonthlyHours=0.0;
public void setEmployee()
{
Scanner input =new Scanner(System.in);
System.out.println("Enter First Name");
FirstName=input.nextLine();
System.out.println("Enter Last Name");
LastName=input.nextLine();
System.out.println("Enter Rate");
Rate=input.nextDouble();
for(int j=0;j<4;j++)
{
System.out.println("Enter Hours of week"+(j+1));
nhours[j]=input.nextInt();
MonthlyHours+=nhours[j];
}
for(int j=0;j<4;j++){//calculat Monthly Salary
if (nhours[j]<=40)
{
MonthlySalary+=(Rate*nhours[j]);
}
else
{
MonthlySalary+=(Rate*nhours[j])+((Rate*1.5)*(nhours[j]-40));
}
}
}
}وذا المين ....
class Employee{
private String FirstName;//First Name
private String LastName;//Last Name
private double MonthlySalary;//Monthly Salary
// constructor that initializes the three instance variables
public Employee()
{
FirstName=null;
LastName=null;
MonthlySalary=0.0;
}
void Employee(String first ,String last ,double salary) {
FirstName=first;
LastName=last;
MonthlySalary=salary;
}
// Provide a set and get method for each instance variable.
// set and get method for variable FirstName
public void setFirstName(String first)
{
FirstName=first;
}
public String getFirstName()
{
return FirstName;
}
//----------------------
//set and get method for variable LastName
public void setLastName(String last)
{
LastName=last;
}
public String getLastName()
{
return LastName;
}
//----------------------------
//set and get method for variable MonthlySalary
public void setMonthlySalary(double salary)
{ do
if(salary>0)
MonthlySalary=salary;
else
System.out.print("The salary should be postive");
while(salary<0);
}
public double getMonthlySalary() {
return MonthlySalary;
}
}
/**
*
* @author hp
*/
public class EmployeeTest {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Employee EmployeeList[]=new Employee[5];//consantrat list of employee
for (int i=0;i<EmployeeList.length;i++)
{
EmployeeList=new Employee();
EmployeeList.setEmployee();
}
//--------------------------------------------------------------------------
System.out.print("\t\tFirstName\tLastName\tHoursOfWork\t\tHourlyRate\t\tMonthlySalary");
for (int i=0;i<EmployeeList.length;i++)//print all the employee
{
EmployeeList.display();
}
}
}بليز احد يقولي ايش تصحيحه....