Skip to content

Instantly share code, notes, and snippets.

@gabrielbiga
Last active August 29, 2015 13:57
Show Gist options
  • Save gabrielbiga/9369282 to your computer and use it in GitHub Desktop.
Save gabrielbiga/9369282 to your computer and use it in GitHub Desktop.
Circulo
/**
* Circulo
* com.gsoft.Circulo
*
* Operacoes com circulo
*
* 05/03/2014 @ 12:15:20 PM
* Copyright (C) 2014 Gsoft do Brasil Sistemas
*
* @author Gabriel Marinho <[email protected]>
*/
package circulo;
import static java.lang.Math.PI; //Implementa constante PI
/**
*
* @author Gabriel Marinho <[email protected]>
*/
public class Circulo {
private double raio;
//Construtor
public Circulo(double R) {
this.raio = R;
}
public double calcularArea() {
//Formula: PI * R²
return PI * Math.pow(this.raio, 2);
}
public double calcularDiametro() {
//Forumula: 2 * R
return 2 * this.raio;
}
public double calcularPerimetro() {
//Foruma: PI * Diametro
return PI * this.calcularDiametro();
}
public double getRaio() {
return this.raio;
}
public void setRaio(double raio) {
this.raio = raio;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment