package action;
import dao.ProbaDao;
import daoI.IProbaDao;
import net.sourceforge.stripes.action.DefaultHandler;
import net.sourceforge.stripes.action.ForwardResolution;
import net.sourceforge.stripes.action.Resolution;
public class DensitateaPamanturilor extends BaseActionBean {
private String m0;
private String m1;
private String m2;
private int idProbaCurenta;
private String y;
private String yd;
private String e;
private String n;
@DefaultHandler
public Resolution view() {
idProbaCurenta = Integer.parseInt(getContext().getRequest().getSession(true).getAttribute("idProbaCurenta").toString());
return new ForwardResolution("/WEB-INF/jsp/densitateaPamanturilor.jsp");
}
public Resolution calculeaza() {
idProbaCurenta = Integer.parseInt(getContext().getRequest().getSession(true).getAttribute("idProbaCurenta").toString());
IProbaDao probaDao = new ProbaDao();
float w = probaDao.geProbaByID(idProbaCurenta).getW();
float rs = probaDao.geProbaByID(idProbaCurenta).getRs();
float m0F = Float.valueOf(getM0().toString().trim()).floatValue();
float m1F = Float.valueOf(getM1().toString().trim()).floatValue();
float m2F = Float.valueOf(getM2().toString().trim()).floatValue();
double yD = (m0F / ((m1F - m2F) / 1 - (m1F - m0F) / 0.9));
double ydD = yD / (1 + w);
float eF = (float) ((rs - ydD) / ydD);
double nD = (rs - ydD) / rs;
probaDao.addYYdne(idProbaCurenta, yD, ydD, eF, nD);
String yS = Double.toString(yD);
int p = yS.indexOf('.');
if (p >= 1) {
yS = yS.substring(0, p + 2);
}
setY(yS);
String ydS = Double.toString(ydD);
p = ydS.indexOf('.');
if (p >= 1) {
ydS = ydS.substring(0, p + 2);
}
setYd(ydS);
String eS = Float.toString(eF);
p = eS.indexOf('.');
if (p >= 1) {
eS = eS.substring(0, p + 2);
}
setE(eS);
String nS = Double.toString(nD);
p = nS.indexOf('.');
if (p >= 1) {
nS = nS.substring(0, p + 2);
}
setN(nS);
return new ForwardResolution("/WEB-INF/jsp/densitateaPamanturilor.jsp");
}
/**
* @return the y
*/
public String getY() {
return y;
}
/**
* @param y the y to set
*/
public void setY(String y) {
this.y = y;
}
/**
* @return the yd
*/
public String getYd() {
return yd;
}
/**
* @param yd the yd to set
*/
public void setYd(String yd) {
this.yd = yd;
}
/**
* @return the e
*/
public String getE() {
return e;
}
/**
* @param e the e to set
*/
public void setE(String e) {
this.e = e;
}
/**
* @return the n
*/
public String getN() {
return n;
}
/**
* @param n the n to set
*/
public void setN(String n) {
this.n = n;
}
/**
* @return the m0
*/
public String getM0() {
return m0;
}
/**
* @param m0 the m0 to set
*/
public void setM0(String m0) {
this.m0 = m0;
}
/**
* @return the m1
*/
public String getM1() {
return m1;
}
/**
* @param m1 the m1 to set
*/
public void setM1(String m1) {
this.m1 = m1;
}
/**
* @return the m2
*/
public String getM2() {
return m2;
}
/**
* @param m2 the m2 to set
*/
public void setM2(String m2) {
this.m2 = m2;
}
}