Created
May 20, 2025 17:08
-
-
Save kurotori/4a35cda67dbe139f81f423169a3f9b38 to your computer and use it in GitHub Desktop.
Ejemplo de Clases con composición ("El Auto")
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Auto { | |
String color = ""; | |
String marca = ""; | |
String modelo = ""; | |
Motor maquina = new Motor(); | |
///A | |
Rueda rueda1 = new Rueda(); | |
Rueda rueda2 = new Rueda(); | |
Rueda rueda3 = new Rueda(); | |
Rueda rueda4 = new Rueda(); | |
///B | |
Rueda[] ruedas = new Rueda[4]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Motor { | |
int cilindrada = 0; | |
String combustible = ""; | |
int potencia = 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Rueda { | |
int rodado = 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment