下面是我写的Java code
public class Instructor extends Person {  private Course course; public Instructor(String name, int UFID, String dob){ super(name, UFID, dob); } public Instructor(String name, int UFID, String dob, Course course){ super(name, UFID, dob); this.course = course; } public void setCourse(Course course){ this.course = course; } public Course getCourse(){ return course; } public String getName() { return name; } public String toString(){ String str = ""; str += "Course Being Taught: " + "\n"; str += course.toString(); return str;
}}
×××××××××××××××××××××××××××××××××××××××××××××××××××××××
下面是对code的要求
The Instructor classThe Instructor class is a subclass of the Person class.
Properties:
----------
private Course course; // the course being taught by the instructor

Constructors:
------------
1) public Instructor(String name, int UFID, String dob)
   calls the superclass' constructor
   
2) public Instructor(String name, int UFID, String dob, Course course)
   calls the superclass' constructor and sets the other properties appropriately
  
Methods:
--------
-getCourse/setCourse - get/set methods for the course variable-toString() - The toString() method is public and returns a String. 
              It should return a String in this format [HINT: Use the super class' toString() method somehow]: 
              
      Instructor:
              Name: name
              UFID: UFID
              D.O.B: dob
      Course Being Taught:
      [Course info goes here] (HINT: Use the Course class' toString method)
    
哪位要是能帮我修改一下感激不尽
可以给我发个Email, [email protected]
或者用QQ联系我1834972557

解决方案 »

  1.   

    public String toString(){String str = "Instructor: Instructor: \n" + super.toString();str += "\nCourse Being Taught: " + "\n";str += course.toString();return str;
    }
      

  2.   

    Instructor.javapublic String toString(){String str = "Instructor: Instructor: \n" + super.toString();str += "\nCourse Being Taught: " + "\n";str += course.toString();return str;
    }Person.javapublic String toString(){String str = " Name: " + this.name +"\n"
      + " UFID: " + this.UFID + "\n"
      + " D.O.B: + this.dob ;
    return str;
    }