Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intento de solucion sinxela en Java #36

Merged
merged 2 commits into from
Nov 29, 2017
Merged

Conversation

isGroba
Copy link

@isGroba isGroba commented Oct 30, 2017

Esta solución inclue o bonus 1 cunha pequena entrada no programa para que o usuario poida engadir os datos. É unha solución moi sinxela, tanto que non engado nin test... agardao as vosas correccións e consellos. Grazas!!

@tomasalmeida
Copy link
Contributor

Hola @isGroba, como pediste consejos sobre la clase java, pongo algunas cosas que me parecen interesantes para que las tengas en el futuro!

private int capacidade;
private int contido;

public Caldeiro() {
Copy link
Contributor

@tomasalmeida tomasalmeida Oct 30, 2017

Choose a reason for hiding this comment

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

Este constructor hace 3 cosas que el propio compilador ya te hace por defecto:

  • If a constructor does not explicitly invoke a superclass constructor, the Java compiler automatically inserts a call to the no-argument constructor of the superclass. If the super class does not have a no-argument constructor, you will get a compile-time error. Object does have such a constructor, so if Object is the only superclass, there is no problem. (https://docs.oracle.com/javase/tutorial/java/IandI/super.html)

  • Los atributos en java se inicializan siempre con 0 (para numeros primitivos), false (para boolean primitivo) y null para objetos. En tu caso, capacidade y contido son enteros primitivos y por lo tanto, son automaticamente inicializados con cero. https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html

Copy link
Author

Choose a reason for hiding this comment

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

Grazas polos consellos!! Tereinos presentes!!

@antonmry antonmry merged commit ce758a2 into VigoTech:master Nov 29, 2017
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.

3 participants