Circulo
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package figura.circulo;
public class Circulo {
double radio; double pi = 3.1416;
public Circulo(double dato1){
radio = dato1;
}
public double area(){
return pi * (Math.pow(radio, 2));
}
public double perimetro(){
return ((2*radio)*(pi));
}
public double obtenerRadio(){
return radio;
}
public void modificarRadio(double dato1){
radio = dato1;
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Pruebas;
import figura.circulo.Circulo;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
public class CirculoTest {
static Circulo circulo;
public CirculoTest() {
}
@BeforeClass
public static void setUpClass() throws Exception {
circulo = new Circulo(5.0);
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
// TODO add test methods here.
// The methods must be annotated with annotation @Test. For example:
//
// @Test
// public void hello() {}
@Test public void areaTest(){
assertEquals(circulo.area(),78.53999999999999,0);
}
@Test public void perimetroTest(){
assertEquals(circulo.perimetro(),31.416,0);
}
@Test public void obtenerLadosTest(){
assertEquals(circulo.obtenerRadio(),5,0);
}
@Test public void modificarLadosTest(){
circulo.modificarRadio(6.0);
assertEquals(circulo.obtenerRadio(),6,0);
}
@Test public void nuevoTest(){
System.out.println(circulo.obtenerRadio());
}
}
No hay comentarios:
Publicar un comentario