2007/01/11 | 接口类继承问题
类别(STUDY) | 评论(0) | 阅读(48) | 发表于 16:01

接口类只可以继承接口类的,例如Student是一个类,而“public interface CollegeStudentInterface extends Student”就是错误的。如果要写一个CollegeStudent的接口只能先把Student接口化,然后将CollegeStudentInterface继承它。

/**An interface for a class of students.*/
public interface StudentInterface
{
 /** Task: Sets student's name and id
  *  @param studentName a name that is the desired student's name
  *  @param studentId   an string that is the desired student's id */
 public void setStudent(Name studentName,String studentId);
 
 /** Task: Sets student's name
  *  @param: studentName a name that is the desired student's name
  */
 public void setName(Name studentName);
 
 /** Task: Gets student's name
  * @return a name
  */
 public Name getName();
 
 /** Task: Sets student's id
  *  @param studentId a string that is the desired student's id
  */
 public void setId(String studentId);
 
 /** Task: Gets student's id
  *  @return a string type student' id
  */
 public String getId();
 
 /** Task: Converse a student class into string
  *  @return a string contains the id and name
  */
 public String toString();
}

/**An interface for a class of collegeStudents.
 *
 * @author Isaiah
 *
 */
public interface CollegeStudentInterface extends StudentInterface
{
 /** Task: Sets student's name,id,graduation year,degree sought
  *  @param studentName a name that is the desired student's name
  *  @param studentId a string that is the desired student's id
  *  @param graduationYear an int that is the desired graduation year
  *  @param degreeSought a string that is the desired degree sought
  */
 public void setStudent(Name studentName, String studentId,
   int graduationYear,String degreeSought);
 
 public void setYear();
 
 public int getYear();
 
 public void setDegree();
 
 public String getDegree();
 
 public String toString();
}

0

评论Comments

日志分类
首页[90]
GUITAR[43]
JRUM[4]
PIANO[23]
HEART_ACHES[5]
STUDY[7]
FRAGMENT[8]