我对如何从新对象实例中获取参数也流入超类以更新超类中的私有字段感到困惑。
所以我在一个高级Java课上,并且我的作业需要一个“ Person”超级类和一个扩展“ Person”的“ Student”子类。
Person类存储学生姓名,但它是Student类的构造函数,它接受Person名称。
假设Person中没有方法可以更新变量方法...例如subClassVar = setSuperClassVar();
例如:
public class Person
{
private String name; //holds the name of the person
private boolean mood; //holds the mood happy or sad for the person
private int dollars; //holds their bank account balance
}
class Student extends Person //I also have a tutor class that will extend Person as well
{
private String degreeMajor //holds the var for the student's major they have for their degree
Public Student(String startName, int …Run Code Online (Sandbox Code Playgroud)