// Programming Technique II (SECJ1023)
// Semester 2, 2020/2021
// Tutorial 1: Procedural Programming (PP) vs. Object-Oriented Programming (OOP)
// Program 3: Using OOP
// Megat Irfan Zackry (A20EC0205)

#include <iostream>
#include <iomanip>
using namespace std;

class Data{
	int w,h;
	
	public:
		void setWidth(int);
		int getWidth();
		
		void setHeight(int);
		int getHeight();
		
		void drawRectangle(Data);
		void calcRectangleArea(Data);
};

void Data::setWidth(int width){
	w = width;
	
}

int Data::getWidth(){
	return w;
}


void Data::setHeight(int height){
	h = height;
}

int Data::getHeight(){
	return h;
}
// ! Define a function to draw a rectangle on the screen with a specified width (w) and height (h)
void Data::drawRectangle(Data d)
{
	int i;  
 
	for (i=0; i<=d.w; i++) 
	cout << "-";
	cout <<endl;


	for (int i=0; i < d.h; i++){
		cout << endl << ":" << setw(d.w) << ":" << endl;
	}

	for(i=0; i<=d.w; i++)
	cout << "-";
	cout << endl<<endl;

}

// ! Define a function to calculate the area of a rectangle with a specified width (w) and height (h) 
void Data::calcRectangleArea(Data w_h)
{
	int area;
	
	area = w_h.w*w_h.h;
	cout << "Rectangle area is : "<< area;
}

int main()
{
	//  Draw a rectangle of width 30 and height 5 and calculate its area
	Data d;
	int width = 30, height = 5;
	
	d.setWidth(width);
	d.setHeight(height);
	cout << "This rectangle of width = "<<d.getWidth()<< " and height = "<<d.getHeight()<<endl<<endl;
	d.drawRectangle(d);
	d.calcRectangleArea(d);
	
	return 0;
}
