//Megat Irfan Zackry Bin Ismail
//A20EC0205

#include <iostream>
using namespace std;

class Person{
	private:
		string name;
		int yob;
		int weight;
		float height;
		int age;
		float bmi;
		string category;

	public:
		Person();
		~Person();
		Person(string n, int y, int w, float h);
		void calcBMInCategory();
		void printDetailInfo();
		friend void modify(Person mp);
		friend void findPrintHighest(Person arrPerson[]);
};

	Person::Person(){
		
	}
	
	Person::Person(string n, int y, int w, float h){
		name=n; yob = y; weight = w; height =h;
	}
	
	Person::~Person(){
		
	}



void Person::printDetailInfo(){
	age=2021-yob;
	cout<<"\nName : "<<this->name;
	cout<<"\nYoB : "<<this->yob;
	cout<<"\nWeight : "<<this->weight;
	cout<<"\nHeight : "<<this->height;
	cout<<"\nAge : "<<this->age;
	cout<<"\nBMI : "<<this->bmi;
	cout<<"\nCategory : "<<this->category;
}

///////////  functions ///////

void modify(Person mp){
	mp.name="anonymous";
	mp.yob=1;
	mp.height=1;
	mp.weight=1;
}

void findPrintHighest(Person arrPerson[]){
	cout<<endl<<endl;
	float highest=0;
	int location=0;
	for (int i=0; i<40;i++){
		cout<<endl;
		cout<<"Name : ";
		cin>>arrPerson[i].name;
		cout<<"Year of Birth : ";
		cin>>arrPerson[i].yob;
		cout<<"Weight : ";
		cin>>arrPerson[i].weight;
		cout<<"Height : ";
		cin>>arrPerson[i].height;
		arrPerson[i].calcBMInCategory();
		if (highest<=arrPerson[i].bmi){
			highest=arrPerson[i].bmi;
			location = i;
		}
		
	}
	cout<<endl<<endl<<"Highest person "<<endl;
	arrPerson[location].printDetailInfo();
}

void Person::calcBMInCategory(){
	bmi=(weight/(height*height));
	
	if (bmi<18.5){
		category="Underweight";
	}
	else if (bmi<24.5){
		category="Healthy weight";
	}
	else if (bmi<29.9){
		category="Overweight";
	}
	else {
		category="Obesity";
	}
}

int main(int argc, char** argv) {
	Person p2();
	Person p0("ali",1999,66,1.66);
	Person p1("Myba",1957,69,1.7);
	p0.calcBMInCategory(); //call calcbmi p0 n p1
	p1.calcBMInCategory();
	cout <<"before call modify";
	p0.printDetailInfo();
	modify(p0);
	cout <<"after call modify";
	p0.printDetailInfo();
	Person pa[40];		//create array of person 40
	findPrintHighest(pa); //find highest bmi, print person info
	return 0;
}
