rectangles - File rectangles.cpp Created by Patch Havanas...

This preview shows page 1 - 3 out of 7 pages.

/* File: rectangles.cpp Created by: Patch Havanas Creation Date: 11/29 Synopsis: User inputs a list of rectangles, and the program computes a few different attributes of each rectangle and prints them out. */ #include <iostream> #include <string> #include <vector> using namespace std; class Point { private: double px; double py; public: void setX(const double x); void setY(const double y); double getX() const; double getY() const; }; class Rectangle { private: string name; Point blPoint; double length, height; public: // member functions void setName(const string & inName); void setBottomLeft(const double x, const double y); void setDimensions(const double inLength, const double inHeight); string getName() const; Point getBottomLeft() const; double getLength() const; double getHeight() const; double area() const; double perimeter() const; Point midPoint() const; void scaleBy2(); void display() const; }; // FUNCTION PROTOTYPES GO HERE: // DISPLAYS WELCOME BANNER void display_banner(); // READS NAME OF RECTANGLE, PRINTS IF THERE IS AN ERROR bool read_rectangle(const string namePrompt, const string invalid, const string used, string & inName, vector<Rectangle> & list); // READS IN THE BOTTOM LEFT POINT OF EACH RECTANGLE void read_BottomLeft(const string pointPrompt, double & x, double & y);
// READS IN THE LENGTH AND HEIGHT OF EACH RECTANGLE void read_dimensions(const string dimPrompt, double & length, double & height); // ADDS THE RECTANGLE TO THE END OF A VECTOR void add_rectangle(const string name, double x, double y, double length, double height, vector<Rectangle> & list); // DISPLAYS THE RECTANGLES void display_all_recs(vector<Rectangle> & list); int main() { // Define your local variables, e.g. a vector of class Rectangle Rectangle rec; // CLASS RECTANGLE vector<Rectangle> list;

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture