 // FICHIER A COMPLETER
package com.example.menu;

import java.text.DecimalFormat;


import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.NumberPicker;

public class ResultIMCActivity extends BaseMenuActivity {

	double imc;

	

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_result_imc);
        
        // COMPLETER ICI je recupere mon objet global individu
        
        TextView tv_nom=(TextView)findViewById(R.id.tv_result_nom);
        TextView tv_prenom=(TextView)findViewById(R.id.tv_result_prenom);
        tv_nom.setText(pers.getNom());
        tv_prenom.setText(pers.getPrenom());
        imc=calculIMC(XXXXXXXX); // COMPLETER ICI remplacer les XXX
        displayIMC();

  
    }






	
	public void displayIMC() {
		// TODO Auto-generated method stub
		ImageView iconeIMC=(ImageView) findViewById(R.id.iv_iconeIMC);
		TextView commentIMC=(TextView)findViewById(R.id.tv_commentIMC);
		LinearLayout ll=(LinearLayout)findViewById(R.id.ll_IMCdisplay);
		ll.setVisibility(View.VISIBLE);
		DecimalFormat f = new DecimalFormat();
		f.setMaximumFractionDigits(1);
		String imcChaine=f.format(imc);
		String comment= "IMC: "+imcChaine;
		if (imc<18.5){ //maigreur
			iconeIMC.setImageResource(R.drawable.sad);
			comment=comment+" attention : etat de maigreur";
		}
		else {
				if ((imc>=18.5)&&(imc<25)){ // normal
					iconeIMC.setImageResource(R.drawable.angel);
					comment=comment+" corpulence normale";
				}
				else {
						if ((imc>=25)&&(imc<35)){ //surpoids
							iconeIMC.setImageResource(R.drawable.hmm);
							comment=comment+" en surpoids. A surveiller.";
						}
						else { // obésité
							iconeIMC.setImageResource(R.drawable.sad);
							comment=comment+" attention danger.Il faut perdre des kilos";
						}
				}
			}
		commentIMC.setText(comment);
			
	}
	

	
	private double calculIMC(int poids, int taille)
	{	
		double taillemetre=((double)taille/100);
		double imc=poids/Math.pow(taillemetre, 2);
		return (imc);
	}



    
}
