Skip to content

Conversation

@ibisshagrat
Copy link

Se aplican los cambios indicados a VehiculoConRuedas, y se añade Moto.


public class Moto extends VehiculoConRuedas {

public String getMatricula() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No se ha pedido matrícula para las motos

public class Moto extends VehiculoConRuedas {

public String getMatricula() {
return super.matricula;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Si pones el campo privado no tendrías acceso a él

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lo puse como protected para poder acceder a ese campo desde el hijo. ¿No se debería?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lo hice asi, para poder implementar un método abstracto.

Comment on lines 13 to 15
public Moto(String modelo, String color, String matricula) {
super(modelo, color, 2, matricula);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem comentario de matrícula

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

En este caso se manda la matricula al contranstuctor vehículo con ruedas,, que es publico, aunque matricula fuera privado, entiendo que no daría problemas, no?

private String matricula;
private int cantRuedas;
private Date fechaMatriculacion;
protected String matricula;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No se ha pedido matricula aquí

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Como era código que se repetía entre los hijos, lo incluí en el padre, lo quitaré.

private int cantidadRuedas;

public abstract Date proximaItv();
public abstract String getMatricula();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Como comenté era solo por poner un método abstracto. Se podría hacer como método normal, así lo haré.

@ibisshagrat
Copy link
Author

Se suprime la matricula de Moto.
Se convierte matricula de VehiculoConRuedas en privada, el método abstracto getMatricula() en normal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants