I have my code main.cc #include #include #include #include #include #include using namespace std; struct Point {    double xCoor = 0;    double yCoor = 0;    bool isSolid; }; /* === Operation 1 - Print the map data === */ class Rectangle {    Point corner1, corner2;    bool isSolid;    public:    Rectangle() {        Point p1, p2;        corner1 = p1;        corner2 = p2;        isSolid = false;    }       Rectangle(bool isSolid, Point p1, Point p2) {        corner1 = p1;        corner2 = p2;        this->isSolid = isSolid;    }       void PrintData() {        std::cout <<            "Corner1: (" << corner1.xCoor << ", " << corner1.yCoor << ")\n"            "Corner2: (" << corner2.xCoor << ", " << corner2.yCoor << ")\n"; if(corner1.isSolid and corner2.isSolid) { cout<< "This rectangle is solid \n"; } else { cout<< "This rectangle is not solid \n"; void ReadReactangles(string fileName) {    int const        MIN_ARGS = 5, IS_SOLID = 0,        COOR1 = 1,        COOR2 = 2,        COOR3 = 3,        COOR4 = 4;    fstream file(fileName, ios::in); // fstream object to read data from the input file    /* check if the input file can be found or not */    if (!file) cout << "CAN'T OPEN\n";    string line;    string args[MIN_ARGS];    size_t argCount = 0;    Rectangle rect;    Point p1, p2;       /* if the file present, read all lines till the end of file using a while loop */    while (getline(file, line)) { // read arguments and init objs line by line        if (line.empty()) break;        cout << "\nline: " << line << '\n';               argCount = 0;        for (size_t i = 0; i < MIN_ARGS; i++) { args[i] = ""; }        for (size_t i = 0; i < line.length(); i++) {            if (argCount >= MIN_ARGS) break;               if (line[i] == ' ') ++argCount;            else args[argCount] += line[i];        }               // Print point 1 and point 2        p1.xCoor = stod(args[COOR1]);        p1.yCoor = stod(args[COOR2]);        p2.xCoor = stod(args[COOR3]);        p2.yCoor = stod(args[COOR4]);        rect = Rectangle(stoi(args[IS_SOLID]), p1, p2);        rect.PrintData();        line = "";    }    file.close(); } /* This is the main method which is responsible for running the program. */ int main() { cout<<" === Operation 1 - Print the map data === "<    ReadReactangles("Rectangles.txt"); } Rectangles.txt <----THIS IS FILE TEST CODE 0 0 0 100 100 1 2 1 1.1 1.0 1.2 1.3 1 10 10 11 11 0 50 60 70 80 4 0 55 65 65 75 5 1 56 66 64 74 SO I WANT TO change main.cc separate 3 file rectangle.h, rectangle.cc, and point.h rectangle.h #pragma once #include "point.h" class Rectangle {    Point p1;    Point p2;    bool solid = false;    vector children;    public:    // Constructors    // If we are not solid, we have to have children    Rectangle() {}    Rectangle(Point new_p1 = {0, 0}, Point new_p2 = {0, 0}, bool new_solid = true) : p1(new_p1), p2(new_p2), solid(new_solid) {}    Rectangle(double x1, double y1, double x2, double y2, bool new_solid) : p1(Point(x1, y1)), p2(Point(x2, y2), solid(new_solid) {}    // Getters    Point getPoint1() const;    Point getPoint2() const;    // Return a reference to your children if not solid    vector getChildren() const;    // Comparison    // Takes in a point and returns true if that point is within the rectangle    bool pointIn(const Point &pointCheck) const;    // Takes in another rectangle and returns true if both rectangles collide at all    bool rectCollision(const Rectangle &other) const; } point.h struct Point {    double x = 0;    double y = 0;    // Constructors    Point() : x(0), y(0) {}    Point(double new_x, new_y) : x(new_x), y(new_y) {} } rectangle.cc WRITE THE CODE IN MAIN.CC CHANGE FOLLOW IN GUIDE void loadRectangles(file, reference to vector) { try to load file if (file doesn't load) throw error while (file still has stuff) { get line from file if (file doesn't have stuff) break; create rectangle with data in line add rectangle to vector if (rectangle is NOT solid) { for (number of children) { create child rectangle with data in line add child rectangle to parent's vector } } } }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I have my code

main.cc

#include
#include
#include
#include
#include
#include

using namespace std;

struct Point {
   double xCoor = 0;
   double yCoor = 0;
   bool isSolid;
};

/* === Operation 1 - Print the map data === */
class Rectangle {
   Point corner1, corner2;
   bool isSolid;
  
public:
   Rectangle() {
       Point p1, p2;
       corner1 = p1;
       corner2 = p2;
       isSolid = false;
   }
  
   Rectangle(bool isSolid, Point p1, Point p2) {
       corner1 = p1;
       corner2 = p2;
       this->isSolid = isSolid;
   }
  
   void PrintData() {
       std::cout <<
           "Corner1: (" << corner1.xCoor << ", " << corner1.yCoor << ")\n"
           "Corner2: (" << corner2.xCoor << ", " << corner2.yCoor << ")\n";
if(corner1.isSolid and corner2.isSolid)
{
cout<< "This rectangle is solid \n";
}
else
{
cout<< "This rectangle is not solid \n";

void ReadReactangles(string fileName) {
   int const
       MIN_ARGS = 5,
IS_SOLID = 0,
       COOR1 = 1,
       COOR2 = 2,
       COOR3 = 3,
       COOR4 = 4;
   fstream file(fileName, ios::in); // fstream object to read data from the input file
   /* check if the input file can be found or not */
   if (!file) cout << "CAN'T OPEN\n";
   string line;
   string args[MIN_ARGS];
   size_t argCount = 0;
   Rectangle rect;
   Point p1, p2;
  
   /* if the file present, read all lines till the end of file using a while loop */
   while (getline(file, line)) { // read arguments and init objs line by line
       if (line.empty()) break;
       cout << "\nline: " << line << '\n';
      
       argCount = 0;
       for (size_t i = 0; i < MIN_ARGS; i++) { args[i] = ""; }
       for (size_t i = 0; i < line.length(); i++) {
           if (argCount >= MIN_ARGS) break;
  
           if (line[i] == ' ') ++argCount;
           else args[argCount] += line[i];
       }
      
       // Print point 1 and point 2
       p1.xCoor = stod(args[COOR1]);
       p1.yCoor = stod(args[COOR2]);
       p2.xCoor = stod(args[COOR3]);
       p2.yCoor = stod(args[COOR4]);

       rect = Rectangle(stoi(args[IS_SOLID]), p1, p2);
       rect.PrintData();
       line = "";
   }
   file.close();
}

/* This is the main method which is responsible for running the program. */
int main() {
cout<<" === Operation 1 - Print the map data === "<    ReadReactangles("Rectangles.txt");
}

Rectangles.txt <----THIS IS FILE TEST CODE

0 0 0 100 100 1 2
1 1.1 1.0 1.2 1.3
1 10 10 11 11
0 50 60 70 80 4
0 55 65 65 75 5
1 56 66 64 74

SO I WANT TO change main.cc separate 3 file rectangle.h, rectangle.cc, and point.h

rectangle.h

#pragma once

#include "point.h"

class Rectangle {
   Point p1;
   Point p2;
   bool solid = false;
   vector children;

   public:
   // Constructors
   // If we are not solid, we have to have children
   Rectangle() {}
   Rectangle(Point new_p1 = {0, 0}, Point new_p2 = {0, 0}, bool new_solid = true) : p1(new_p1), p2(new_p2), solid(new_solid) {}
   Rectangle(double x1, double y1, double x2, double y2, bool new_solid) : p1(Point(x1, y1)), p2(Point(x2, y2), solid(new_solid) {}

   // Getters
   Point getPoint1() const;
   Point getPoint2() const;

   // Return a reference to your children if not solid
   vector getChildren() const;

   // Comparison

   // Takes in a point and returns true if that point is within the rectangle
   bool pointIn(const Point &pointCheck) const;

   // Takes in another rectangle and returns true if both rectangles collide at all
   bool rectCollision(const Rectangle &other) const;
}

point.h

struct Point {
   double x = 0;
   double y = 0;

   // Constructors
   Point() : x(0), y(0) {}
   Point(double new_x, new_y) : x(new_x), y(new_y) {}

}

rectangle.cc

WRITE THE CODE IN MAIN.CC CHANGE

FOLLOW IN GUIDE

void loadRectangles(file, reference to vector)

{

try to load file

if (file doesn't load) throw error

while (file still has stuff)

{

get line from file

if (file doesn't have stuff) break;

create rectangle with data in line add rectangle to vector

if (rectangle is NOT solid)

{

for (number of children)

{

create child rectangle with data in line add child rectangle to parent's vector

}

}

}

}

HELP ME PLEASE C++. THANK YOU SO MUCH

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 7 steps with 1 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education