Buonasera ragazzi, avrei dei problemi con questo codice:
Outputs:codice:class GameShape { public void displayShape() { System.out.println("displaying shape"); } // more code } class PlayerPiece extends GameShape { public void movePiece() { System.out.println("moving game piece"); } // more code } class TilePiece extends GameShape { public void getAdjacent() { System.out.println("getting adjacent tiles"); } // more code } public class TestShapes { public static void main (String[] args) { PlayerPiece player = new PlayerPiece(); TilePiece tile = new TilePiece(); doShapes(player); doShapes(tile); } public static void doShapes(GameShape shape) { shape.displayShape(); } }
displaying shape
displaying shape
Ciò che non capisco è: 1) doShapes vorrebbe dire esegui il metodo Shapes...ma dov'è? Non mi sembra che da nessuna parte si stato dichiarato uno Shapes. 2) Che significa "doShapes(GameShape shape)" 3) perché il risultato è 2 volte displaying shape?^
Grazie in anticipo

Rispondi quotando
