import javax.swing.*;

public class bina_malzeme_veri
{
public String sira; 
public String isim; 
public String gurup; //
public double ro; //  density kg/m^3;
public double k;  //  conductivity W/(m K)
public double R;  //  Resistance (m^2K)/W
public double x;  //  Thickness m

public bina_malzeme_veri(String sirai,String namei,String groupi, double roi,double ki,double xi)
{
sira=sirai;
isim=namei;
gurup=groupi;
ro=roi;
k=ki;
x=xi;
setx(xi);
}

public void setx(double xi)
{
double xx[]={0.5e-2,1e-2,2e-2,5e-2,0.1,0.15,0.2};
double y1[]={0.13,0.16,0.19,0.21,0.20,0.19,0.19};
double y2[]={0.13,0.16,0.17,0.19,0.19,0.19,0.19};
double y3[]={0.13,0.16,0.21,0.24,0.24,0.24,0.24};
x=xi;
int nn=xx.length;
if(sira.equals("11.1")) 
{ if(x<=xx[0]) R=y1[0];
  else if(x>=xx[nn-1]) R=y1[nn-1];
  else
  {for(int i=0;i<nn-1;i++)
    {if(x>=xx[i]&& x<xx[i+1])
      R=(x-xx[i])/(xx[i+1]-xx[i])*(y1[i+1]-y1[i])+y1[i];
      k=x/R;
      break;
    }
  }
}
else if(sira.equals("11.2")) 
{ if(x<=xx[0]) R=y2[0];
  else if(x>=xx[nn-1]) R=y2[nn-1];
  else
  {for(int i=0;i<nn-1;i++)
    {if(x>=xx[i]&& x<xx[i+1])
      R=(x-xx[i])/(xx[i+1]-xx[i])*(y2[i+1]-y2[i])+y2[i];
      k=x/R;
      break;
    }
  }
}
else if(sira.equals("11.3")) 
{ if(x<=xx[0]) R=y3[0];
  else if(x>=xx[nn-1]) R=y3[nn-1];
  else
  {for(int i=0;i<nn-1;i++)
    {if(x>=xx[i]&& x<xx[i+1])
      R=(x-xx[i])/(xx[i+1]-xx[i])*(y3[i+1]-y3[i])+y3[i];
      k=x/R;
      break;
    }
  }
}
else {R=x/k;}
//System.out.println("x="+x+"R="+R+"x="+x+"k="+k);
}

public String toString()
{
String s="sıra = "+sira+"isim = "+isim+" gurup = "+gurup+"\n";
s+='\u03C1'+" = "+ro+" kg/m"+'\u00B3'+" k = "+k+"W/mK ";
s+="R = "+R+"m^2K/W  ";
return s;
}

public void print()
{JOptionPane.showMessageDialog(null,toString());}

}