//NAME: NG JING ER
//MATRIC: A19EC0115
//SECJ1023-08
//LAB POLYMORPHISM
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;

class Location{
	private:
		string street;
		string town;
	public:
		Location(string n="",string m="")
		{	street=n;
			town=m;	}
		string getStreet(){ return street;}
		string getTown(){ return town;}
		string getFullLocation(){ return street+", "+town;}
};

class House{
	private:
		int noRoom;
		Location *location;
	protected:
		double rentRate;
	public:
		House(){ noRoom=0;	}
		House(Location *l, int n, double r){
			location=l;
			noRoom=n;
			rentRate=r;
		}
		string getLocation(){ return location->getFullLocation();	}
		int getRoom(){ return noRoom;	}
		double getRate(){ return rentRate;	}
		virtual double getDeposit(){ return 0;	}
		virtual void display() 
		{ cout<<" "<<endl;	}
};

class Bungalow:public House{
	private:
		int land;
	public:
		Bungalow(){ land=0;	}
		Bungalow(Location *LOC, int NO, double RENT, int l)
		:House(LOC,NO,RENT){	land=l;		}
		int getLand(){ return land;	}
		double getDeposit(){ return 6*rentRate;
		}  
		void display(){
			cout<<"We have a bungalow located at "<<House::getLocation()
				<<" with "<<House::getRoom()<<" bedrooms"<<endl;
			cout<<"Land size : "<<getLand()<<" sqft."<<endl;
			cout<<"Monthly rental rate: RM"<<fixed<<setprecision(2)<<House::getRate()<<endl;
			cout<<"Deposit: RM"<<fixed<<setprecision(2)<<getDeposit()<<endl<<endl;
		}
};

class Apartment:public House{
	private:
		int level;
	public:
		Apartment(){ level=0;	}
		Apartment(Location *_LOC, int _NO, double _RENT, int _l)
		:House(_LOC,_NO,_RENT){	level=_l;	}
		int getFLevel(){ return level;	}
		double getDeposit(){ return 3*rentRate;
		} 
		void display(){
			cout<<"We have an apartment located at "<<House::getLocation()
				<<" with "<<House::getRoom()<<" bedrooms,"<<endl;
			cout<<"at level "<<getFLevel()<<"."<<endl;
			cout<<"Monthly rental rate: RM"<<fixed<<setprecision(2)<<House::getRate()<<endl;
			cout<<"Deposit: RM"<<fixed<<setprecision(2)<<getDeposit()<<endl<<endl;
		} 
};

int main(){
	cout<<"*** HOUSE FOR RENT *** "<<endl<<endl;
	
	Location *locBanglow=new Location("Taman University","Johor Bahru");
	Location *locApart1=new Location("Pulai Spring Resort","Pulai");
	Location *locApart2=new Location("Scholars Inn","Universiti Teknologi Malaysia");
	
	Bungalow b(locBanglow,6,2000.00,300);
	Apartment a1(locApart1,3,800.00,5);
	Apartment a2(locApart2,2,700.00,12);
	
	House *h;
	House r;
	h=&b;
	h->display();
	h=&a1;
	h->display();
	h=&a2;
	h->display();
	
	return 0;
}
