我有一个作业,需要一个初始课程和一个单独的项目来测试该课程。现在,每次我尝试编译它时,它都会给我一个这些错误:
package blooddata;
TestBloodData.java:10: error: cannot find symbol
BloodData patient1 = new BloodData("AB", "-");
^
symbol: class BloodData
location: class TestBloodData
TestBloodData.java:10: error: cannot find symbol
BloodData patient1 = new BloodData("AB", "-");
^
symbol: class BloodData
location: class TestBloodData
TestBloodData.java:11: error: cannot find symbol
BloodData patient2 = new BloodData("B", "+");
^
symbol: class BloodData
location: class TestBloodData
TestBloodData.java:11: error: cannot find symbol
BloodData patient2 = new BloodData("B", "+");
^
symbol: class BloodData
location: class TestBloodData
4 errors
实际代码如下。我试过谷歌搜索、youtube 和阅读我的教科书。我很困惑为什么会这样说。我尝试关闭并重新打开 NetBeans,甚至卸载和安装 IDE,但显然没有任何效果。我尝试将项目属性中的主类设置为我正在测试的 BloodData 类(这是大多数建议),但这也不起作用。
package blooddata;
/**
*
* @author CaseyPhillips
*/
public class BloodData {
public String bloodType;
public String rHFactor;
public BloodData()
{
bloodType = "O";
rHFactor = "+";
}
public BloodData(String bloodType, String rHFactor)
{
this.bloodType = bloodType;
this.rHFactor = rHFactor;
}
public void setBloodType(String bloodType)
{
this.bloodType = bloodType;
}
public String getBloodType()
{
return bloodType;
}
public void setRHFactor(String rHFactor)
{
this.rHFactor = rHFactor;
}
public String getRHFactor()
{
return rHFactor;
}
public void showBloodType()
{
System.out.println("The patient's blood type is " +
bloodType + " and their Rh Factor is " + rHFactor);
}
public static void main(String[] args) {
// TODO code application logic here
}
}
测试司机:
package blooddata;
/*
Author: Casey Phillips
*/
public class TestBloodData
{
public static void main(String[] args)
{
BloodData patient1 = new BloodData("AB", "-");
BloodData patient2 = new BloodData("B", "+");
patient1.showBloodType();
patient2.showBloodType();
}
}
我使用的编译命令是:
Caseys-MacBook-Pro:~ CaseyPhillips$ cd NetBeansProjects/BloodData/src/blooddata
Caseys-MacBook-Pro:blooddata CaseyPhillips$ javac TestBloodData.java
TestBloodData.java:11: error: cannot find symbol
BloodData patient1 = new BloodData("AB", "-");
^
symbol: class BloodData
location: class TestBloodData
TestBloodData.java:11: error: cannot find symbol
BloodData patient1 = new BloodData("AB", "-");
^
symbol: class BloodData
location: class TestBloodData
TestBloodData.java:12: error: cannot find symbol
BloodData patient2 = new BloodData("B", "+");
^
symbol: class BloodData
location: class TestBloodData
TestBloodData.java:12: error: cannot find symbol
BloodData patient2 = new BloodData("B", "+");
^
symbol: class BloodData
location: class TestBloodData
4 errors