我从我的代码中收到以下错误消息,
找不到符号 - 变量 jobName
我们必须创建一个名为 Job 的类,其中包含两个简单的字段 Job name 和 Job length。
我不明白为什么我会收到此错误消息。代码如下。提前感谢您的帮助。
import java.util.ArrayList;
public class Job
{
// instance variables - replace the example below with your own
private String name;
private int duration;
private boolean isComplete;
/**
* Constructor for objects of class Job
*/
public Job(String name, int duration)
{
// initialise instance variables
jobName = name;
jobDuration = duration;
}
/**
* Accessor method for job name.
*
* @param y a sample parameter for a method
* @return value of job.
*/
public String getName() {
{
// put your code here
return jobName;
}
}
/**
* Accessor method for job duration.
*
* @param y a sample parameter for a method
* @return value of job duration.
*
*/
public int getDuration() {
{
return jobDuration;
}
}
/**
* Run method which prints.
*
* @param y a sample parameter for a method.
* @return
*/
public void run(String name, int duration) {
if (isComplete)
{
System.out.print("JOB COMPLETE" + jobName);
}
}
}