3 回答
慕尼黑的夜晚无繁华
TA贡献1864条经验 获得超6个赞
接口
接口是一个空的外壳。
// I say all motor vehicles should look like this:interface MotorVehicle{ void run(); int getFuel();}// My team mate complies and writes vehicle looking that wayclass Car implements MotorVehicle{ int fuel; void run() { print("Wrroooooooom"); } int getFuel() { return this.fuel; }}
抽象类
// I say all motor vehicles should look like this:abstract class MotorVehicle{ int fuel; // They ALL have fuel, so lets implement this for everybody. int getFuel() { return this.fuel; } // That can be very different, force them to provide their // own implementation. abstract void run();}// My teammate complies and writes vehicle looking that wayclass Car extends MotorVehicle{ void run() { print("Wrroooooooom"); }}
实施
倚天杖
TA贡献1828条经验 获得超3个赞
添加回答
举报
0/150
提交
取消