在同一包和目录中找不到符号
2022-09-03 06:13:15
我有两个课程,提供和课程。它们都位于同一包和同一目录中。
产品.java:
package assignment02;
public class Offering implements Comparable<Offering> {
private Course course;
private int CRN;
private int semester;
public Offering(Course course, int CRN, int semester) {
this.course = course;
this.CRN = CRN;
this.semester = semester;
}
public int getNumCredits() {
return course.getNumCredits;
}
public int getCRN() {
return CRN;
}
public int getSemester() {
return semester;
}
public int compareTo(Offering other) {
if(other == null) return - 1;
return semester - other.semester;
}
}
课程.java:
package assignment02;
public class Course {
private String name;
private String rubric;
private String number;
private int numCredits;
public Course(String name, String rubric, String number, int numCredits) {
this.name = name;
this.rubric = rubric;
this.number = number;
this.numCredits = numCredits;
}
public String getName() {
return name;
}
public String getRubric() {
return rubric;
}
public String getNumber() {
return number;
}
public int getNumCredits() {
return numCredits;
}
}
当我尝试编译产品时,我收到错误:
D:\CS 140\assignment02>javac Offering.java
Offering.java:4: error: cannot find symbol
private Course course;
^
symbol: class Course
location: class Offering
和
Offering.java:8: error: cannot find symbol
public Offering(Course course, int CRN, int semester) {
^
symbol: class Course
location: class OfferingOffering.java:8: error: cannot find symbol
我知道这个错误意味着编译器无法对“Course”做任何事情,但我真的不知道为什么。我也知道这最终会变得非常明显,但我似乎无法弄清楚。任何帮助将不胜感激。