Menu

I had .cpp file:    #include “twodlinkedlist.h” #include <map> #include <algorithm>   void TwoDLinkedList::Clear() {     // COMPLETE YOUR IMPLEMENTATION BELOW     TwoDNode* row = no…

I had .cpp file:  #include “twodlinkedlist.h”#include

#include
 void TwoDLinkedList::Clear() {    // COMPLETE YOUR IMPLEMENTATION BELOW    TwoDNode* row = northwest;    while (row != nullptr) {        TwoDNode* col = row;        row = row->south;        while (col != nullptr) {            TwoDNode* next = col->east;            delete col;            col = next;        }    }    northwest = nullptr;    southeast = nullptr;    blockdimx = 0;    blockdimy = 0;} void TwoDLinkedList::Copy(const TwoDLinkedList& otherlist) {    // COMPLETE YOUR IMPLEMENTATION BELOW    if (this == &otherlist) {        return; // Prevent self-assignment    }     Clear();     if (otherlist.northwest == nullptr) {        northwest = nullptr;        southeast = nullptr;        return;    }     blockdimx = otherlist.blockdimx;    blockdimy = otherlist.blockdimy;     std::map node_map;     TwoDNode* other_current = otherlist.northwest;    TwoDNode* prev_row = nullptr;    TwoDNode* current = nullptr;    TwoDNode* first_in_row = nullptr;     while (other_current != nullptr) {        if (first_in_row == nullptr) {            first_in_row = new TwoDNode();            current = first_in_row;        } else {            current->south = new TwoDNode();            current = current->south;        }        current->data = other_current->data;        node_map[other_current] = current;         TwoDNode* other_row_current = other_current->east;        TwoDNode* row_current = current;        while (other_row_current != nullptr) {            row_current->east = new TwoDNode();            row_current = row_current->east;            row_current->data = other_row_current->data;            node_map[other_row_current] = row_current;            other_row_current = other_row_current->east;        }         if (prev_row != nullptr) {            TwoDNode* temp_prev = prev_row;            TwoDNode* temp_curr = first_in_row;            while (temp_prev != nullptr && temp_curr != nullptr) {                temp_prev->south = temp_curr;                temp_curr->north = temp_prev;                temp_prev = temp_prev->east;                temp_curr = temp_curr->east;            }        }         prev_row = first_in_row;        first_in_row = nullptr;        other_current = other_current->south;    }     northwest = node_map[otherlist.northwest];    southeast = node_map[otherlist.southeast];} /** *  Default constructor creates an empty list */TwoDLinkedList::TwoDLinkedList() {    // COMPLETE YOUR IMPLEMENTATION BELOW    northwest = nullptr;    southeast = nullptr;    blockdimx = 0;    blockdimy = 0;}  void TwoDLinkedList::Build(PNG& img, unsigned int blockdimx, unsigned int blockdimy) {    // COMPLETE YOUR IMPLEMENTATION BELOW    Clear();
     this->blockdimx = blockdimx;    this->blockdimy = blockdimy;
     unsigned int img_width = img.width();    unsigned int img_height = img.height();
     TwoDNode* prev_row = nullptr;    TwoDNode* first_in_row = nullptr;
     for (unsigned int y = 0; y < img_height; y += blockdimy) {        TwoDNode* current_row = nullptr;        for (unsigned int x = 0; x < img_width; x += blockdimx) {            TwoDNode* new_node = new TwoDNode();            new_node->data.Build(blockdimx, blockdimy, y, x, img);
             if (first_in_row == nullptr) {                first_in_row = new_node;                if (northwest == nullptr) {                    northwest = first_in_row;                }            }
             if (current_row != nullptr) {                current_row->east = new_node;                new_node->west = current_row;            }            current_row = new_node;
             if (prev_row != nullptr) {                TwoDNode* temp_prev = prev_row;                TwoDNode* temp_curr = first_in_row;                while (temp_prev != nullptr && temp_curr != nullptr) {                    temp_prev->south = temp_curr;                    temp_curr->north = temp_prev;                    temp_prev = temp_prev->east;                    temp_curr = temp_curr->east;                }            }        }        prev_row = first_in_row;        first_in_row = nullptr;    }
     southeast = prev_row;    while (southeast && southeast->east) {        southeast = southeast->east;    }}  unsigned int TwoDLinkedList::GetBlockDimensionX() const {    // REPLACE THE LINE BELOW WITH YOUR IMPLEMENTATION    if (!northwest) return 0;
     unsigned int count = 0;    TwoDNode* current = northwest;    while (current) {        count++;        current = current->east;    }    return count;}
 unsigned int TwoDLinkedList::GetBlockDimensionY() const {    // REPLACE THE LINE BELOW WITH YOUR IMPLEMENTATION    if (!northwest) return 0;
     unsigned int count = 0;    TwoDNode* current = northwest;    while (current) {        count++;        current = current->south;    }    return count;}
 PNG TwoDLinkedList::Render(unsigned int scale) const {    // REPLACE THE LINE BELOW WITH YOUR IMPLEMENTATION    if (!northwest) return PNG();
     unsigned int width = blockdimx * GetBlockDimensionX() * scale;    unsigned int height = blockdimy * GetBlockDimensionY() * scale;    PNG result(width, height);
     TwoDNode* row_start = northwest;    unsigned int row = 0;    while (row_start != nullptr) {        TwoDNode* current = row_start;        unsigned int col = 0;        while (current != nullptr) {            current->data.Render(scale, row * blockdimy * scale, col * blockdimx * scale, result);            col++;            current = current->east;        }        row++;        row_start = row_start->south;    }
     return result;}
 void TwoDLinkedList::FlipHorizontal() {    // COMPLETE YOUR IMPLEMENTATION BELOW    TwoDNode* row_start = northwest;    while (row_start != nullptr) {        TwoDNode* current = row_start;        TwoDNode* prev = nullptr;        TwoDNode* next;
         while (current != nullptr) {            next = current->east;            current->east = prev;            current->west = next;            prev = current;            current = next;        }
         row_start->east = nullptr;        row_start = prev;    }
     // Swap northwest and southeast    std::swap(northwest, southeast);} And .h file here: 
 #ifndef _TWODLINKEDLIST_H_#define _TWODLINKEDLIST_H_
 #include “cs221util/PNG.h”#include “cs221util/RGBAPixel.h”#include “block.h”
 using namespace std;using namespace cs221util;
 class TwoDNode {    public:        Block data;        TwoDNode* north; // pointer to the northern neighbour, if one exists; NULL otherwise        TwoDNode* east; // pointer to the eastern neighbour, if one exists; NULL otherwise        TwoDNode* south; // pointer to the southern neighbour, if one exists; NULL otherwise        TwoDNode* west; // pointer to the western neighbour, if one exists; NULL otherwise
         /**         *  Default node constructor assigns appropriate values to the neighbour pointers         */        TwoDNode();
         /**         *  Parameterized node constructor assigns data block and appropriate values to the neighbour pointers         */        TwoDNode(const Block& bdata);};
 class TwoDLinkedList {    private:        TwoDNode* northwest; // pointer to upper-left node in the 2D list        TwoDNode* southeast; // pointer to lower-right node in the 2D list

         unsigned int blockdimx; // horizontal dimension of the list (in blocks)        unsigned int blockdimy; // vertical dimension of the list (in blocks)               /**         *  Deallocates any associated dynamic memory and sets private attributes appropriately         *         *  @post this list is empty         */        void Clear();
         /**         *  Copies the data and structure of otherlist into this list         *         *  @post this list is a physically separate copy of otherlist         */        void Copy(const TwoDLinkedList& otherlist);
     public:        /**         *  Default constructor creates an empty list         */        TwoDLinkedList();
         /**         *  Parameterized constructor creates a list with blockdimx columns,         *  blockdimy rows, using color data from img         *         *  @param img – input PNG         *  @param blockdimx – horizontal dimension of the list (in Blocks, i.e. number of columns)         *  @param blockdimy – vertical dimension of the list (in Blocks, i.e. number of rows)         *         *  @pre img has dimensions at least 1×1         *  @pre 1 <= blockdimx <= PNG's horizontal dimension (in pixels)         *  @pre 1 <= blockdimy <= PNG's vertical dimension (in pixels)         */        TwoDLinkedList(PNG& img, unsigned int blockdimx, unsigned int blockdimy);          /**         *  Copy constructor creates a new list as a copy of the data in otherlist         */        TwoDLinkedList(const TwoDLinkedList& otherlist);          /**         *  Overloaded assignment operator assigns structure and data of rhs into this list         *         *  @post this list is a physically separate copy of otherlist         */        TwoDLinkedList& operator=(const TwoDLinkedList& rhs);          /**         *  Destructor deallocates associated dynamic memory         */        ~TwoDLinkedList();          /**         *  Builds the structure of this list from the provided parameters.         *  The dimension of individual blocks will be an even division         *  of the input PNG's dimensions by blockdimx or blockdimy.         *  Assume that supplied PNG dimensions will be divisible by         *  blockdimx and blockdimy.         *         *  @pre PNG horizontal dimension is divisible by blockdimx         *  @pre PNG vertical dimension is divisible by blockdimy         *         *  Example: PNG dimensions 320x240         *           blockdimx = 4         *           blockdimy = 2         *           The constructed list will have the following Block and node structure:         *         *                +-----------+     +-----------+     +-----------+     +-----------+         *  northwest --> |           | –> |           | –> |           | –> |           |         *                |  80 x 120 |     |  80 x 120 |     |  80 x 120 |     |  80 x 120 |         *                |           | <-- |           | <-- |           | <-- |           |         *                +-----------+     +-----------+     +-----------+     +-----------+         *                   |     ^           |     ^           |     ^           |     ^           *                   v     |           v     |           v     |           v     |           *                +-----------+     +-----------+     +-----------+     +-----------+         *                |           | --> |           | –> |           | –> |           |         *                |  80 x 120 |     |  80 x 120 |     |  80 x 120 |     |  80 x 120 |         *                |           | <-- |           | <-- |           | <-- |           | <-- southeast         *                +-----------+     +-----------+     +-----------+     +-----------+         */        void Build(PNG& img, unsigned int blockdimx, unsigned int blockdimy);          /**         *  Returns the horizontal dimension of this list (in blocks)         */        unsigned int GetBlockDimensionX() const;          /**         *  Returns the vertical dimension of this list (in blocks)         */        unsigned int GetBlockDimensionY() const;          /**         *  Places this lists's color data into a PNG of appropriate dimensions         *  @param scale - integer multiplier for dimensions. 0 = scale by 0.5.         */        PNG Render(unsigned int scale) const;          /**         *  Reorganizes the list and node contents so that a rendered image will be flipped horizontally.         *  This must be achieved by pointer manipulation. Do not deallocate any existing nodes, and         *  do not allocate any new nodes.         *         *  Ensure that the integrity of north/south/east/west pointers of all nodes is maintained.         *         *  You may use up to O(n) time and space complexity, where n is the total number of nodes in the list.         *         *  Example: A, B, C, D etc. are physical nodes (each at a particular address)         *  before:         *   northwest -> A <-> B <-> C <-> D         *                ^     ^     ^     ^         *                v     v     v     v         *                E <-> F <-> G <-> H         *                ^     ^     ^     ^         *                v     v     v     v         *                I <-> J <-> K <-> L  <- southeast         *         *  after:         *   northwest -> D <-> C <-> B <-> A         *                ^     ^     ^     ^         *                v     v     v     v         *                H <-> G <-> F <-> E         *                ^     ^     ^     ^         *                v     v     v     v         *                L <-> K <-> J <-> I  <- southeast         */        void FlipHorizontal();      private:        #include "twodlinkedlist-private.h"  }; #endif My question is why i had error: use of undeclared identifier 'blockdimx' and 'blockdimy'

OR