Created
October 26, 2012 15:01
-
-
Save delucas/3959278 to your computer and use it in GitHub Desktop.
Ejercicio de Círculo/Cilindro resuelto en clase - UNTreF EdD 1
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 Cilindro { | |
| private Double altura; | |
| private Circulo base; | |
| public void setAltura(Double altura) { | |
| this.altura = altura; | |
| } | |
| public void setBase(Circulo base) { | |
| this.base = base; | |
| } | |
| public Double getVolumen() { | |
| return this.altura * this.base.getArea(); | |
| } | |
| } |
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 Circulo { | |
| private Double radio; | |
| public void setRadio(Double radio) { | |
| this.radio = radio; | |
| } | |
| public Double getArea() { | |
| return Math.PI * Math.pow(this.radio, 2); | |
| } | |
| public Double getPerimetro() { | |
| return 2 * Math.PI * this.radio; | |
| } | |
| public Double getRadio() { | |
| return this.radio; | |
| } | |
| public Double getDiametro() { | |
| return this.radio * 2.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
| Welcome to DrJava. | |
| > Circulo c = new Circulo() | |
| > c.setRadio(1.0) | |
| > c.getRadio() | |
| 1.0 | |
| > c.getDiametro() | |
| 2.0 | |
| > c.getPerimetro() | |
| 6.283185307179586 | |
| > c.getArea() | |
| 3.141592653589793 | |
| > Cilindro cili = new Cilindro() | |
| > cili.setAltura(2.0) | |
| > cili.setBase(c) | |
| > cili.getVolumen() | |
| 6.283185307179586 | |
| > _ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment