#include <iostream>
#include <string>
#include <iomanip>
#include <cctype>
#include <fstream>

//Brynard Bryan Edmund A19EC0029
//See Wen Xiang A19EC0206
//Low Zi Xiang A19EC0080


//IMPORTANT
//admin id : admin
//admin password : admin1100



using namespace std;
//Medical_supplies class
class Medical_supplies{
	private:
		int giveaway;
	public:
		Medical_supplies()
		{
		giveaway =0;
		}
		virtual void setmaterial(){}
		void setgiveaway(int a)
		{
		giveaway=a;
		}
		int getgiveaway(){return giveaway;}
		virtual void givecounts(){}
};
//Mask class
class Mask:public Medical_supplies{
	private:
		int givecount=0,item_count=0 ;
		double hydrophilic=0,melt_blown=0,wood_plup=0,carbon_fiber=0,water_repelled=0;//material variable

	public:
		Mask()
		{
		}
		void setmaterial()
		{//first material
		cout<<"----------Calculate the face mask----------"<<endl<<endl;
		cout<<"*****Raw material for face mask*****"<<endl;
	    //cost per mask: 25g
	  
	    cout<<"Please enter amount of Hydrophilic spunbond non-woven fabric layer(kilogram) :";
	    cin>>hydrophilic;
		while(hydrophilic<0||cin.fail())
	    {
		cin.clear();
	    cin.ignore(100,'\n');
	    cout<<"Wrong input, minimum amount is 0kg."<<endl;
	    cout<<"Please enter amount of Hydrophilic spunbond non-woven fabric layer(kilogram) :";
	    cin>>hydrophilic;
	    }
		cout<<endl;
		//second material
		cout<<"Please enter amount of melt-blown non-woven fabric layer(kilogram) :";
		//cost per mask: 10.8g
		cin>>melt_blown;
		while(melt_blown<0||cin.fail())
	    {
		cin.clear();
	    cin.ignore(100,'\n');
	    cout<<"Wrong input, minimum amount is 0kg."<<endl;
	    cout<<"Please enter amount of melt-blown non-woven fabric layer(kilogram) :";
	    cin>>melt_blown;
	    }
	    cout<<endl;
	    //third material
	    cout<<"Please enter amount of wood pulp fiber layer(kilogram) :";
	    //cost per mask: 22.5g
	    cin>>wood_plup;
	   while(wood_plup<0||cin.fail())
	    {
		cin.clear();
	    cin.ignore(100,'\n');
	    cout<<"Wrong input, minimum amount is 0kg."<<endl;
	    cout<<"Please enter amount of wood pulp fiber layer(kilogram) :";
	    cin>>wood_plup;
	    }
	    cout<<endl;
	    //fourth material
	    cout<<"Please enter amount of activated carbon fiber layer(kilogram) :";
	    //cost per mask: 22.5g
	    cin>>carbon_fiber;
	   while(carbon_fiber<0||cin.fail())
	    {
		cin.clear();
	    cin.ignore(100,'\n');
	    cout<<"Wrong input, minimum amount is 0kg."<<endl;
	    cout<<"Please enter amount of activated carbon fiber layer(kilogram) :";
	    cin>>carbon_fiber;
	    }
	    cout<<endl;
	    //fifth material
	    cout<<"Please enter amount of water-repellent spun-bonded non-woven fabric layer(kilogram) :";
	    //cost per mask:22.5g
	    cin>>water_repelled;
	    while(water_repelled<0||cin.fail())
	    {
		cin.clear();
	    cin.ignore(100,'\n');
	    cout<<"Wrong input, minimum amount is 0kg."<<endl;
	    cout<<"Please enter amount of water-repellent spun-bonded non-woven fabric layer(kilogram) :";
	    cin>>water_repelled;
	    }
	    cout<<"___________________________________________________________________________________________"<<endl;
	    count_mask();
	    }
	    //count mask amount
	    void count_mask()
	    {item_count=hydrophilic/0.025;
	    if(item_count>melt_blown/0.0108)
	    item_count=melt_blown/0.0108;
	    if(item_count>wood_plup/0.0225)
	    item_count=wood_plup/0.0225;
	    if(item_count>carbon_fiber/0.0225)
	    item_count=carbon_fiber/0.0225;
	    if(item_count>water_repelled/0.0225)
	    item_count=water_repelled/0.0225;	   
		}
		//count supply
	    void givecounts()
	    {if(item_count/Medical_supplies::getgiveaway()>0)
		{//enough supply
		cout<<"Face mask per person : "<<(item_count/Medical_supplies::getgiveaway())<<endl;
		cout<<"Face mask remaining : "<<(item_count%Medical_supplies::getgiveaway())<<endl;
		cout<<"Amount of Hydrophilic spunbond non-woven fabric layer remaining :"<<(hydrophilic-(item_count*0.025))<<" kg"<<endl;
		cout<<"Amount of melt-blown non-woven fabric layer remaining :"<<(melt_blown-(item_count*0.0108))<<" kg"<<endl;
		cout<<"Amount of wood pulp fiber layer remaining :"<<(wood_plup-(item_count*0.0225))<<" kg"<<endl;
		cout<<"Amount of activated carbon fiber layer remaining :"<<(carbon_fiber-(item_count*0.0225))<<" kg"<<endl;
		cout<<"Amount of water-repellent spun-bonded non-woven fabric layer remaining :"<<(water_repelled-(item_count*0.0225))<<" kg"<<endl;
	    }
	    else
	    {//not enough supply
	    cout<<"Not enough mask to supply "<<Medical_supplies::getgiveaway()<<" people with "<<item_count<<" mask in total."<<endl;
	    cout<<"Amount of Hydrophilic spunbond non-woven fabric layer need to add :";
	    if((((Medical_supplies::getgiveaway()-item_count)*0.025)-(hydrophilic-(item_count*0.025)))>0)
	    cout<<((Medical_supplies::getgiveaway()-item_count)*0.025)-(hydrophilic-(item_count*0.025))<<" kg"<<endl;
	    else cout<<"0 kg"<<endl;
	    cout<<"Amount of melt-blown non-woven fabric layer need to add :";
	    if((((Medical_supplies::getgiveaway()-item_count)*0.0108)-(melt_blown-(item_count*0.0108)))>0)
	    cout<<((Medical_supplies::getgiveaway()-item_count)*0.0108)-(melt_blown-(item_count*0.0108))<<" kg"<<endl;
	    else cout<<"0 kg"<<endl;
	    cout<<"Amount of wood pulp fiber layer need to add :";
	    if((((Medical_supplies::getgiveaway()-item_count)*0.0225)-(wood_plup-(item_count*0.0225)))>0)
	    cout<<((Medical_supplies::getgiveaway()-item_count)*0.0225)-(wood_plup-(item_count*0.0225))<<" kg"<<endl;
	    else cout<<"0 kg"<<endl;
	    cout<<"Amount of activated carbon fiber layer need to add :";
	    if((((Medical_supplies::getgiveaway()-item_count)*0.0225)-(carbon_fiber-(item_count*0.0225)))>0)
	    cout<<((Medical_supplies::getgiveaway()-item_count)*0.0225)-(carbon_fiber-(item_count*0.0225))<<" kg"<<endl;
	    else cout<<"0 kg"<<endl;
		cout<<"Amount of water-repellent spun-bonded non-woven fabric layer need to add :";
		if((((Medical_supplies::getgiveaway()-item_count)*0.0225)-(water_repelled-(item_count*0.0225)))>0)
	    cout<<((Medical_supplies::getgiveaway()-item_count)*0.0225)-(water_repelled-(item_count*0.0225))<<" kg"<<endl;
	    else cout<<"0 kg"<<endl;
	    }
	    cout<<"___________________________________________________________________________________________"<<endl;
		}
};
//hand sanatizer class
class handsanitizer:public Medical_supplies{
	private:
		int givecount;
		int item_count;
		double isopropyl=0,glycerol=0,hydrogen_peroxide=0,sterile_water=0;	//material variable
	public:
		handsanitizer()
		{givecount=0;
		}
		
		void setmaterial()
		{//first material
		cout<<"----------Calculate number of 500ml hand sanitizer  ----------"<<endl<<endl;
		cout<<"*****Accumulated Hand Sanitizer*****"<<endl
		//cost per 500ml hand sanitizer: 416.65ml
		<<"Please enter amount of Isopropyl alcohol(litre) :";
		cin>>isopropyl;
	while(isopropyl<0||cin.fail())
	    {
		cin.clear();
	    cin.ignore(100,'\n');
	    cout<<"Wrong input, minimum amount is 0 litre."<<endl;
	    cout<<"Please enter amount of Isopropyl alcohol(litre) :";
	    cin>>isopropyl;
	    }
		cout<<endl;
		//second material
		cout<<"Please enter amount of glycerol(litre) :";
		//cost per 500ml hand sanatizer: 20.85ml
		cin>>glycerol;
		while(glycerol<0||cin.fail())
	    {
		cin.clear();
	    cin.ignore(100,'\n');
	    cout<<"Wrong input, minimum amount is 0 litre."<<endl;
	    cout<<"Please enter amount of glycerol(litre) :";
	    cin>>glycerol;
	    }
		cout<<endl;
		//third material
		cout<<"Please enter amount of hydrogen peroxide(litre) :";
		//cost per 500ml hand sanatizer: 7.25ml
		cin>>hydrogen_peroxide;
		while(hydrogen_peroxide<0||cin.fail())
	    {
		cin.clear();
	    cin.ignore(100,'\n');
	    cout<<"Wrong input, minimum amount is 0 litre."<<endl;
	    cout<<"Please enter amount of hydrogen peroxide(litre) :";
	    cin>>hydrogen_peroxide;
	    }
		cout<<endl;
		//fourth material
		cout<<"Please enter amount of sterile water(litre) :";
		//cost per 500ml hand sanatizer: 55.25ml
		cin>>sterile_water;
		while(sterile_water<0||cin.fail())
	    {
		cin.clear();
	    cin.ignore(100,'\n');
	    cout<<"Wrong input, minimum amount is 0 litre."<<endl;
	    cout<<"Please enter amount of sterile water(litre) :";
	    cin>>sterile_water;
	    }
		cout<<"___________________________________________________________________________________________"<<endl;
		count_hs();
		}
		//count hand sanitizer amount
		void count_hs()
		{item_count=isopropyl/0.41665;
		if (item_count>glycerol/0.02085)
		item_count=glycerol/0.02085;
		if (item_count>hydrogen_peroxide/0.00725)
		item_count=hydrogen_peroxide/0.00725;
		if (item_count>sterile_water/0.05525)
		item_count=sterile_water/0.05525;
		}
		//count supply
		void givecounts()
		{if(item_count/Medical_supplies::getgiveaway()>0)
		{//enough supply
		cout<< "Hand sanitizer per person : "<<item_count/Medical_supplies::getgiveaway()<<endl;
		cout<< "Hand sanitizer remaining : "<<item_count%Medical_supplies::getgiveaway()<<endl;
		cout<<"Amount of Isopropyl alcohol remaining :"<<(isopropyl-(item_count*0.41665))<<" litre"<<endl;
		cout<<"Amount of glycerol remaining :"<<(glycerol-(item_count*0.02085))<<" litre"<<endl;
		cout<<"Amount of hydrogen peroxide remaining :"<<(hydrogen_peroxide-(item_count*0.00725))<<" litre"<<endl;
		cout<<"Amount of sterile water remaining :"<<(sterile_water-(item_count*0.05525))<<" litre"<<endl;
	    }
		  else
		    {//not enough supply
			cout<<"Not enough hand sanitizer to supply "<<Medical_supplies::getgiveaway()<<" people with "<<item_count<<" hand sanitizer in total."<<endl;
		    cout<<"Amount of Isopropyl alcohol required :";
		    if((((Medical_supplies::getgiveaway()-item_count)*0.41665)-(isopropyl-(item_count*0.41665)))>0)
		    cout<<((Medical_supplies::getgiveaway()-item_count)*0.41665)-(isopropyl-(item_count*0.41665))<<" litre"<<endl;
		    else cout<<"0 litre"<<endl;
		    cout<<"Amount of glycerol required :";
		    if((((Medical_supplies::getgiveaway()-item_count)*0.02085)-(glycerol-(item_count*0.02085)))>0)
		    cout<<((Medical_supplies::getgiveaway()-item_count)*0.02085)-(glycerol-(item_count*0.02085))<<" litre"<<endl;
		    else cout<<"0 litre"<<endl;
			cout<<"Amount of hydrogen peroxide required :";
		    if((((Medical_supplies::getgiveaway()-item_count)*0.00725)-(hydrogen_peroxide-(item_count*0.00725)))>0)
		    cout<<((Medical_supplies::getgiveaway()-item_count)*0.00725)-(hydrogen_peroxide-(item_count*0.00725))<<" litre"<<endl;
		    else cout<<"0 litre"<<endl;
			cout<<"Amount of sterile water required :";
		    if((((Medical_supplies::getgiveaway()-item_count)*0.05525)-(sterile_water-(item_count*0.05525)))>0)
		    cout<<((Medical_supplies::getgiveaway()-item_count)*0.05525)-(sterile_water-(item_count*0.05525))<<" litre"<<endl;
		    else cout<<"0 litre"<<endl;
		    }
		    cout<<"___________________________________________________________________________________________"<<endl;
		}   
};
//medical protective cloth class
class Medical_protective_clothing:public Medical_supplies{
	private:
		int givecount=0;
		int item_count=0;
		double Polypropylene_Fabric=0,New_Polyester_Fiber=0,Polymer_Coated_Fabric=0,SMS_Nonwovens=0,Polyethylene_Breathable_Film=0;//material variable
		int choose=0;//choose for size
		double s=0.0765,m=0.0792,l=0.0819,xl=0.0846,xxl=0.0873,weight=0;//cloth size and cost of material per cloth(gram)
	public:
		Medical_protective_clothing(){}
		void setmaterial()
			{//first material
			cout<<"----------Calculate the medical protective clothing ----------"<<endl<<endl;
			cout<<"*****Raw material for medical protective clothing*****"<<endl;
		    cout<<"Please enter amount of Polypropylene Fabric(kilogram) :";
			cin>>Polypropylene_Fabric;
		    while(Polypropylene_Fabric<0||cin.fail())
	        {
	     	cin.clear();
	        cin.ignore(100,'\n');
	        cout<<"Wrong input, minimum amount is 0 kg."<<endl;
	        cout<<"Please enter amount of Polypropylene Fabric(kilogram) :";
	        cin>>Polypropylene_Fabric;
	        }
			cout<<endl;
			//second material
			cout<<"Please enter amount of New Polyester Fiber(kilogram) :";
			cin>>New_Polyester_Fiber;
			while(New_Polyester_Fiber<0||cin.fail())
	        {
	     	cin.clear();
	        cin.ignore(100,'\n');
	        cout<<"Wrong input, minimum amount is 0 kg."<<endl;
	        cout<<"Please enter amount of New Polyester Fiber(kilogram) :";
	        cin>>New_Polyester_Fiber;
	        }
		    cout<<endl;
		    //third material
		    cout<<"Please enter amount of Polymer Coated Fabric(kilogram) :";
		    cin>>Polymer_Coated_Fabric;
		    while(Polymer_Coated_Fabric<0||cin.fail())
	        {
	     	cin.clear();
	        cin.ignore(100,'\n');
	        cout<<"Wrong input, minimum amount is 0 kg."<<endl;
	        cout<<"Please enter amount of Polymer Coated Fabric(kilogram) :";
	        cin>>Polymer_Coated_Fabric;
	        }
		    cout<<endl;
		    //fourth material
		    cout<<"Please enter amount of SMS Nonwovens(kilogram) :";
		    cin>>SMS_Nonwovens;
		    while(SMS_Nonwovens<0||cin.fail())
	        {
	     	cin.clear();
	        cin.ignore(100,'\n');
	        cout<<"Wrong input, minimum amount is 0 kg."<<endl;
	        cout<<"Please enter amount of SMS Nonwovens(kilogram) :";
	        cin>>SMS_Nonwovens;
	        }
		    cout<<endl;
		    //fifth material
		    cout<<"Please enter amount of Polyethylene Breathable Film(kilogram) :";
		    cin>>Polyethylene_Breathable_Film;
		    while(Polyethylene_Breathable_Film<0||cin.fail())
	        {
	     	cin.clear();
	        cin.ignore(100,'\n');
	        cout<<"Wrong input, minimum amount is 0 kg."<<endl;
	        cout<<"Please enter amount of Polyethylene Breathable Film(kilogram) :";
	        cin>>Polyethylene_Breathable_Film;
	        }
		    cout<<"___________________________________________________________________________________________"<<endl;
		    cout<<endl;
		    //choose size
		    cout<<"Please enter the number of size of medical protective clothing."<<endl<<"[1] for S\n[2] for M\n[3] for L\n[4] for XL\n[5] for XXL"<<endl;
		    cin>>choose;
		    while(choose!=1&&choose!=2&&choose!=3&&choose!=4&&choose!=5||cin.fail())
		    {
			cin.clear();
	        cin.ignore(100,'\n');
			cout<<"Wrong input, please enter again."<<endl;
		    cout<<"Please enter the number of size of medical protective clothing."<<endl<<"[1] for S\n[2] for M\n[3] for L\n[4] for XL\n[5] for XXL"<<endl;
		    cin>>choose;
			}
			if (choose==1)
			weight=s;
			else if(choose==2)
			weight=m;
			else if(choose==3)
			weight=l;
			else if(choose==4)
			weight=xl;
			else 
			weight=xxl;
		    count_cloth();
		    }
		    
		    //count cloth amount
		    void count_cloth()
		    {item_count=Polypropylene_Fabric/weight;
		    if(item_count>New_Polyester_Fiber/weight)
		    item_count=New_Polyester_Fiber/weight;
		    if(item_count>Polymer_Coated_Fabric/weight)
		    item_count=Polymer_Coated_Fabric/weight;
		    if(item_count>SMS_Nonwovens/weight)
		    item_count=SMS_Nonwovens/weight;
		    if(item_count>Polyethylene_Breathable_Film/weight)
		    item_count=Polyethylene_Breathable_Film/weight;	   
			}
			
				//count supply
		    void givecounts()
		    {if(item_count/Medical_supplies::getgiveaway()>0)
			{//enough supply
			cout<<"Medical protective cloth per person : "<<(item_count/Medical_supplies::getgiveaway())<<endl;
			cout<<"Medical protective cloth remaining : "<<(item_count%Medical_supplies::getgiveaway())<<endl;
			cout<<"Amount of Polypropylene Fabric remaining :"<<(Polypropylene_Fabric-(item_count*weight))<<" kg"<<endl;
			cout<<"Amount of New Polyester Fiber remaining :"<<(New_Polyester_Fiber-(item_count*weight))<<" kg"<<endl;
			cout<<"Amount of Polymer Coated Fabric remaining :"<<(Polymer_Coated_Fabric-(item_count*weight))<<" k"<<endl;
			cout<<"Amount of SMS Nonwovens remaining :"<<(SMS_Nonwovens-(item_count*weight))<<" kg"<<endl;
			cout<<"Amount of Polyethylene Breathable Film remaining :"<<(Polyethylene_Breathable_Film-(item_count*weight))<<" kg"<<endl;
		    }
		    else
		    {//not enough supply
		    cout<<"Not enough medical protective cloth to supply "<<Medical_supplies::getgiveaway()<<" people with "
			<<item_count<<" medical protective cloth in total."<<endl;
		    cout<<"Amount of Polypropylene Fabric need to add :";
		    if((((Medical_supplies::getgiveaway()-item_count)*weight)-(Polypropylene_Fabric-(item_count*weight)))>0)
		    cout<<((Medical_supplies::getgiveaway()-item_count)*weight)-(Polypropylene_Fabric-(item_count*weight))<<" kg"<<endl;
		    else cout<<"0 kg"<<endl;
		    cout<<"Amount of New Polyester Fiber need to add :";
		    if((((Medical_supplies::getgiveaway()-item_count)*weight)-(New_Polyester_Fiber-(item_count*weight)))>0)
		    cout<<((Medical_supplies::getgiveaway()-item_count)*weight)-(New_Polyester_Fiber-(item_count*weight))<<" kg"<<endl;
		    else cout<<"0 kg"<<endl;
		    cout<<"Amount of Polymer Coated Fabric need to add :";
		    if((((Medical_supplies::getgiveaway()-item_count)*weight)-(Polymer_Coated_Fabric-(item_count*weight)))>0)
		    cout<<((Medical_supplies::getgiveaway()-item_count)*weight)-(Polymer_Coated_Fabric-(item_count*weight))<<" kg"<<endl;
		    else cout<<"0 kg"<<endl;
		    cout<<"Amount of SMS Nonwovens need to add :";
		    if((((Medical_supplies::getgiveaway()-item_count)*weight)-(SMS_Nonwovens-(item_count*weight)))>0)
		    cout<<((Medical_supplies::getgiveaway()-item_count)*weight)-(SMS_Nonwovens-(item_count*weight))<<" kg"<<endl;
		    else cout<<"0 kg"<<endl;
			cout<<"Amount of Polyethylene Breathable Film need to add :";
			if((((Medical_supplies::getgiveaway()-item_count)*weight)-(Polyethylene_Breathable_Film-(item_count*weight)))>0)
		    cout<<((Medical_supplies::getgiveaway()-item_count)*weight)-(Polyethylene_Breathable_Film-(item_count*weight))<<" kg"<<endl;
		    else cout<<"0 kg"<<endl;
		    }
		    cout<<"___________________________________________________________________________________________"<<endl;
			}
	
};

//address part
/////////////////////////
//////////////////////////
////////////////////////////
class Address
{
		private:
			string state;
			string area;
		public :
			Address()		// Constructor
			{
				state ="";
				area = "";
			}
			Address(string a,string b)	//Constructor 
			{
				state = a;
				area = b;
			}
			void setState(string a){state = a;}
			void setArea(string b){area = b;}
			string getState(){return state;}
			string getArea(){return area;}
};

//danger zone part
/////////////////////////
//////////////////////////
////////////////////////////
class DangerZone	
{
		private:
			Address *address;
			string Level;
		public : 
			DangerZone()	// Constructor
			{
				Level = "Green";
			}
			DangerZone(Address *a,string c) //Constructor
			{
				address = a;
				Level =c;
			}
			void setLevel(string _level)	//Mutator
			{
				Level = _level;
			}
			void setAddress(string a,string b)	//Mutator
			{
				address = new Address(a,b);
			}
			string getLevel()	//Accesor
			{
				return Level;
			}
			
			void NewZone()	//  add new Danger area 
			{
				system ("cls");
				int choose,c;
				string _area,_state;
				bool flag = true;
				
				//Display all state for selection
				cout << "Please select the state " <<endl;
				cout << "which state do you want to choose : " <<endl;
				cout << "[1] Johor"<<endl;
				cout << "[2] Kedah " <<endl;
				cout << "[3] Kelantan " <<endl;
				cout << "[4] Malacca" <<endl;
				cout << "[5] Negeri Sembilan " <<endl; 
				cout << "[6] Pahang" <<endl;
				cout << "[7] Penang" <<endl;
				cout << "[8] Perak" <<endl;
				cout << "[9] Perlis" <<endl;
				cout << "[10] Sabah " <<endl;
				cout << "[11] Sarawak" <<endl;
				cout << "[12] Selangor" <<endl;
				cout <<	"[13] Terengganu " <<endl;
				
				//check whether the input is between 1-13
			 	do{
					cout << "Option :";	
					cin >> choose;
						if(choose<1||choose >13||isalpha(choose))
						{
						cin.clear();
						cin.ignore();
						cout<<"Wrong input, please enter again."<<endl;
						}
				}while(choose<1||choose >13||isalpha(choose));
				cin.ignore();
					 
					 
					 //Select the state to add
					 if (choose ==1 )
					 {
					 	_state = "Johor";
					 	
					 }
					 else if(choose ==2)
					 {
					 	_state ="Kedah";
					 	
					 }
					 else if(choose == 3)
					 {
					 	_state ="Kelantan";
					 	
					 }
					 else if(choose ==4)
					 {
					 	_state ="Malacca";
					 	
					 }
					 else if(choose ==5)
					 {
					 	_state ="Negeri Sembilan";
					 	
					 }
					 else if(choose == 6)
					 {
					 	_state ="Pahang";
					 	
					 }
					 else if(choose == 7)
					 {
					 	_state ="Penang";
					 	
					 }
					 else if(choose == 8)
					 {
					 	_state ="Perak";
					 	
					 }
					 else if(choose == 9)
					 {
					 	_state ="Perlis";
					 	
					 }
					 else if(choose == 10)
					 {
					 	_state ="Sabah";
					 	
					 }
					 else if(choose == 11)
					 {
					 	_state ="Sarawak";
					 	
					 }
					 else if(choose == 12)
					 {
					 	_state ="Selangor";
					 	
					 }
					 else if(choose == 13)
					 {
					 	_state ="Terengganu";
					 	
					 }
					 
					 
					 // Enter the name of the state
					 cout << "Please enter the name of state's area : ";
					 
					 getline(cin,_area);
					 
					 
					 //Enter the danger level of the area
					cout << "What is the danger level :"<<endl
						 << "[1] Red " <<endl
						 << "[2] Yellow " <<endl
						 << "[3] Green" <<endl;
						 
						 cout << "Option :";
						 cin >> c;
						 if(c == 1)
						 {
						 	Level = "Red";
						 }
						 else if(c == 2)
						 {
						 	Level="Yellow";
						 }
						 else if(c==3)
						 {
						 	Level ="Green";
						 }
						 
						 
						 
						 //set the input
						 setAddress(_state,_area);
						 setLevel(Level);
			
			}
			friend void sortZone(int size, DangerZone *p)	// sort the DangerZone
			{
				string _state[size];
				string _area[size];
				string _dangerlevel[size];
				string _statetemp[size];
				string _areatemp[size];
				string _dangerleveltemp[size];
				int count=0;
				
				for(int i =0;i<size;i++)//copy state,area,dangerlevel to another variable
				{
					_state[i].assign(p[i].address->getState());
					_area[i]=p[i].address->getArea();
					_dangerlevel[i] = p[i].getLevel();
				} 
				
				
				for(int i=0;i<size;i++)	//sort Johor
				{
					if(_state[i]=="Johor")
					{
						_statetemp[count] = _state[i];
						_areatemp[count] = _area[i];
						_dangerleveltemp[count] = _dangerlevel[i];
						count +=1;
					}
				}
				
				for(int i=0;i<size;i++)	//sort Kedah
				{
					if(_state[i] == "Kedah")
					{
						
						_statetemp[count] = _state[i];
						_areatemp[count] = _area[i];
						_dangerleveltemp[count] = _dangerlevel[i];
						count +=1;
						
					}
				}
				for(int i =0 ;i<size ;i++)//sort Kelantan
				{
					if(_state[i] == "Kelantan")
					{
						_statetemp[count] = _state[i];
						_areatemp[count] = _area[i];
						_dangerleveltemp[count] = _dangerlevel[i];
						count +=1;
					}
				}
					for(int i =0 ;i<size ;i++)//sort Malacca
				{
					if(_state[i] == "Malacca")
					{
						_statetemp[count] = _state[i];
						_areatemp[count] = _area[i];
						_dangerleveltemp[count] = _dangerlevel[i];
						count +=1;
					}
				}
					for(int i =0 ;i<size ;i++)//sort Negeri Sembilan
				{
					if(_state[i] == "Negeri Sembilan")
					{
						_statetemp[count] = _state[i];
						_areatemp[count] = _area[i];
						_dangerleveltemp[count] = _dangerlevel[i];
						count +=1;
					}
				}
				for(int i =0 ;i<size ;i++)//sort Pahang
				{
					if(_state[i] == "Pahang")
					{
						_statetemp[count] = _state[i];
						_areatemp[count] = _area[i];
						_dangerleveltemp[count] = _dangerlevel[i];
						count +=1;
					}
				}
				for(int i =0 ;i<size ;i++)//sort Penang
				{
					if(_state[i] == "Penang")
					{
						_statetemp[count] = _state[i];
						_areatemp[count] = _area[i];
						_dangerleveltemp[count] = _dangerlevel[i];
						count +=1;
					}
				}
				for(int i =0 ;i<size ;i++)//sort Perak
				{
					if(_state[i] == "Perak")
					{
						_statetemp[count] = _state[i];
						_areatemp[count] = _area[i];
						_dangerleveltemp[count] = _dangerlevel[i];
						count +=1;
					}
				}
				for(int i =0;i<size ;i++)//sort Perlis
				{
					if(_state[i] == "Perlis")
					{
						_statetemp[count] = _state[i];
						_areatemp[count] = _area[i];
						_dangerleveltemp[count] = _dangerlevel[i];
						count +=1;
					}
				}
				for(int i =0 ;i<size ;i++)//sort Perlis
				{
					if(_state[i] == "Sabah")
					{
						_statetemp[count] = _state[i];
						_areatemp[count] = _area[i];
						_dangerleveltemp[count] = _dangerlevel[i];
						count +=1;
					}
				}
				for(int i =0;i<size ;i++)//sort Sarawak
				{
					if(_state[i] == "Sarawak")
					{
						_statetemp[count] = _state[i];
						_areatemp[count] = _area[i];
						_dangerleveltemp[count] = _dangerlevel[i];
						count +=1;
					}
				}
				for(int i =0 ;i<size ;i++)//sort Selangor
				{
					if(_state[i] == "Selangor")
					{
						_statetemp[count] = _state[i];
						_areatemp[count] = _area[i];
						_dangerleveltemp[count] = _dangerlevel[i];
						count +=1;
					}
				}
				for(int i =0 ;i<size ;i++)//sort Terrenganu
				{
					if(_state[i] == "Terengganu")
					{
						_statetemp[count] = _state[i];
						_areatemp[count] = _area[i];
						_dangerleveltemp[count] = _dangerlevel[i];
						count +=1;
					}
				}
				
				
				for(int i=0;i<size;i++) // after sort assign back the sorted array to initial variable
				{
					p[i].setAddress(_statetemp[i],_areatemp[i] );
					p[i].setLevel(_dangerleveltemp[i]);
				}
				
			}
			friend void UpdateZone(int size,DangerZone *p)	//update existing Danger Zone
			{
				string _state[size];
				string _area[size];
				string _dangerlevel[size];
				string chooseArea;
				int chooseLevel;
				int choose;
				bool check=true;
				int count ;
				// Copy the values to another variable
				for(int i =0;i<size;i++)
				{
					_state[i].assign(p[i].address->getState());
					_area[i]=p[i].address->getArea();
					_dangerlevel[i] = p[i].getLevel();
				} 
				cout << endl;
				cout << "which state do you want to choose : " <<endl;	//Get the state
				cout << "[1] Johor"<<endl;
				cout << "[2] Kedah " <<endl;
				cout << "[3] Kelantan " <<endl;
				cout << "[4] Malacca" <<endl;
				cout << "[5] Negeri Sembilan " <<endl; 
				cout << "[6] Pahang" <<endl;
				cout << "[7] Penang" <<endl;
				cout << "[8] Perak" <<endl;
				cout << "[9] Perlis" <<endl;
				cout << "[10] Sabah " <<endl;
				cout << "[11] Sarawak" <<endl;
				cout << "[12] Selangor" <<endl;
				cout <<	"[13] Terengganu " <<endl;
				
			//Check whether the input is between 1 and 13	
			do{
					cout << "Option :";	
					cin >> choose;
						if(choose<1||choose >13||isalpha(choose))
						{
						cin.clear();
						cin.ignore();
						cout<<"Wrong input, please enter again."<<endl;
						}
				}while(choose<1||choose >13||isalpha(choose));
				cin.ignore();
				
				// These function will display the selected state's area only
				if(choose == 1)
				{
					system ("cls");
					cout <<setw(30)<<left << "State" << setw(30) << left<< "Area" << setw(30) <<left << "Danger Level"<<endl;
					cout <<"_______________________________________________________________________"<<endl;
					for(int i=0;i<size;i++)
					{
						if(_state[i]=="Johor")
						{
							cout << p[i]<<endl;
						}
					}
					
				}
				else if(choose ==2)
				{
					system ("cls");
					cout <<setw(30)<<left << "State" << setw(30) << left<< "Area" << setw(30) <<left << "Danger Level"<<endl;
					cout <<"_______________________________________________________________________"<<endl;
					for(int i=0;i<size;i++)
					{
						if(_state[i]=="Kedah")
						{
							cout << p[i]<<endl;
						}
					}
				}
				else if(choose==3)
				{
						system ("cls");
					cout <<setw(30)<<left << "State" << setw(30) << left<< "Area" << setw(30) <<left << "Danger Level"<<endl;
					cout <<"_______________________________________________________________________"<<endl;
					for(int i=0;i<size;i++)
					{
						if(_state[i]=="Kelantan")
						{
							cout << p[i]<<endl;
						}
					}
				}
				else if(choose ==4 )
				{
						system ("cls");
					cout <<setw(30)<<left << "State" << setw(30) << left<< "Area" << setw(30) <<left << "Danger Level"<<endl;
					cout <<"_______________________________________________________________________"<<endl;
					for(int i=0;i<size;i++)
					{
						if(_state[i]=="Malacca")
						{
							cout << p[i]<<endl;
						}
					}
				}
				else if(choose==5)
				{
						system ("cls");
					cout <<setw(30)<<left << "State" << setw(30) << left<< "Area" << setw(30) <<left << "Danger Level"<<endl;
					cout <<"_______________________________________________________________________"<<endl;
					for(int i=0;i<size;i++)
					{
						if(_state[i]=="Negeri Sembilan")
						{
							cout << p[i]<<endl;
						}
					}
				}
				else if(choose==6)
				{
						system ("cls");
					cout <<setw(30)<<left << "State" << setw(30) << left<< "Area" << setw(30) <<left << "Danger Level"<<endl;
					cout <<"_______________________________________________________________________"<<endl;
					for(int i=0;i<size;i++)
					{
						if(_state[i]=="Pahang")
						{
							cout << p[i]<<endl;
						}
					}
				}
				else if(choose==7)
				{
						system ("cls");
					cout <<setw(30)<<left << "State" << setw(30) << left<< "Area" << setw(30) <<left << "Danger Level"<<endl;
					cout <<"_______________________________________________________________________"<<endl;
					for(int i=0;i<size;i++)
					{
						if(_state[i]=="Penang")
						{
							cout << p[i]<<endl;
						}
					}
				}
				else if(choose ==8)
				{
					system ("cls");
					cout <<setw(30)<<left << "State" << setw(30) << left<< "Area" << setw(30) <<left << "Danger Level"<<endl;
					cout <<"_______________________________________________________________________"<<endl;
					for(int i=0;i<size;i++)
					{
						if(_state[i]=="Perak")
						{
							cout << p[i]<<endl;
						}
					}
				}
				else if(choose ==9)
				{
						system ("cls");
					cout <<setw(30)<<left << "State" << setw(30) << left<< "Area" << setw(30) <<left << "Danger Level"<<endl;
					cout <<"_______________________________________________________________________"<<endl;
					for(int i=0;i<size;i++)
					{
						if(_state[i]=="Perlis")
						{
							cout << p[i]<<endl;
						}
					}
				}
				else if(choose ==10)
				{
					system ("cls");
					cout <<setw(30)<<left << "State" << setw(30) << left<< "Area" << setw(30) <<left << "Danger Level"<<endl;
					cout <<"_______________________________________________________________________"<<endl;
					for(int i=0;i<size;i++)
					{
						if(_state[i]=="Sabah")
						{
							cout << p[i]<<endl;
						}
					}
				}
				else if(choose ==11)
				{
						system ("cls");
					cout <<setw(30)<<left << "State" << setw(30) << left<< "Area" << setw(30) <<left << "Danger Level"<<endl;
					cout <<"_______________________________________________________________________"<<endl;
					for(int i=0;i<size;i++)
					{
						if(_state[i]=="Sarawak")
						{
							cout << p[i]<<endl;
						}
					}
				}
				else if(choose ==12)
				{
						system ("cls");
					cout <<setw(30)<<left << "State" << setw(30) << left<< "Area" << setw(30) <<left << "Danger Level"<<endl;
					cout <<"_______________________________________________________________________"<<endl;
					for(int i=0;i<size;i++)
					{
						if(_state[i]=="Selangor")
						{
							cout << p[i]<<endl;
						}
					}
				}
				else if(choose == 13)
				{
						system ("cls");
					cout <<setw(30)<<left << "State" << setw(30) << left<< "Area" << setw(30) <<left << "Danger Level"<<endl;
					cout <<"_______________________________________________________________________"<<endl;
					for(int i=0;i<size;i++)
					{
						if(_state[i]=="Terengganu")
						{
							cout << p[i]<<endl;
						}
					}
				}
				
					// Get the area 
					cout << "\nWhich area do you want to change (please write the area as output displayed ): ";
					
					getline(cin,chooseArea);
					
					
					while(check)	// Check whether the area exist, if not user need to re-input
					{
						for(int i=0;i<size;i++)
						{
							if (chooseArea==_area[i])
							{
								check = false;
							}
						}
						if(check == true)
						{
							cout << "Invalid area,please try again : ";
							getline(cin,chooseArea);
						}
					}
					
					
					
					
					
					cout << endl;
					// Set the new danger level
					for(int i =0;i<size;i++)
					{
						if(_area[i] == chooseArea)
						{
							cout << "Previous danger level is :" << _dangerlevel[i] <<endl;
							cout << "Please choose new danger level :"<<endl;
							cout << "[1] Red" <<endl;
							cout << "[2] Yellow" <<endl;
							cout << "[3] Green" <<endl;
							cout << "Option : " ;
							cin >> chooseLevel;
							if(chooseLevel==1)
							{
								p[i].setLevel("Red");
							}
							if (chooseLevel ==2)
							{
								p[i].setLevel("Yellow");
							}
							if(chooseLevel ==3)
							{
								p[i].setLevel("Green");
							}
						}
						
						
					}
				
				
			}
			
			friend ifstream &operator>>(ifstream &fin, DangerZone &x) //get the value from file
			{
				string temp,temp2,temp3,_state,_zone,_dangerlevel;
						getline(fin,temp);	// Get the whole line. eg : Johor,Skudai:Yellow 
						
						temp2=temp.substr(temp.find(',')+1);	//Take the string after ','  eg:  Skudai:yellow
						temp3=temp.substr(temp.find(':')+1);	//Take the string after ':'  eg:  yellow
						
						
						_zone = temp2;
						_state = temp;
						
						temp2 = _zone.substr(0,_zone.find(':'));	//Take the stirng until it meet ':'   eg:  Skudai:yellow -> Skudai
						temp = _state.substr(0,_state.find(','));	//Take the string until it meet ','   eg:  Johor,Skudai:yellow -> Johor
						
						_state=temp;
						_zone = temp2;
						_dangerlevel = temp3;
						x.setAddress(_state,_zone);		
						
						x.setLevel(_dangerlevel);

						
						return fin;
						
			}
			
			friend int readZone(DangerZone *x)	// Read data in "DangerZone.txt"
			{
				
				
				ifstream infile;
				infile.open("DangerZone.txt");
				
				if(infile.is_open())
				{
					int count =0;
					
					while(!infile.eof())
					{
						infile >> x[count];
						count ++;
					}
					infile.close();
					return count;
					
				}
				else
				cout << "unable to open file"<<endl;
			}
			friend ostream &operator << (ostream& fout,DangerZone &x)	//operator << to display the state, area and danger level
			{
				
				
				fout <<setw(30)<<left<< x.address->getState()<<setw(30)<<left <<x.address->getArea()<<setw(30)<<left<<x.getLevel();
				return fout;
			
			}
			friend void display(int _count,DangerZone *x)	//Display the state,area and danger level and save it to the file for future use
			{
				
				cout <<setw(30)<<left << "State" << setw(30) << left<< "Area" << setw(30) <<left << "Danger Level"<<endl;
				cout <<"_______________________________________________________________________"<<endl;
				for(int i=0;i<_count;i++)
				{
					cout << x[i]<<endl;
				}
				
				ofstream outfile ;
				outfile.open("DangerZone.txt");
				
				if(outfile.is_open())
				{
				
				for(int i=0;i<_count;i++)
				{
					if(i<_count-1)
						outfile  << x[i].address->getState()<<","<<x[i].address->getArea()<<":"<<x[i].getLevel()<<endl;
					else
						outfile  << x[i].address->getState()<<","<<x[i].address->getArea()<<":"<<x[i].getLevel();
					
				} 
				}
				else
					cout << "Unable to save" <<endl;
				outfile.close();
			}
};

class ScreeningCentre{
		private:
			int state;
			string area;
			string hospital;
		public :
			ScreeningCentre()	//Constructor
			{
				state	= 1;
				area = "";
				hospital = "";
			}
			ScreeningCentre(int s, string a, string h)	//Constructor
			{
				state	= s;
				area = a;
				hospital = h;
			}
			void setHospital(string h){hospital=h;}	//Mutator
			string getHospital(){return hospital;}	// Accessor
			void checkSC(){	// Get the person's living state 
				cout<<"Please provide your current living State :\n";
				cout << "[1] Johor"<<endl;
				cout << "[2] Kedah " <<endl;
				cout << "[3] Kelantan " <<endl;
				cout << "[4] Malacca" <<endl;
				cout << "[5] Negeri Sembilan " <<endl; 
				cout << "[6] Pahang" <<endl;
				cout << "[7] Penang" <<endl;
				cout << "[8] Perak" <<endl;
				cout << "[9] Perlis" <<endl;
				cout << "[10] Sabah " <<endl;
				cout << "[11] Sarawak" <<endl;
				cout << "[12] Selangor" <<endl;
				cout <<	"[13] Terrengganu " <<endl;
				cout << "Option : " ;
				do{cin>>state;}while(state<1&&state>13);cin.ignore();	// Check whether the input is between 1-13
				if(state!=4&&state!=6&&state!=7&&state!=9&&state!=12&&state!=13){	// Get the area of selected state. Some state only have 1 hospital so not required to get area.
				cout<<"Please provide your current living Area (Eg:Tawau) :";getline(cin,area);
				}
				// Search for the area and display the respective hospital based on area
				if(state==1)	//State : johor
				{bool areas=true;
				while(areas)
				{
					if(area=="Kluang")
					{
						hospital="Hospital Enche Besar Hajjah Kalsom";
						cout<<"You have a risk to be infected, please go "<<hospital<<" to do screening test and quarantine.\n";
						areas=false;
					}
					else if(area=="Permai")
					{
						hospital="Hospital Permai";
						cout<<"You have a risk to be infected, please go "<<hospital<<" to do screening test and quarantine.\n";
						areas=false;
					}
					else if(area=="Johor Bahru")
					{
						hospital="Hospital Sultanah Aminah";
						cout<<"You have a risk to be infected, please go "<<hospital<<" to do screening test and quarantine.\n";
						areas=false;
					}
					else
					{cout<<"Please provide true area.(Eg:Kluang,Permai,Johor Bahru) :";
					getline(cin,area);
					areas=true;
					}
					}
				}
				else if(state==2)	//State : Kedah
				{bool areas=true;
				while(areas)
				{
					if(area=="Alor Setar")
					{
						hospital="Hospital Sultanah Bahiyah";
						cout<<"You have a risk to be infected, please go "<<hospital<<" to do screening test and quarantine.\n";
						areas=false;
					}
					else if(area=="Langkawi")
					{
						hospital="Hospital Sultanah Maliha";
						cout<<"You have a risk to be infected, please go "<<hospital<<" to do screening test and quarantine.\n";
						areas=false;
					}
					else
					{cout<<"Please provide true area.(Eg:Alor Setar,Langkawi) :";
					getline(cin,area);
					areas=true;
					}
					}
				}
				else if(state==3)	//State : Kelantan
				{
					bool areas=true;
				while(areas)
				{
					if(area=="Kota Bharu")
					{
						hospital="Hospital Raja Perempuan Zainab II";
						cout<<"You have a risk to be infected, please go "<<hospital<<" to do screening test and quarantine.\n";
						areas=false;
					}
					else if(area=="Kuala Krai")
					{
						hospital="Hospital Kuala Krai";
						cout<<"You have a risk to be infected, please go "<<hospital<<" to do screening test and quarantine.\n";
						areas=false;
					}
					else if(area=="Tumpat")
					{
						hospital="Hospital Tumpat";
						cout<<"You have a risk to be infected, please go "<<hospital<<" to do screening test and quarantine.\n";
						areas=false;
					}
					else
					{cout<<"Please provide true area.(Eg:Kota Bharu,Kuala Krai,Tumpat) :";
					getline(cin,area);
					areas=true;
					}
					}
				}
				else if(state==4)	//State : Malacca
				{
					hospital="Hospital Melaka";
					cout<<"You have a risk to be infected, please go "<<hospital<<" to do screening test and quarantine.\n";
				}
				else if(state==5) // State : Negeri Sembilan
				{bool areas=true;
				while(areas)
				{
					if(area=="Seremban")
					{
						hospital="Hospital Tuanku Jaafar";
						cout<<"You have a risk to be infected, please go "<<hospital<<" to do screening test and quarantine.\n";
						areas=false;
					}
					else if(area=="Rembau")
					{
						hospital="Hospital Rembau";
						cout<<"You have a risk to be infected, please go "<<hospital<<" to do screening test and quarantine.\n";
						areas=false;
					}
					else
					{cout<<"Please provide true area.(Eg:Seremban,Rembau) :";
					getline(cin,area);
					areas=true;
					}
				}
				}
				else if(state==6)	// State : Pahang
				{
					hospital="Hospital Tengku Ampuan Afzan";
					cout<<"You have a risk to be infected, please go "<<hospital<<" to do screening test and quarantine.\n";
				}
				else if(state==7)	//State :Penang
				{
					hospital="Hospital Pulau Pinang";
					cout<<"You have a risk to be infected, please go "<<hospital<<" to do screening test and quarantine.\n";
				}
			
				else if(state==8)	//State : Perak
				{bool areas=true;
				while(areas)
				{
					if(area=="Ipoh")
					{
						hospital="Hospital Raja Permaisuri Bainun";
						cout<<"You have a risk to be infected, please go "<<hospital<<" to do screening test and quarantine.\n";
						areas=false;
					}
					else if(area=="Teluk Intan")
					{
						hospital="Hospital Teluk Intan";
						cout<<"You have a risk to be infected, please go "<<hospital<<" to do screening test and quarantine.\n";
						areas=false;
					}
					else if(area=="Slim River")
					{
						hospital="Hospital Slim River";
						cout<<"You have a risk to be infected, please go "<<hospital<<" to do screening test and quarantine.\n";
						areas=false;
					}
					else
					{cout<<"Please provide true area.(Eg:Ipoh,Teluk Intan,Slim River) :";
					getline(cin,area);
					areas=true;
					}
				}
				}
				else if(state==9)	//State : Perlis
				{
					hospital="Hospital Tuanku Fauziah";
					cout<<"You have a risk to be infected, please go "<<hospital<<" to do screening test and quarantine.\n";
				}
				else if(state==10)	//State : Sabah
				{bool areas=true;
				while(areas)
				{
					if(area=="Kota Kinabalu")
					{
						hospital="Hospital Queen Elizabeth I";
						cout<<"You have a risk to be infected, please go "<<hospital<<" to do screening test and quarantine.\n";
						areas=false;
					}
					else if(area=="Sandakan")
					{
						hospital="Hospital Duchess Of Kent";
						cout<<"You have a risk to be infected, please go "<<hospital<<" to do screening test and quarantine.\n";
						areas=false;
					}
					else if(area=="Tawau")
					{
						hospital="Hospital Tawau";
						cout<<"You have a risk to be infected, please go "<<hospital<<" to do screening test and quarantine.\n";
						areas=false;
					}
					else if(area=="Likas")
					{
						hospital="Hospital Wanita dan Kanak-kanak";
						cout<<"You have a risk to be infected, please go "<<hospital<<" to do screening test and quarantine.\n";
						areas=false;
					}
					else if(area=="Lahad Datu")
					{
						hospital="Hospital Lahad Datu";
						cout<<"You have a risk to be infected, please go "<<hospital<<" to do screening test and quarantine.\n";
						areas=false;
					}
					else if(area=="Keningau")
					{
						hospital="Hospital Keningau";
						cout<<"You have a risk to be infected, please go "<<hospital<<" to do screening test and quarantine.\n";
						areas=false;
					}
					else
					{cout<<"Please provide true area.(Eg:Sandakan,Kota Kinabalu,Tawau,Likas,Lahad Datu,Keningau) :";
					getline(cin,area);
					areas=true;
					}
				}
				}
				else if(state==11)	//State : Sarawak
				{bool areas=true;
				while(areas)
				{
					if(area=="Kuching")
					{
						hospital="Hospital Umum Sarawak";
						cout<<"You have a risk to be infected, please go "<<hospital<<" to do screening test and quarantine.\n";
						areas=false;
					}
					else if(area=="Miri")
					{
						hospital="Hospital Miri";
						cout<<"You have a risk to be infected, please go "<<hospital<<" to do screening test and quarantine.\n";
						areas=false;
					}
					else if(area=="Bintulu")
					{
						hospital="Hospital Bintulu";
						cout<<"You have a risk to be infected, please go "<<hospital<<" to do screening test and quarantine.\n";
						areas=false;
					}
					else if(area=="Sibu")
					{
						hospital="Hospital Sibu";
						cout<<"You have a risk to be infected, please go "<<hospital<<" to do screening test and quarantine.\n";
						areas=false;
					}
					else
					{cout<<"Please provide true area.(Eg:Kuching,Miri,Bintulu,Sibu) :";
					getline(cin,area);
					areas=true;
					}
				}
				}
				else if(state==12)	//State :  Selangor
				{
					hospital="Hospital Sungai Buloh";
					cout<<"You have a risk to be infected, please go "<<hospital<<" to do screening test and quarantine.\n";
				}
				else if(state==13)	// State : Terengganu
				{
						hospital="Hospital Sultanah Nur Zahirah";
						cout<<"You have a risk to be infected, please go "<<hospital<<" to do screening test and quarantine.\n";
				}
			}
};

class Symptoms{
	private:
		char flu;
		char cough;
		char shortbreath;
		double temperature;
		char closecontact;
		char travel;
		int probability_infected;
	public:
		Symptoms()	// Constructor
		{flu='N';cough='N';shortbreath='N';temperature=36.5;
		closecontact='N';travel='N';probability_infected='N';}
		void setsymptoms(char f,char c, char s, double t, char cc, char tr)	//Mutator
		{ 
			int i=0;
			if(f=='Y'||f=='y') i++;
			if(c=='Y'||c=='y') i++;
			if(s=='Y'||s=='y') i++;
			if(t>37.5) i++;
			if(cc=='Y'||cc=='y') i++;
			if(t=='Y'||t=='y')i++;
			probability_infected = i;
		}
		bool check_probability_infected()	// Check the probability of covid infected
		{
			char f ,c, s, cc, tr;
			double t;
			cout << "\nWhat is your temperature? : ";
			do {
				cin.clear();
				cin.ignore();
				cin>>t;
			}while (t<30&&t>50||cin.fail());
			cout << "\nDo you experience flu recently? [Y/N] :";do{cin>>f;}while(f!='Y'&&f!='y'&&f!='Y'&&f!='N'&&f!='n');
			cout << "\nDo you experience coughing recently? [Y/N] :";do{cin>>c;}while(c!='Y'&&c!='y'&&c!='Y'&&c!='N'&&c!='n');
			cout << "\nDo you recently have shortness of breath? [Y/N] :";do{cin>>s;}while(s!='Y'&&s!='y'&&s!='Y'&&s!='N'&&s!='n');
			cout << "\nDo you have close contact with Covid-19 infector? [Y/N] :";do{cin>>cc;}while(cc!='Y'&&cc!='y'&&cc!='Y'&&cc!='N'&&cc!='n');
			cout << "\nHave you traveled oversea recently? [Y/N] :";do{cin>>tr;}while(tr!='Y'&&tr!='y'&&tr!='Y'&&tr!='N'&&tr!='n');
			setsymptoms(f,c,s,t,cc,tr);
			if(probability_infected>=3)	// Potential infection when 3 out of 5 show symptoms
			{
				return true;
			}
			else 
			{
				return false;
			}
		}
};

class People{
	private:
		string name;
		string NRIC;
		ScreeningCentre *SC;
		Symptoms *ST; 
	public:
		People(){		//Constructor
			name=""; NRIC=""; 
		}
		People(string n, string i, ScreeningCentre *s){	//Constructor
			name=n; NRIC=i; SC=s;}
		void setName(string n){name = n;}	//Mutator
		void setNRIC(string n){NRIC = n;}	//Mutator
		void setSC(ScreeningCentre *sc){SC = sc;}	//Mutator
		void setST(Symptoms *st){ST=st;}	//Mutator
		string getName(){return name;}		//Accessor
		string getNRIC(){return NRIC;}		//Accessor
		string getSC(){SC->getHospital();}	//Accessor
		friend ifstream &operator>>(ifstream &fin, People &x)	//operator >> to read the file 
		{
				string temp,temp2,temp3,_name,_NRIC,_hospital;	//Get the whole line eg: Ali:000212123366;Hospital Abc
				getline(fin,temp);
						
				temp2=temp.substr(temp.find(':')+1);	// get the string after ':' eg : 000212123366;Hospital Abc
				temp3=temp.substr(temp.find(';')+1);	// get the string after ';' eg : Hospital Abc
						
				_name = temp;
				_NRIC = temp2;
						
				temp2 = _NRIC.substr(0,_NRIC.find(';'));	//get string until ';'  eg : 000212123366;Hospital Abc -> 000212123366
				temp = _name.substr(0,_name.find(':'));		// get string until ':' eg : Ali:000212123366;Hospital Abc -> Ali
						
				_name=temp;
				_NRIC = temp2;
				_hospital = temp3;
				x.setName(_name);
				
				x.setNRIC(_NRIC);
				
				ScreeningCentre *src=new ScreeningCentre;
				src->setHospital(_hospital);
				x.setSC(src);
			    
			
				return fin;
						
		}
		friend int readPeople(People *p)	//Read the text file 
		{				
				ifstream infile1;
				infile1.open("quarantinelist.txt");
				
				if(infile1.is_open())
				{
					int count =0;
					
					while(!infile1.eof())
					{
						infile1 >> p[count];
						count ++;
					}
					infile1.close();
					return count;
					
				}
				else
				{
					cout << "Unable to open file!"<<endl;
					return 0;
				}
					
		}
		friend ostream &operator << (ostream& fout,People &x) //Operator << to display the name,NRIC and hospital 
			{
				
			
				fout <<setw(35)<<left<< x.getName()<<setw(25)<<left <<x.getNRIC()<<setw(30)<<left<<x.SC->getHospital();
				return fout;
			
			}
		friend void displayql(int _count,People *x)		// Function to save the name to the file
		{
				cout <<setw(35)<<left << "Name" << setw(25) << left<< "NRIC" << setw(30) <<left << "Quarantine Place"<<endl;
				cout <<"___________________________________________________________________________________-"<<endl;
				for(int i=0;i<_count;i++)
				{
					cout << x[i]<<endl;
				}
				
				ofstream outfile1 ;
				outfile1.open("quarantinelist.txt");
				
				if(outfile1.is_open())
				{
				
				for(int i=0;i<_count;i++)
				{
					if(i<_count-1)
						outfile1  << x[i].getName()<<":"<<x[i].getNRIC()<<";"<<x[i].SC->getHospital()<<endl;
					else
						outfile1  << x[i].getName()<<":"<<x[i].getNRIC()<<";"<<x[i].SC->getHospital();
				}
				}
				else
					cout << "Unable to save" <<endl;
				outfile1.close();
		}
		friend void writeout(int _count,People *x)
		{
				ofstream outfile1 ;
				outfile1.open("quarantinelist.txt");
				
				if(outfile1.is_open())
				{
				
					for(int i=0;i<_count;i++)
					{
						if(i<_count-1)
							outfile1  << x[i].getName()<<":"<<x[i].getNRIC()<<";"<<x[i].SC->getHospital()<<endl;
						else
							outfile1  << x[i].getName()<<":"<<x[i].getNRIC()<<";"<<x[i].SC->getHospital();
					} 
				}
				else
					cout << "Unable to save" <<endl;
				outfile1.close();
		}
};

int main()
{
	int option=0;
	bool flag = true;
	bool flag2=true;
	int i=-1;
	Symptoms symptoms;
	ScreeningCentre *sc=new ScreeningCentre[500];
	string ic;
	string username;
	string password; 
	string hospital;
	People people[500];
	int ppl_no;
	int choose;
	ifstream infile("DangerZone.txt");
//main system
	int size;
	char cont;
	cout << "\n-----Welcome to Movement Control Order (MCO) and Quarantine System of Country-----"<<endl;
	cout << "Who are you?\n";
	cout << "[1] Admin" <<endl;
	cout << "[2] User " <<endl;
	
	do{//get option
		cout << "Option : ";	
		cin >> option;
		if(option!=1&&option!=2||isalpha(option)||cin.fail())
		{
			cin.clear();
			cin.ignore();
			cout<<"Wrong input, please enter again."<<endl;
		}
	}while(option!=1&&option!=2||isalpha(option)||cin.fail());
	cin.ignore();

	do//option 1
	{
	if(option == 1)
	{  int trys=0;//Admin input name and password system
		cout << "\nAdmin Username : ";
		getline(cin,username) ;
		if(username!="admin")
		{
	     cout<<"Invalid Username :";	
     	}
     	if(username=="admin")
     	{
		cout << "Password : ";
		getline(cin,password);
		if( password != "admin1100")
		{   while(trys<2)
		{
		cout << "Invalid Password!" <<endl;
		trys++;
		cout<<"You have "<<3-trys<<" chance left."<<endl;
		cout << "Password : ";
		getline(cin,password);
		}
		}	
		}
		if(username=="admin"&&password=="admin1100")
			flag = false;
			else flag= true;
	}
	//option 2
	else if(option ==2)
	{//user input name and IC system
		cout << "\nUsername : " ;
		getline(cin,username);
		cout << "NRIC : " ;
		getline(cin,ic);
		
		int length = ic.length();
		if(length ==12)
		{
			string month=ic.substr(2, 2);
			int month1 = stoi(month);
			
			string day=ic.substr(4, 2);
			int day1 = stoi(day);
			if(month1<1||month1>12)
				cout <<"Invalid Login!" <<endl;
			else if (day1<1||day1>31)
				cout <<"Invalid Login!" <<endl;
			else{
				cout << "Login Successful!"<<endl;
				flag =false;
			}
			
		}
		else
		{
			cout <<"Invalid Login!" <<endl;
		}
	}
	}while(flag);
	//after input option 1 success
	if(option ==1 )
	{
		flag = true;
		do {
		//admin system
		cout<<"\n*****Movement Control Order (MCO) and quarantine system of country*****\n"<<endl
			<<"Options :"<<endl
			<<"[1] Tracking the number of medical supply for Malaysian"<<endl
			<<"[2] Update  the danger level of each zone"<<endl
			<<"[3] Exit\n";
        //get admin option
		cout << "Options : ";
		cin >> choose;
		while(choose!=1&&choose!=2&&choose!=3||cin.fail())
		{
			cin.clear();
			cin.ignore();
			cout<<"Wrong input, please enter again."<<endl;
			cout<<"Options : ";
			cin>>choose;
		}
		//option 1
		if(choose ==1)
		{
			Medical_supplies *m[4];
			Mask mask;
			handsanitizer hand;
			Medical_protective_clothing cloth;
			m[1]=&mask;
			m[2]=&hand;
			m[3]=&cloth;
			int count;
			int chooses=0;
			char choose='Y';
			while(choose=='Y')
			{//tracking number of supply system
				system("CLS");
				cout<<"\nPlease choose the medical supply calculate system"<<endl
					<<"[1] For face mask calculation"<<endl
					<<"[2] For hand sanitizer calculation"<<endl
					<<"[3] For medical protective clothing calculation"<<endl
					<<"Option : ";
				cin>>chooses;
				while(chooses<1||chooses>3||cin.fail())
				{	system("CLS");
				    cin.clear();
				    cin.ignore();
				    cout<<"Wrong input, please enter again."<<endl;
					cout<<"Please choose the calculate system"<<endl
						<<"[1] For mask calculation"<<endl
						<<"[2] For hand sanitizer calculation"<<endl
						<<"[3] For medical protective clothing calculation"<<endl;
					cout<<"Option : ";
					cin>>chooses;
				}//get calculate system option
			while (choose=='Y')
				{m[chooses]->setmaterial();
				cout<<"How many people to give away : ";//get number of people need
			  	cin>>count;
			while(count<1||cin.fail())
			{   cin.clear();
			    cin.ignore();
			  	cout<<"Wrong input, Please enter again."<<endl;
			  	cout<<"How many people to give away : ";
			  	cin>>count;
			}
			cout<<endl;
			m[chooses]->setgiveaway(count);//run calculate system
			m[chooses]->givecounts();//run calculate system
			cout<<endl<<"Do you want to calculate again ? [Y/N] :";//ask for continue
			cin>>choose;
			choose=toupper(choose);
			while(choose!='Y'&&choose!='N')
			{	cout<<"Wrong input, Please enter again";
			  	cout<<endl<<"Do you want to calculate again? [Y/N] :";
			 	cin>>choose;
			 	choose=toupper(choose);
			}}
			 
			   cout<<endl<<"Do you want to continue?[Y/N] :";
			   cin>>choose;
			   choose=toupper(choose);
			   while(choose!='Y'&&choose!='N')
			   {cout<<"Wrong input, Please enter again";
			   cout<<endl<<"Do you want to continue? [Y/N] :";
			   cin>>choose;
			   choose=toupper(choose);
			   }
			}
		}
		//option 2
		else if(choose==2) 
		{
			
			bool flag = true;
			char cont;
			
			while(flag)
			{
			DangerZone *newDangerZone = new DangerZone[100];
			size=readZone(newDangerZone);	// Read input text 
			sortZone(size,newDangerZone);	//sort the file by state
			display(size,newDangerZone);	//display the Danger Zone
			
			cout <<endl;
			while(flag)	// Option to add or update
			{
			cout <<"do you want to update or add : " <<endl;
			cout << "[1] Update existing zone :"<<endl;
			cout << "[2] Add new zone : " <<endl;
			do{		// check if user input other than 1,2
			cout << "Option :";	
			cin >> choose;
			if(choose!=1&&choose!=2||isalpha(choose)||cin.fail())
			{
				cin.clear();
				cin.ignore();
				cout<<"Wrong input, please enter again."<<endl;
			}
			}while(choose!=1&&choose!=2||isalpha(choose)||cin.fail());
			
			cin.ignore();
			if(choose==1)	//perform update if choose 1
			{
				UpdateZone(size,newDangerZone);
				flag = false;
			}
			
			else if(choose ==2)		//perform update if choose 2
			{
				try
				{
					if(size>100)throw size;
					newDangerZone[size++].NewZone();
					sortZone(size,newDangerZone);
					flag = false;
			    }
				
				catch(int a)
				{
					if (a>100)
						cout<<"Out of Maximum"<<endl;
					flag=true;
				}
		    }
			}
			
			display(size,newDangerZone);	// Display the dangerZone after add or update
			
			cout << endl;
			cout << "Do you want to continue? [Y/N]: ";	//Do you want to perform the operation again
			cin >>cont;
			cont=toupper(cont);
			while (cont!='Y'&&cont!='N'||cin.fail())	
			{
		
					cout << "Wrong option, please try it again"<<endl;
					cout << "Option : ";
					cin >> cont ;
			     	cont=toupper(cont);	
					}
					if(cont =='Y')
					{
						flag = true;
						system("cls");
					}
					else if(cont =='N')
					{
						flag = false;
					}
		
		
			delete [] newDangerZone;
		}
		
		}
		else if (choose==3)
		{
			cout<<"\nThanks for using!";
			exit(0);
		}
	}while(flag2);
	}
	else if (option ==2)	// Option : User
	{
		do{
		flag = true;
		cout<<"\n*****Movement Control Order (MCO) and quarantine system of country*****"<<endl
			<<"[1] Display the danger level of each zone"<<endl
			<<"[2] Track person activity, symptoms and location" <<endl
			<<"[3] Check quarantine people and quarantine place\n"
			<<"[4] Exit\n";
		do{			// Check and make sure the input is between 1-4
				cout << "Option : ";	
				cin >> choose;
				if(choose!=1&&choose!=2&&choose!=3&&choose!=4||cin.fail())
				{
					cin.clear();
					cin.ignore();
					cout<<"Wrong input, please enter again."<<endl;
				}
			}while(choose!=1&&choose!=2&&choose!=3&&choose!=4||cin.fail());
			cin.ignore();
		if(choose==1)
		{DangerZone *newDangerZone = new DangerZone[100];
		 int size;			
			size=readZone(newDangerZone);	// Read input text 
			sortZone(size,newDangerZone);	// sort Zone according to state  
			display(size,newDangerZone);	//display the Danger Zone
			cout <<endl;
			cout << "Do you want to continue? [Y/N]: ";	//Do you want to continue?
			cin >>cont;
			cont=toupper(cont);
			while (cont!='Y'&&cont!='N')	//check cont "Y/N"
			{

			cout << "Wrong option, please try it again"<<endl;
			cout << "Option : ";
			cin >> cont ;
	     	cont=toupper(cont);	
			}
			if(cont =='Y')
			{
				flag = true;
				system("CLS");
			}
			else if(cont =='N')
			{
				cout<<"\nThanks for using!";
				flag = false;
			}
		}
		else if(choose==2)	//operation 2
		{
			if (symptoms.check_probability_infected())	//check the symptoms of user
			{
				int size;
				try		//try catch  the size exceed 100 people
				{
					size=readPeople(people);
					if((size+1)>100)throw size;
					sc[size].checkSC();
					people[size].setName(username);people[size].setNRIC(ic);people[size].setSC(&sc[size]);
					writeout(size+1,people);		
					flag = false;
			    }
				
				catch(int a)
				{
					if (a>100)
						cout<<"Out of Maximum Quarantine People, Please stay home Quarantine!!!"<<endl;
					flag=true;
				}
				
			}
			else
				cout<<"Your are in good health.\n";
			cout << "\nDo you want to continue? [Y/N]: ";
			cin >>cont;
			cont=toupper(cont);
			while (cont!='Y'&&cont!='N')	//Option checking "Y/N"
			{

			cout << "Wrong option, please try it again"<<endl;
			cout << "Option : ";
			cin >> cont ;
	     	cont=toupper(cont);
			}
			if(cont =='Y')
			{
				flag = true;
				system("CLS");
			}
			else if(cont =='N')
			{
				cout<<"\nThanks for using!";
				flag = false;
			}
		}
		else if (choose==3)	//Display the quarantine people and his respective quarantine place
		{
			int size;
			size=readPeople(people);	//Read size of file
			displayql(size,people);		//display the table
			cout << "Do you want to continue? [Y/N]: ";
			cin >>cont;
			cont=toupper(cont);
			while (cont!='Y'&&cont!='N')	//Check condition between "Y/N"
			{

			cout << "Wrong option, please try it again"<<endl;
			cout << "Option : ";
			cin >> cont ;
	     	cont=toupper(cont);	
			}
			if(cont =='Y')
			{
				flag = true;
				system("CLS");
			}
			else if(cont =='N')
			{
				cout<<"\nThanks for using!";
				flag = false;
			}			
		}
		else if (choose==4)		// End of program
		{
			cout<<"\nThanks for using!";
			exit(0);
		}
			
		}while(flag);
	}
	return 0;
}
