/*
 * 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.Ecuacion_cuadratica;

/**
 *
 * @author calderon
 */
public class Cuadratica {
    private double A, B, C;
    private Complejo x1, x2;
    
    public Cuadratica(double unaA, double unaB, double unaC) {
        A = unaA;
        B = unaB;
        C = unaC;
        Solucion();
    }
    
    public void Solucion() {
        double D;
        
        D = B*B - 4.0*A*C;
        
        if(D>0) {
            x1 = new Complejo((-B + Math.sqrt(D))/(2.0*A), 0);
            x2 = new Complejo((-B - Math.sqrt(D))/(2.0*A), 0);
        }
        
        else {
            x1 = new Complejo(-B /(2.0*A), +Math.sqrt(-D)/(2.0*A));
            x2 = new Complejo(-B /(2.0*A), -Math.sqrt(-D)/(2.0*A));
            
        }
    }
    
    @Override
    public String toString() {
        String aux;
        
        aux  = x1.toString() + x2.toString();
        
        return aux;
    }
    
}
