接口类:
public interface CourseChooseImpl {
public String qcc(String spe);
}
Stu方法类:
public class Stu implements CourseChooseImpl{
int ID; // 学号
String name[];// 姓名
char sex; // 性别
String spe; // 专业
String cou; // 课程
public Stu(int iD, String[] name, char sex, String spe, String cou) {
ID = iD;
this.name = name;
this.sex = sex;
this.spe = spe;
this.cou = cou;
}
@Override
public String toString() {
return spe+","+cou;
}
public void showInfo(){//输出学生的基本信息
System.out.println("学号:"+this.ID);
System.out.println("姓名:"+this.name);
System.out.println("性别:"+this.sex);
System.out.println("专业:"+this.spe);
System.out.println("课程:"+this.cou);
}
@Override
public String qcc(String spe) {
return "welcome to you !";
}
public static void main(String[] args) {
String[] names = {"小明","小芳","小刚"};
Stu student = new Stu(101, names , '男', "电子信息", "模拟电路");
String str= student. qcc("模拟电路");
System.out.println(str);
System.out.println(student);
}
}
1、XuanKe
2、XuanKe
3、this.ID = ID;
this.name = name;
this.sex = sex;
this.spe = spe;
this.cou = cou;
4、System.out.println("学号:"+this.ID);
System.out.println("姓名:"+this.name);
System.out.println("性别:"+this.sex);
System.out.println("专业:"+this.spe);
System.out.println("课程:"+this.cou);
5、100,'张三','男','计算机','C语言'
6、'计算机'
我觉得qcc方法里应该返回stu类中的课程 return this.cou