#include <iostream>
#include <string>
#include <limits>

using namespace std;

const int TOTALHOUSE = 50;

//Home struct already declared in housing.cpp
void initializedHousing(House housings[], int &totalHouse) {
	House house;
	
	house.lot = "0101";
	house.propertyName = "Platino Apartment";
	house.totalBedrooms = 3;
	house.totalBathrooms = 2;
	house.price = 150000;
	house.status = 1;
	house.buyerName = "none";
	
	housings[0] = house;	
	totalHouse++;
	
	house.lot = "0102";
	house.propertyName = "Platino Apartment";
	house.totalBedrooms = 4;
	house.totalBathrooms = 3;
	house.price = 250000;
	house.status = 1;
	house.buyerName = "none";
	
	housings[1] = house;
	totalHouse++;
	
	house.lot = "0103";
	house.propertyName = "Platino Apartment";
	house.totalBedrooms = 5;
	house.totalBathrooms = 4;
	house.price = 350000;
	house.status = 1;
	house.buyerName = "none";
	
	housings[2] = house;
	totalHouse++;
}

void memberMenu(string login)
{
	system("cls");

	cout<<"\n";
	cout<<"\t               ###############################          "<<endl;
	cout<<"\t            #####################################       "<<endl;
	cout<<"\t         ###########################################    "<<endl;
	cout<<"\t      ################################################# "<<endl;
	cout<<"\t                     WELCOME TO HBS (" << login << ")   "<<endl;
	cout<<"\t        ##           Member Main Menu              ##   "<<endl;
	cout<<"\t        ##   ===================================   ##   "<<endl;
	cout<<"\t        ##         1) VIEW HOUSE                   ##   "<<endl;
	cout<<"\t        ##         2) BUY HOUSE                    ##   "<<endl;
	cout<<"\t        ##         3) PRINT                        ##   "<<endl;
	cout<<"\t        ##         4) EXIT                         ##   "<<endl;
	cout<<"\t        ##   ===================================   ##   "<<endl;
	cout<<"\t        #############################################   "<<endl;
	cout<<"\t      ################################################# "<<endl;
	cout<<endl;
}

void exitMemberMenu()
{
	system("cls");

	cout << "\n\n\n\n\n";
	cout << "\t\t\t  THANK YOU FOR USING HBS" << endl;
	cout << "\t\t\t       SEE YOU AGAIN" << endl;
	cout << "\n\n\n\n";

	exit(0);
}

void chooseMemberMenu(User user) {
	
	House housing[TOTALHOUSE];
	
	int totalHouse = 0;
	initializedHousing(housing, totalHouse);
		
	int choice;
	
	do
	{
		memberMenu(user.login);
		
		cout<<"\n\n";
		cout<<"\t\t\t      Enter your choice"<<endl;
		cout<<"\t\t\t             ";
		cin >> choice;
		
		cin.clear();
  		cin.ignore(numeric_limits<streamsize>::max(), '\n');
		
		system("cls");
		
		switch(choice) {
			
			case 1 : {
				viewHouse(housing, totalHouse);
				
				break;
			}
			
			case 2 : {
				buyHouse(housing, user.name, totalHouse);	
				
				break;
			}
			
			case 3 : {
				print(housing, user.name, totalHouse);
				
				break;
			}
			
			case 4 : {
				exitMemberMenu();
				break;
			}
		
			default : {
				cout<<"\n\n\n";
				cout<<"\t\t\t       INVALID INPUT"<<endl;
				cout<<"\t\t\t    Please choose again"<<endl;
				cout<<endl<<endl;					  
				system("pause");
				system("cls");
			}
		}
				
	} while(choice != 4);
}
