父类
package com.imooc;
public class traffic {
int planeSpeed;
int planeAccount;
public int getPlaneSpeed() {
return planeSpeed;
}
public void setPlaneSpeed(int planeSpeed) {
this.planeSpeed = planeSpeed;
}
public int getPlaneAccount() {
return planeAccount;
}
public void setPlaneAccount(int planeAccount) {
this.planeAccount = planeAccount;
}
public void show(){
this.setPlaneAccount(planeAccount=100);
this.setPlaneSpeed(planeSpeed=1000);
System.out.println("飞机的速度"+planeSpeed);
System.out.println("飞机的载客数量"+planeAccount);
}
}package com.imooc;
public class testing {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
traffic run1=new traffic();
run1.show();
}
}子类我不知道怎么用到,为什么show方法放到子类里,测试程序就无法调用show方法
traffic run1=new traffic(); 这句话对象是父类啊,你要子类就要用子类
你这是完整的解决方法,不需要用到子类。只是你命名traffic误导了你自己