Box.java 824 Bytes
Newer Older
Nelson Ruiz committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42

//practica de set y get
class Boxx {

    public float ancho;
    public float largo;
    public float profundidad;
    public float volumen;
/*    public Boxx(int anch,int larg,int prof){
        this.ancho=anch;
        this.largo=larg;
        this.profundidad=prof;
    }
*/
    public void setDatos(float anch,float larg,float prof){
        this.ancho=anch;
        this.largo=larg;
        this.profundidad=prof;
    }
    public void calcularVolumen(){
         this.volumen=ancho*largo*profundidad;
    }

    public float getDatos(){
        
        return this.volumen;
    }
    
}

public class Box{

    public static void main(String[] args) {
        Boxx obj= new Boxx();
        obj.setDatos(2,3,5);
        obj.calcularVolumen();
        System.out.println("Volumen= "+obj.getDatos()+" m2");
    }
}