##产品接口,有location抽象方法 ```java public interface Production { public String location(); } ``` ##交通工具接口,有getType、getSpeed、getColor抽象方法 ```java public interface Vehicle { public String getType(); public String getSpeed(); public String getColor(); } ``` ##Car类,继承至产品、交通工具接口 具体类对象需要重写接口中的方法 ```java public class Car implements Vehicle, Production { private String type; private String speed; private String color; private String location; public Car(String type, String speed, String color,String location) { super(); this.type = type; this.speed = speed; this.color = color; this.location = location; } @Override public String getType() { return type; } @Override public String getSpeed() { return speed; } @Override public String getColor() { return color; } @Override public String location() { return location; } } ``` Last modification:January 19, 2022 © Allow specification reprint Support Appreciate the author AliPayWeChat Like 0 If you think my article is useful to you, please feel free to appreciate
One comment
这篇文章如同一幅色彩斑斓的画卷,每一笔都充满了独特的创意。