java吧 关注:1,234,778贴子:12,701,900
  • 2回复贴,共1

求大神教教我

取消只看楼主收藏回复

interface Achievement
{
float average();
}
class Person
{
String name;
int age;
public Person(String newName,int newAge)
{ name=newName;
age=newAge;
}
public void introduce()
{
System.out.println("你好,我是"+name+",今年"+age+"岁");
}
}
class Student implements Achievement
{
int Chinese;
int Math;
int English;
public Student(String newName,int newAge){
//调用父类中的构造方法
}
public void setScore(int c,int m,int e)
{ Chinese=c;
Math=m;
English=e;
}
public float average()
{
return (Chinese+Math+English)/3;
}
}
class test42 { //主类
public static void main(String[] args) {
// TODO Auto-generated method stub
Student s1=new Student("张三",16);
//调用s1的introduce方法
s1.setScore(80, 90, 80);
System.out.println(s1.average());
}
}
怎么调用 //调用s1的introduce方法和 //调用父类中的构造方法


IP属地:广东1楼2015-11-28 09:30回复


    IP属地:广东2楼2015-11-28 09:34
    回复


      IP属地:广东4楼2015-11-28 09:45
      回复