JAVA面向对象程序设计-FeiGe快递系统-继承I

99 阅读1分钟

JAVA面向对象程序设计-FeiGe快递系统-继承


`

public class vehicle {
public int wheel;
public void start(){
System.out.println(“vehicle的start方法启动”);
}
private String enginebrand;
protected void end(){
System.out.println(“熄火”);
}

}


![在这里插入图片描述](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/00978071af2a4616aaaa2c453f2bcf37~tplv-k3u1fbpfcp-zoom-1.image)

public class sedan extends car {
public void manned(){
System.out.println(“可载人”);
}
public static void main(String[] args) {
sedan sedan =new sedan();
sedan.start();
}
}


![在这里插入图片描述](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/6aec2dc1d59248c38f05f67ba9e0fd70~tplv-k3u1fbpfcp-zoom-1.image)

public class car extends vehicle {
public double carheight;
public void run(){
System.out.println(“启动快”);
}
public static void main(String[] args) {
car car =new car();
car.start();
car.end();
car.run();
}
}


![在这里插入图片描述](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/847691c76bb74aa6befe937eb9d751bf~tplv-k3u1fbpfcp-zoom-1.image)