/*  Module Title : Object-Oriented Programming  */
/*  Project Title : Customer Mobile Phone Service Plan System  */
#include <stdlib.h>
#include <iostream.h>
#include <iomanip.h>
#include <string.h>
#include <conio.h>
//hpmenu counter

//////////////////
//system("cls");


	
class Custinfomain

{
	
public :

	char *Custno;
	char *Custname;
	char Custadd[50];
	int Contactno;
	char *Emailadd;
	char Datereq[10];
	char Datemod[10];
	char Birthdate[20];
	char Gender[10];
	char Nric_Pass[20];
	char Occupation[20];
	static int custlist;
	
	
	
	Custinfomain(void)

	{
		
			  
		Custno = NULL;
		Custname = NULL;
		strcpy(Custadd,"");
		Contactno = 0;
		Emailadd = NULL;
		strcpy(Datereq,"");
		strcpy(Datemod,"");
		strcpy(Birthdate,"");
		strcpy(Gender,"");
		strcpy(Nric_Pass,"");
		strcpy(Occupation,"");
	
	}

	~Custinfomain(void)

	{
	
		delete Custno;
		delete Custname;
		delete Emailadd;
	}

void Addcustinfo(void)

{
	char temp[80];
	char temp1[512];
	char temp2[100];

	cout << "Please Enter Customer No. : " << endl;
	cin.getline (temp, 80);
	Custno = new char [strlen(temp)+1];
	strcpy(Custno,temp);

	cout << "Please Enter Customer Name : " << endl;
	cin.getline (temp1, 512);
	Custname = new char [strlen(temp1)+1];
	strcpy(Custname,temp1);

	cout << "Please Enter Customer Address : " << endl;
	cin.getline(Custadd,50);
//	cin.ignore();
	
	cout << "Please Enter Contact No. : " << endl;
	cin >> Contactno;
	cin.ignore();


	cout << "Please Enter Email Address : " << endl;
	cin.getline (temp2, 100);
	Emailadd= new char [strlen(temp2)+1];
	strcpy(Emailadd,temp2);
//	cin.ignore();
		

	cout << "Please Enter Date Registered : " << endl;
	cin.getline(Datereq, 20);
//	cin.ignore();

	cout << "Please Enter Date Modified : " << endl;
	cin.getline(Datemod,20);
//	cin.ignore();

	cout << "Please Enter Birthdate : " << endl;
	cin.getline(Birthdate,20) ;
//	cin.ignore();

	cout << "Please Enter Gender : " << endl;
	cin.getline(Gender,20);
//	cin.ignore();

	cout << "Please Enter NRIC/Passport : " << endl;
	cin.getline(Nric_Pass,20);
//	cin.ignore();
	
	cout << "Please Enter Occupation : " << endl;
	cin.getline(Occupation,20);
//	cin.ignore();
	custlist++;
	system("cls");
	

}



void Modifycustinfo(void)

{
	cout << " Customer No. : " << Custno << endl;
	cout << " Customer Name : " << Custname << endl;
	cout << " Customer Address : " << Custadd << endl;
	cout << " Contact No. : " << Contactno << endl;
	cout << " Email Address : " << Emailadd << endl;
	cout << " Date Registered : " << Datereq << endl;
	cout << " Date Modified : " << Datemod << endl;
	cout << " Birth Date : " << Birthdate << endl;
	cout << " Gender : " << Gender << endl;
	cout << " NRIC/Passport : " << Nric_Pass << endl;
	cout << " Occupation : " << Occupation << endl;

}



void Enquirecustinfo(char NricNo[12])

{
	if(strcmp(NricNo,Nric_Pass)==0)
	
	{

	cout << " Customer No. : " << Custno << endl;
	cout << " Customer Name : " << Custname << endl;
	cout << " Customer Address : " << Custadd << endl;
	cout << " Contact No. : " << Contactno << endl;
	cout << " Email Address : " << Emailadd << endl;
	cout << " Date Registered : " << Datereq << endl;
	cout << " Date Modified : " << Datemod << endl;
	cout << " Birth Date : " << Birthdate << endl;
	cout << " Gender : " << Gender << endl;
	cout << " NRIC/Passport : " << Nric_Pass << endl;
	cout << " Occupation : " << Occupation << endl;
	}
}

};

int Custinfomain::custlist=0;




class Handphoneinfomain

{
	//hp model we making is v2xxx and v5xxx	


	
public:
	
	
		char DesignNo[20];
		char ModelNo[20];
		char SerialNo[20];
		float weight;
		char frequency[10];
		char colour[10];
		float price;
		int flag;
		int quantity;
		static int hplist;
	
	
	Handphoneinfomain(void)
	{
		strcpy(DesignNo,"");
		strcpy(ModelNo,"");
		strcpy(SerialNo,"");
		weight=0.0;
		strcpy(frequency,"");
		strcpy(colour,"");
		price=0.0;
		flag=0;
		quantity=0;

	}


	void addhplist(void)
	
	{
		
		cout<<"Please enter design number :";
		cin.getline(DesignNo,20);
		//cin.ignore();
		cout<<"Please enter model number :";
		cin.getline(ModelNo,20);
		//cin.ignore();
		cout<<"Please enter serial number :";
		cin.getline(SerialNo,20);
	//	cin.ignore();
		cout<<"Please enter handphone weight :";
		cin>>weight;
		cin.ignore();
		cout<<"Please enter frequency :";
		cin.getline(frequency,10);
	//	cin.ignore();
		cout<<"Please enter colour :";
		cin.getline(colour,10);
	//	cin.ignore();
		cout<<"Please enter price :";
		cin>>price;
		cin.ignore();
		hplist++;
		system("cls");
	
	}

	void deletehplist(void)
	
	{
	/*	char DelDesignNo[20];
		cout<<"Please enter design number of handphone to delete";
		cin.getline(DelDesignNo,20);
		for(int p=0;p<Handphoneinfomain::hplist;p++)
		{if(strcmp(DelDesignNo,Handphoneinfomain)==1)
		{
		strcpy(DesignNo,"");
		strcpy(ModelNo,"");
		strcpy(SerialNo,"");
		weight=0.0;
		strcpy(frequency,"");
		strcpy(colour,"");
		price=0.0;
		flag=0;
		quantity=0;
		}
		else
			cout<<"No records found"<<endl;
		}
*/
	}

int modifyhplist(char snum[20])
	
	{
		
		if(strcmp(snum,SerialNo)==0)
		{

		cout<<"Please enter design number :";
		cin.getline(DesignNo,20);
		//cin.ignore();
		cout<<"Please enter model number :";
		cin.getline(ModelNo,20);
		//cin.ignore();
		cout<<"Please enter serial number :";
		cin.getline(SerialNo,20);
	//	cin.ignore();
		cout<<"Please enter handphone weight :";
		cin>>weight;
		cin.ignore();
		cout<<"Please enter frequency :";
		cin.getline(frequency,10);
	//	cin.ignore();
		cout<<"Please enter colour :";
		cin.getline(colour,10);
	//	cin.ignore();
		cout<<"Please enter price :";
		cin>>price;
		cin.ignore();
		system("cls");
		return 1;
		}

		return 0;

}    
int enquiry(char snum[20])
	
	{
		
		//cin.ignore();
		if(strcmp(snum,SerialNo)==0)
			
		{cout<<DesignNo<<endl;
			cout<<ModelNo<<endl;
			cout<<SerialNo<<endl;
			cout<<weight<<endl;
			cout<<frequency<<endl;
			cout<<colour<<endl;
			cout<<price<<endl;
		return 1;
		}
		//else
		return 0;
		
	
	
	
	
	
	
	
	
	
	
	
	}
};





	int Handphoneinfomain::hplist =0;

//class v2xxx :public Handphoneinfomain
//{
//};




class Serviceplanmain

{

	char *Serviceplanno;
	char *Custno;
	char Daterec;
	char DateUpd;
	char Status;
	char Servicetype;
	double SPamt;

public:

	  Serviceplanmain(void)

		{
			Serviceplanno = NULL;
			Custno = NULL;
			Daterec = NULL;
			DateUpd = NULL;
			Status = NULL;
			Servicetype = NULL;
			SPamt = 0.0;

		}

		~Serviceplanmain()

		{
			delete Serviceplanno;
			delete Custno;
		}

void Input()

{
	char temp[100];
	char temp1[200];


	cout << "Please Enter Serviceplanno. : " << endl;
	cin>>temp;
	cin.ignore();
	Serviceplanno = new char [strlen(temp)+1];
	strcpy(Serviceplanno,temp);

	cout << "Please Enter Customer No. : " << endl;
	cin>>temp1;
	cin.ignore();
	Custno = new char [strlen(temp1)+1];
	strcpy(Custno,temp1);
	
	cout << "Please Enter Date Received : " << endl;
	cin >> Daterec;
	cin.ignore();

	cout << "Please Enter Date Updated : " << endl;
	cin >> DateUpd;
	cin.ignore();

	cout << "Please Enter Status ( New, Active, Suspend, Terminated ) : " << endl;
	cin >> Status;
	cin.ignore();

	cout << "Please Enter Service Type ( Platinum, Gold, Silver ) : " << endl;
	cin >> Servicetype;
	cin.ignore();

	cout << "Please Enter Amount Paid For Service Plan : " << endl;
	cin >> SPamt;
	cin.ignore();


}

};
		



void Addcustmenu()

{	
		static int i=0;
		static int j=0;
		static int k=0;
		char Nric[12];
		Custinfomain cust_details[20];
		int choice =0 ;
		
		do
		
		{
		
			cout << "1) Add Customer Information" << endl;
			cout << "2) Modify The Customer Information" << endl;
			cout << "3) Enquire The Customer Information" << endl;
			cout << "4) Exit" << endl;
			cout << "9) Back To Main Menu"<<endl;
			cout << "Please Select A Choice : " << endl;
			cin >> choice;
			cin.ignore();
			system("cls");
	
			
		if(choice==1)
		
		{cust_details[i++].Addcustinfo();}
		
		else if(choice==2)
		{cust_details[j++].Modifycustinfo();}
		
		else if(choice==3)
		{
			cout<<"Please enter Customer Nric number :";
			cin.getline(Nric,12);

			for(int o;o<Custinfomain::custlist;o++)
			{
				cust_details[o].Enquirecustinfo(Nric);
			}



		
		
		
		
		
		}
		
		else if(choice==4)
		{		
			cout << "SCRAM HEAD" << endl;
		}
			
			//{
		//	for(int m=0;m<i;m++)
		//	{cout<<"Handphone"<<m+1<<endl;
		//		cust_details[m].enquiry();
		//	}
			
		//}
		}while(choice!=9);
}



void hp_menu(void)
	
{	
		 int i=0;
		 int j=0;
		 int k=0;
		 int answer;

		Handphoneinfomain hp_details[20];
		int choice=0;
		
		char Sno[20];
		do
		
		{
		cout<<"1)Add handphone list"<<endl;
		cout<<"2)Delete handphone list"<<endl;
		cout<<"3)Modify handphone list"<<endl;
		cout<<"4)Enquiry"<<endl;
		cout<<"9)Back to main menu"<<endl;
		cin>>choice;
		cin.ignore();
		system("cls");

		if(choice==1)
		{hp_details[i++].addhplist();}
		else if(choice==2)
		{hp_details[j++].deletehplist();}
		else if(choice==3)
		{
			cout<<"Please enter serial number of hp to modify: ";
			cin.getline(Sno,20);
			for(int m=0;m<Handphoneinfomain::hplist;m++)
			{
							
			answer = hp_details[m].modifyhplist(Sno);
			
				if(answer==1)break;
				else
				{cout<<"No records found"<<endl;break;
				
				}

			}
		
		}
		
		
		
		else if(choice==4)
		{
			
		cout<<"Please enter serial number of hp :";
		cin.getline(Sno,20);
			
		
		for(int m=0;m<Handphoneinfomain::hplist;m++)
			{
				answer = hp_details[m].enquiry(Sno);

				if(answer==1)break;
				else
				{
					cout<<"No records found"<<endl;break;
					
				}

			}
			
		
		
		
		
		
		
		
		
		
		
		
		
		
		/*for(int m=0;m<Handphoneinfomain::hplist;m++)
			{
				cout<<"Handphone"<<m+1<<endl;
				hp_details[m].enquiry();
			}*/
			
		}
		}while(choice!=9);

}



	static int m=0;
	


		
void main(void)

{	

	//CustinfoMain cust_details;
	//Serviceplanmain service_details;
	//Handphoneinfomain hp_details[20];
	int choice=0;
		
	do
	
	{
		int a; 

int b = 7; 



a = ++b + (++b);// - --b + --b ;
cout << a; 

		cout<<"1) Hp information maintenance"<<endl;
		cout<<"2) Customer information maintenance"<<endl;
		cout<<"3) Service Plan Maintenance"<<endl;
		cout<<"4) Customer order fulfillment process"<<endl;
		cout<<"9) Quit"<<endl;
		cout << ">>>";
		cin >> choice;
		cin.ignore();
		system("cls");
	
	if ( choice == 1 )
	
	{ hp_menu(); }

	else if (choice == 2)
	{ Addcustmenu(); }




	}while(choice!=9);

}




