Skip to content

Instantly share code, notes, and snippets.

@kurotori
Created May 20, 2025 17:08
Show Gist options
  • Save kurotori/4a35cda67dbe139f81f423169a3f9b38 to your computer and use it in GitHub Desktop.
Save kurotori/4a35cda67dbe139f81f423169a3f9b38 to your computer and use it in GitHub Desktop.
Ejemplo de Clases con composición ("El Auto")
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];
}
public class Motor {
int cilindrada = 0;
String combustible = "";
int potencia = 0;
}
public class Rueda {
int rodado = 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment