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
提交
取消