Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Course: CS 1410 Section X01
- // Instructor: Prof Debry
- // Student: Ramsey Lawson
- // Contents: Project 11
- // Date: November 21 2011
- // I declare that the following source code was written solely by me, or provided by the
- // instructor. I understand that copying any source code, in whole or in part, constitutes
- // cheating, and that I will receive a zero in this assignment if I am found in violation of
- // this policy.
- #include <iostream>
- #include <string>
- #include <vector>
- #include "rectangle.h"
- using namespace std;
- // declare global constants here
- const int MAX_SIZE = 3;
- // declare functions here
- void prologue();
- void printRectangle(const rectangle&);
- int main( )
- {
- // declare local variables here
- rectangle userDefinedRectangle;
- string places[MAX_SIZE] = { "1st", "2nd", "3rd" };
- int userInput = 0;
- vector<rectangle> rectangles(MAX_SIZE); // vector to hold rectangle objects
- // int index = 0;
- // C++ statements
- prologue();
- // Prompt the user to enter in the dimensions of three Rectangles.
- for (int i = 0; i < MAX_SIZE; i++)
- {
- cout << "\nPlease type the dimensions of the " << places[i] << " rectangle" << endl;
- cout << "Height = ";
- cin >> userInput;
- userDefinedRectangle.setHeight(userInput);
- cout << "Width = ";
- cin >> userInput;
- userDefinedRectangle.setWidth(userInput);
- rectangles[i] = userDefinedRectangle;
- } // end data gathering loop
- // Using the data provided by the user create three Rectangle objects.
- const int SEPARATOR = 44;
- for (int i = 0; i < SEPARATOR; i++)
- cout << "-";
- cout << endl;
- // For each Rectangle object that you created call the stand-alone function printRectangle.
- printRectangle(userDefinedRectangle);
- system("PAUSE");
- return 0;
- } // end main
- // Function Name: printRectangle
- // Purpose: prints rectangle properties
- // Parameters: reference to a Rectangle object
- // Returns: none
- void printRectangle(const rectangle &shape) // (const vector<rectangle> &shape) vs (const rectangle &shape)
- {
- /*
- for (int i = 0; i < MAX_SIZE; i++)
- cout
- */
- cout << "\nRectangle " << endl;
- // The rectangle's height
- cout << "width = " << shape.getHeight() << endl;
- // The rectangle's width
- cout << "height = " << shape.getWidth() << endl;
- // The rectangle's area
- cout << "Area = " << shape.calcArea() << endl;
- // The rectangle's perimeter
- cout << "Perimeter = " << shape.calcPerimeter() << endl;
- // Whether or not the rectangle is also a square.
- if (shape.isSquare() == true)
- cout << "This rectangle is also a square." << endl;
- } // end printRectangle function
- // Prologue Function
- // Purpose: Program prints out your name, section, and the text "Project/Lab XX"
- // Parameters: none
- // Returns: none
- void prologue()
- {
- string assignment = "Project 11";
- cout << "Ramsey Lawson\nSection X01\n" << assignment << endl;
- } // end prologue function
Add Comment
Please, Sign In to add comment