// Native_Classes_Part1.cpp : Defines the entry point for the console application. /* _____________________________________________________ W O R K I N G W I T H C L A S S E S P A R T 1 Ron Kessler Created 1/20/2017 This simple app shows how to create a Rectangle object in code so we can find the area of the object. The user inputs width and height and then we do the math and print the result on screen. Imagine you need to find the area of a room so you can buy new carpet. Well, we are going to create an app to do that. _____________________________________________________ */ //Step 1: Add a new class to the project called Rectangle and make it inline. //Step 2: In this file, add an include "Rectangle.h" directive so we can access it. //Run with CTL-F5 #include "stdafx.h" #include #include //so we can format our output with 2 decimals #include "Rectangle.h" //the class you just made using namespace std; int main() { //---create a new Rectangle object Rectangle myRoom; cout << "Welcome to My Room Area Calculator" << "\n\n"; //---define vars to hold user data double myWidth; double myLength; //*********INPUT********** cout << "Please enter the width of the room "; cin >> myWidth; myRoom.setWidth (myWidth); //assign value to myRoom object cout << "Please enter the length of the room "; cin >> myLength; myRoom.setLength (myLength); //assign value to myRoom object //*********PROCESSING IS DONE IN THE MYROOM OBJECT********** //*********OUTPUT********** cout << setprecision (2) << fixed; cout << "\n\n" << "Here are your dimensions: \n"; cout << "The width is : " << myRoom.getWidth() << "\n"; cout << "The length is : " << myRoom.getLength() << "\n"; cout << "The area is : " << myRoom.getArea() << "\n"; return 0; }