/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Capitulo_4.CaidaLibre;

/**
 *
 * @author calderon
 */
public class CaidaLibre {
    private double vi, y0, g;
    
    public CaidaLibre(double unaY, double unaV) {
        vi = unaV;
        y0 = unaY;
        g = 9.8;
    }
    
    public double hmax() {
        return vi*vi/2.0/g;
    }
    
    public String tiempos() {
        Cuadratica a = new Cuadratica(-0.5*g, vi, y0 - 0.5*hmax());
        return a.toString();
    }
    
    public String toString() {
        String aux = "";
        
        aux += "Para un objeto que se lanza desde una altura de " + y0 + " mts\n";
        aux += "con una velocidad inicial de v0 = " + vi + " mts/seg \n";
        aux += "\n";
        aux += "La altura maxima que alcanza es " + hmax();
        aux += "\n";
        aux += "Los tiempos en los cuales esta a la mitad de la altura maxima son \n";
        aux += tiempos();
        aux += "\n";       
        
        return aux;
    }
}
