我正在尝试为 java 中的一个类做一些功课,我想做的部分是在 homework.class 中创建一个新人,它扩展了 .name 类
名称类
public class Homework extends Object implements Comparable<Homework> {
private int id;
private Name name;
private int section;
private Files files;
private int dateSubmitted;
...... hwk 类的一部分
public Homework(String first, String last, int section, int dateSubmitted){ //fix me
this.id = nextAvailableUid();
this.section = section;
this.dateSubmitted = dateSubmitted;
this.name.Name(first,last); //error is here in the Name call telling me Name is not a method of Name
}
我得到的错误是在名称中,它告诉我在名称类中创建一个方法名称,我知道有....从 name.class 中可以看出
public class Name implements Comparable<Name>{
private String Fname;
private String Lname;
public Name(String first, String last) {
this.Fname = first;
this.Lname = last; //init the name
}
}