我該如何解決這個問題,我有...這是我的代碼,我工作,我似乎無法得到輸出。我不知道爲什麼會發生這種情況,我的意思是,最近它運行良好,我得到了輸出,但現在每次都得到這個錯誤。錯誤:找不到符號java
public static TimeCard processTimeCard(String data)
{
String[] split = data.split(",");
String employee = split[0];
String project = split[1];
double rate = Double.parseDouble(split[2]);
String[] days = { "Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday",
"Friday", "Saturday"};
Scanner keyboard = new Scanner(System.in);
// Get number of hours for each day of the week
for (int index = 0; index < days.length; index++)
{
System.out.println("How many hours on " + days[index] + ".");
double hours = Double.parseDouble(keyboard.nextLine());
}
// Create a TimeCard object and return a reference to it.
return new TimeCard(employee, project, rate);
}
class TimeCard
{
// Instance Variables
private String employeeName;
private String project;
private double rate;
private double hours;
//Class Variables
private static int numCards = 0;
private static final double OT_MULTIPLIER = 1.5;
private static final int OT_LIMIT = 40;
/**
* Constructor 1
*/
public TimeCard(String employeeName, String project, double rate)
{
this.employee = employeeName;
this.project = project;
this.rate = rate;
this.hours = hours;
}
public String getEmployee()
{
return this.employee;
}
public String getProject()
{
return this.project;
}
public double getRate()
{
return this.rate;
}
}
錯誤我得到的是
error: cannot find symbol
this.employee = employeeName;
&&
error: cannot find symbol
return this.employee;
我該如何解決這個問題?
你正在使用錯誤的變量。 –