Question
C++ Please use the starter code provided at the bottom (input files included as well) Grouping.cpp #include #include #include using namespace std; //Represents an occupied
C++
Please use the starter code provided at the bottom
(input files included as well)
Grouping.cpp
#include
using namespace std;
//Represents an occupied square in the grid //Do not modify the GridSquare class or its member functions class GridSquare { private: int row, col; public: GridSquare() : row(0), col(0) {} //Default constructor, (0,0) square GridSquare(int r, int c) : row(r), col(c) {} //(r,c) square //Compare with == operator, used in test cases bool operator== (const GridSquare r) const { if ((row == r.row) && (col == r.col)) { return true; } return false; } int getRow() { return row; } //return row value int getCol() { return col; } //return column value //Output using
//Function definition for /* Groups squares in 10x10 grid upon construction Additional private helper functions may be added Need to implement the constructor that takes a file name as well as findGroup The findGroup function's parameter list may be changed based on how the function is implemented */ class Grouping { private: int grid[10][10]; vector //Implement the (parameterized) constructor and findGroup functions below //Simple main function to test Grouping int main() { Grouping input1("input1.txt"); input1.printGroups(); return 0; } input1.txt .........X ...XX....X .......... ....X..X.. ...X...X.. .......XX. ....XX.... .......... .......... .......... input2.txt ....XXXXXX ...XX....X ....X..XXX ...XX..X.. ...X...X.. ...X...XX. ...XXXXX.. .......... .......... .......... input3.txt ..X.....X. .X.X.XX.XX ..X..X.... .......XX. XXX..XXX.. X.X..XXX.. XXX.XXXX.. ......XX.. X........X XX....XXXX input4.txt .......... ...X.X.... ..XXXXX... ...X.X.... ..XXXXX... ...X.X.... .......X.. .XXXXXXXXX ...X.....X ...XXXX...
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started