Homework Solution: Create a c++ program implementing a class that represents “ASCII art” images and operations on t…

    Create a c++ program implementing a class that represents “ASCII art” images and operations on them, respresented as two-dimensional char arrays allocated on the heap (using the new keyword). Create a new C++ source file named canvas.cpp that implements the Canvas class, so that canvas.cpp and the provided files compile into a program that runs with no failed tests. Submit the source file canvas.cpp The main.cpp and canvas.h are provided, these files are not to be edited only used to impement canvas.cpp file. Only use basic c++ statements: if/else, for loops, while loops, basic arrays and pointers(*). main.cpp file:
    #include <string>
    #include <cstdlib>
    #include <iostream>
    #include "canvas.h"
    
    using namespace std;
    
    
    inline void _test(const char* expression, const char* file, int line)
    {
            cerr << "test(" << expression << ") failed in file " << file;
            cerr << ", line " << line << "." << endl;
            abort();
    }
    
    #define test(EXPRESSION) ((EXPRESSION) ? (void)0 : _test(#EXPRESSION, __FILE__, __LINE__))
    
    
    void interactive_mode(char ink, int scale)
    {
            cout << "Enter a string and press Enter ";
            cout << "to see the ASCII art version." << endl;
            while (cin)
            {
                    string line;
                    getline(cin, line);
                    string invalid_chars;
                    for (int i = 0; i < line.size(); ++i)
                            if (line[i] < 'A' || line[i] > 'D')
                                    invalid_chars += line[i];
                    if (invalid_chars.size() > 0)
                    {
                            cout << "    String contained invalid chars: ";
                            for (int i = 0; i < invalid_chars.size(); ++i)
                            {
                                    cout << "'" << invalid_chars[i] << "'";
                                    if (i != invalid_chars.size() - 1)
                                            cout << ", ";
                            }
                            cout << "." << endl;
                    }
                    else
                    {
                            Canvas C(line);
                            C.replace('#', ink);
                            for (int i = 1; i < scale; ++i)
                                    C.embiggen();
                            cout << C.to_string();
                    }
            }
    
            exit(0);
    }
    
    
    int main()
    {
            // Interactive mode.
            // Uncomment the "interactive_mode..." line below to 
            // use your Canvas implementation interactively.
            // 
            // The first parameter specifies the character used to fill letters.
            // The second parameter specifies how large the canvas is scaled.
            // 
            // interactive_mode('@', 2);
    
    
            Canvas C1(3, 3);
            test(C1.width() == 3);
            test(C1.height() == 3);
            test(C1.to_string() == string("   n") 
                                        + "   n"
                                        + "   n");
    
            Canvas C2(4, 6);
            test(C2.width() == 4);
            test(C2.height() == 6);
            test(C2.to_string() == string("    n")
                                        + "    n"
                                        + "    n"
                                        + "    n"
                                        + "    n"
                                        + "    n");
    
    
            Canvas C3('A');
            test(C3.width() == 5);
            test(C3.height() == 5);
            test(C3.to_string() == string(" ### n")
                                        + "#   #n"
                                        + "#####n"
                                        + "#   #n"
                                        + "#   #n");
    
            Canvas C4('B');
            test(C4.width() == 5);
            test(C4.height() == 5);
            test(C4.to_string() == string("#### n")
                                        + "#   #n"
                                        + "#### n"
                                        + "#   #n"
                                        + "#### n");
    
            Canvas C5('C');
            test(C5.width() == 5);
            test(C5.height() == 5);
            test(C5.to_string() == string(" ####n")
                                        + "#    n"
                                        + "#    n"
                                        + "#    n"
                                        + " ####n");
    
            Canvas C6('D');
            test(C6.width() == 5);
            test(C6.height() == 5);
            test(C6.to_string() == string("#### n")
                                        + "#   #n"
                                        + "#   #n"
                                        + "#   #n"
                                        + "#### n");
    
            Canvas C7('E');
            test(C7.width() == 5);
            test(C7.height() == 5);
            test(C7.to_string() == string("     n")
                                        + "     n"
                                        + "     n"
                                        + "     n"
                                        + "     n");
    
    
            C4.replace('#', '@');
            test(C4.to_string() == string("@@@@ n")
                                        + "@   @n"
                                        + "@@@@ n"
                                        + "@   @n"
                                        + "@@@@ n");
    
            C4.replace(' ', '-');
            test(C4.to_string() == string("@@@@-n")
                                        + "@---@n"
                                        + "@@@@-n"
                                        + "@---@n"
                                        + "@@@@-n");
    
            C4.replace('-', '@');
            test(C4.to_string() == string("@@@@@n")
                                        + "@@@@@n"
                                        + "@@@@@n"
                                        + "@@@@@n"
                                        + "@@@@@n");
    
            Canvas C8(2, 6);
            C8.replace(' ', 'X');   
            test(C8.to_string() == string("XXn")
                                        + "XXn"
                                        + "XXn"
                                        + "XXn"
                                        + "XXn"
                                        + "XXn");
    
            
            Canvas C9('A');
            C9.embiggen();
            test(C9.width() == 10); 
            test(C9.height() == 10);        
            test(C9.to_string() == string("  ######  n")
                                        + "  ######  n"
                                        + "##      ##n"
                                        + "##      ##n"
                                        + "##########n"
                                        + "##########n"
                                        + "##      ##n"
                                        + "##      ##n"
                                        + "##      ##n"
                                        + "##      ##n");
            
            Canvas C10('B');
            C10.embiggen();
            test(C10.width() == 10);        
            test(C10.height() == 10);       
            test(C10.to_string() == string("########  n")
                                         + "########  n"
                                         + "##      ##n"
                                         + "##      ##n"
                                         + "########  n"
                                         + "########  n"
                                         + "##      ##n"
                                         + "##      ##n"
                                         + "########  n"
                                         + "########  n");
    
            Canvas C11(2, 3);
            C11.embiggen();
            test(C11.width() == 4); 
            test(C11.height() == 6);        
            C11.embiggen();
            test(C11.width() == 8); 
            test(C11.height() == 12);       
            C11.embiggen();
            test(C11.width() == 16);        
            test(C11.height() == 24);       
    
    
            Canvas C12("A");
            test(C12.width() == 5); 
            test(C12.height() == 5);        
            test(C12.to_string() == string(" ### n")
                                         + "#   #n"
                                         + "#####n"
                                         + "#   #n"
                                         + "#   #n");
    
            Canvas C13("AB");
            test(C13.width() == 12);        
            test(C13.height() == 5);        
            test(C13.to_string() == string(" ###   #### n")
                                         + "#   #  #   #n"
                                         + "#####  #### n"
                                         + "#   #  #   #n"
                                         + "#   #  #### n");
    
            Canvas C14("CAB");
            test(C14.width() == 19);        
            test(C14.height() == 5);        
            test(C14.to_string() == string(" ####   ###   #### n")
                                         + "#      #   #  #   #n"
                                         + "#      #####  #### n"
                                         + "#      #   #  #   #n"
                                         + " ####  #   #  #### n");
    
            Canvas C15("!BAD!");
            test(C15.width() == 33);        
            test(C15.height() == 5);        
            test(C15.to_string() == string("       ####    ###   ####        n")
                                         + "       #   #  #   #  #   #       n"
                                         + "       ####   #####  #   #       n"
                                         + "       #   #  #   #  #   #       n"
                                         + "       ####   #   #  ####        n");
    
            Canvas C16("DAD CAB");
            test(C16.width() == 47);        
            test(C16.height() == 5);        
            test(C16.to_string() == string("####    ###   ####           ####   ###   #### n")
                                         + "#   #  #   #  #   #         #      #   #  #   #n"
                                         + "#   #  #####  #   #         #      #####  #### n"
                                         + "#   #  #   #  #   #         #      #   #  #   #n"
                                         + "####   #   #  ####           ####  #   #  #### n");
    
            cout << "Assignment complete." << endl;
    }
    
    canvas.h file:
    #ifndef CANVAS_H
    #define CANVAS_H
    
    #include <string>
    
    using namespace std;
    
    
    // In this homework, you'll manipulate ASCII art images
    // consisting of a rectangular grid of chararacter pixels. 
    class Canvas
    {
            public:
                    // Allocates a canvas of the given width and height
                    // consisting of ' ' chars.
                    Canvas(int width, int height);
    
                    // Allocates a canvas with width 5 and height 5 that looks like:
                    //
                    //  ###       ####        ####     ####
                    // #   #      #   #      #         #   #
                    // #####  or  ####   or  #      or #   #
                    // #   #      #   #      #         #   #
                    // #   #      ####        ####     ####
                    //
                    // depending upon which character ('A', 'B', 'C', or 'D') is 
                    // given as a parameter. If some other character is given, 
                    // allocates a canvas of ' ' chars with width 5 and height 5.
                    Canvas(char x); 
    
                    // Allocates a canvas containing the sequence of characters
                    // in the string with 2 columns of space between each pair 
                    // of adjacent characters. For instance, Canvas("BADCAB") 
                    // should yield:
                    //
                    // ####    ###   ####    ####   ###   ####  
                    // #   #  #   #  #   #  #      #   #  #   #
                    // ####   #####  #   #  #      #####  ####
                    // #   #  #   #  #   #  #      #   #  #   # 
                    // ####   #   #  ####    ####  #   #  #### 
                    // 
                    // Any characters in s not from {'A', 'B', 'C', 'D'} should be 
                    // replaced with empty 5x5 space, just like previous constructor.
                    Canvas(string s);
                            
                    // Returns the width of the canvas.
                    int width();
    
                    // Returns the height of the canvas.
                    int height(); 
    
                    // Returns the entire canvas as a single string, consisting of each row
                    // of the canvas, followed by endl.
                    string to_string(); 
                    
                    // Replaces every instance in the canvas of old_char with new_char.
                    // For instance, if old_char is '#' and new char is '@', then: 
                    // 
                    //  ###             @@@
                    // #   #           @   @
                    // #####  becomes  @@@@@ 
                    // #   #           @   @
                    // #   #           @   @
                    //
                    void replace(char old_char, char new_char);
    
                    // Returns a new canvas twice the width and height, where each pixel 
                    // in the old canvas corresponds to a 2x2 region of pixels in the new canvas. 
                    // 
                    // For instance:
                    //
                    //  ###              ######
                    // #   #             ######
                    // #####  becomes  ##      ##
                    // #   #           ##      ##
                    // #   #           ##########
                    //                 ##########
                    //                 ##      ##
                    //                 ##      ##
                    //                 ##      ##
                    //                 ##      ##
                    //
                    void embiggen();
                    
                    // Destructor. Deallocates all of the memory allocated by the canvas.
                    ~Canvas();
    
            private:
                    // A canvas is represented as a 2D char array, i.e. 
                    // an array of pointers to char (sub)arrays.
                    // Each subarray corresponds to a column of the image.
                    char** C;
                    int _width;
                    int _height;
    };
    
    #endif
    

    Expert Answer

     
    #include <string> #include <cstdlib>

    Create a c++ program implementing a rank that represents “ASCII trade” effigys and operations on them, respresented as two-dimensional char disposes fullocated on the concretion (using the odd keyword).

    Create a odd C++ rise refine named canvas.cpp that implements the Canvas rank, so that canvas.cpp and the granted refines pacify into a program that runs with no failed trials. Submit the rise refine canvas.cpp

    The ocean.cpp and canvas.h are granted, these refines are not attributable attributable attributable attributable attributable attributable to be edited simply representationd to impement canvas.cpp refine. Simply representation basic c++ statements: if/else, restraint loops, period loops, basic disposes and pointers(*).

    main.cpp refine:

    #include <string>
    #include <cstdlib>
    #include <iostream>
    #include "canvas.h"
    
    using nameinterillimitableness std;
    
    
    indirection unsubstantial _test(const char* countenance, const char* refine, int direction)
    {
            cerr << "test(" << countenance << ") failed in refine " << refine;
            cerr << ", direction " << direction << "." << endl;
            abort();
    }
    
    #define trial(EXPRESSION) ((EXPRESSION) ? (void)0 : _test(#EXPRESSION, __FILE__, __LINE__))
    
    
    unsubstantial interactive_mode(char ink, int layer)
    {
            cout << "Enter a string and crowd Enter ";
            cout << "to descry the ASCII trade statement." << endl;
            period (cin)
            {
                    string direction;
                    getline(cin, direction);
                    string frail_chars;
                    restraint (int i = 0; i < direction.size(); ++i)
                            if (line[i] < 'A' || direction[i] > 'D')
                                    frail_chars += direction[i];
                    if (invalid_chars.size() > 0)
                    {
                            cout << "    String contained frail chars: ";
                            restraint (int i = 0; i < frail_chars.size(); ++i)
                            {
                                    cout << "'" << frail_chars[i] << "'";
                                    if (i != frail_chars.size() - 1)
                                            cout << ", ";
                            }
                            cout << "." << endl;
                    }
                    else
                    {
                            Canvas C(line);
                            C.replace('#', ink);
                            restraint (int i = 1; i < layer; ++i)
                                    C.embiggen();
                            cout << C.to_string();
                    }
            }
    
            egress(0);
    }
    
    
    int ocean()
    {
            // Interactive legislation.
            // Uncomment the "interactive_mode..." direction adown to 
            // representation your Canvas implementation interactively.
            // 
            // The leading parameter specifies the species representationd to stuff learning.
            // The succor parameter specifies how vast the canvas is layerd.
            // 
            // interactive_mode('@', 2);
    
    
            Canvas C1(3, 3);
            trial(C1.width() == 3);
            trial(C1.height() == 3);
            trial(C1.to_string() == string("   n") 
                                        + "   n"
                                        + "   n");
    
            Canvas C2(4, 6);
            trial(C2.width() == 4);
            trial(C2.height() == 6);
            trial(C2.to_string() == string("    n")
                                        + "    n"
                                        + "    n"
                                        + "    n"
                                        + "    n"
                                        + "    n");
    
    
            Canvas C3('A');
            trial(C3.width() == 5);
            trial(C3.height() == 5);
            trial(C3.to_string() == string(" ### n")
                                        + "#   #n"
                                        + "#####n"
                                        + "#   #n"
                                        + "#   #n");
    
            Canvas C4('B');
            trial(C4.width() == 5);
            trial(C4.height() == 5);
            trial(C4.to_string() == string("#### n")
                                        + "#   #n"
                                        + "#### n"
                                        + "#   #n"
                                        + "#### n");
    
            Canvas C5('C');
            trial(C5.width() == 5);
            trial(C5.height() == 5);
            trial(C5.to_string() == string(" ####n")
                                        + "#    n"
                                        + "#    n"
                                        + "#    n"
                                        + " ####n");
    
            Canvas C6('D');
            trial(C6.width() == 5);
            trial(C6.height() == 5);
            trial(C6.to_string() == string("#### n")
                                        + "#   #n"
                                        + "#   #n"
                                        + "#   #n"
                                        + "#### n");
    
            Canvas C7('E');
            trial(C7.width() == 5);
            trial(C7.height() == 5);
            trial(C7.to_string() == string("     n")
                                        + "     n"
                                        + "     n"
                                        + "     n"
                                        + "     n");
    
    
            C4.replace('#', '@');
            trial(C4.to_string() == string("@@@@ n")
                                        + "@   @n"
                                        + "@@@@ n"
                                        + "@   @n"
                                        + "@@@@ n");
    
            C4.replace(' ', '-');
            trial(C4.to_string() == string("@@@@-n")
                                        + "@---@n"
                                        + "@@@@-n"
                                        + "@---@n"
                                        + "@@@@-n");
    
            C4.replace('-', '@');
            trial(C4.to_string() == string("@@@@@n")
                                        + "@@@@@n"
                                        + "@@@@@n"
                                        + "@@@@@n"
                                        + "@@@@@n");
    
            Canvas C8(2, 6);
            C8.replace(' ', 'X');   
            trial(C8.to_string() == string("XXn")
                                        + "XXn"
                                        + "XXn"
                                        + "XXn"
                                        + "XXn"
                                        + "XXn");
    
            
            Canvas C9('A');
            C9.embiggen();
            trial(C9.width() == 10); 
            trial(C9.height() == 10);        
            trial(C9.to_string() == string("  ######  n")
                                        + "  ######  n"
                                        + "##      ##n"
                                        + "##      ##n"
                                        + "##########n"
                                        + "##########n"
                                        + "##      ##n"
                                        + "##      ##n"
                                        + "##      ##n"
                                        + "##      ##n");
            
            Canvas C10('B');
            C10.embiggen();
            trial(C10.width() == 10);        
            trial(C10.height() == 10);       
            trial(C10.to_string() == string("########  n")
                                         + "########  n"
                                         + "##      ##n"
                                         + "##      ##n"
                                         + "########  n"
                                         + "########  n"
                                         + "##      ##n"
                                         + "##      ##n"
                                         + "########  n"
                                         + "########  n");
    
            Canvas C11(2, 3);
            C11.embiggen();
            trial(C11.width() == 4); 
            trial(C11.height() == 6);        
            C11.embiggen();
            trial(C11.width() == 8); 
            trial(C11.height() == 12);       
            C11.embiggen();
            trial(C11.width() == 16);        
            trial(C11.height() == 24);       
    
    
            Canvas C12("A");
            trial(C12.width() == 5); 
            trial(C12.height() == 5);        
            trial(C12.to_string() == string(" ### n")
                                         + "#   #n"
                                         + "#####n"
                                         + "#   #n"
                                         + "#   #n");
    
            Canvas C13("AB");
            trial(C13.width() == 12);        
            trial(C13.height() == 5);        
            trial(C13.to_string() == string(" ###   #### n")
                                         + "#   #  #   #n"
                                         + "#####  #### n"
                                         + "#   #  #   #n"
                                         + "#   #  #### n");
    
            Canvas C14("CAB");
            trial(C14.width() == 19);        
            trial(C14.height() == 5);        
            trial(C14.to_string() == string(" ####   ###   #### n")
                                         + "#      #   #  #   #n"
                                         + "#      #####  #### n"
                                         + "#      #   #  #   #n"
                                         + " ####  #   #  #### n");
    
            Canvas C15("!BAD!");
            trial(C15.width() == 33);        
            trial(C15.height() == 5);        
            trial(C15.to_string() == string("       ####    ###   ####        n")
                                         + "       #   #  #   #  #   #       n"
                                         + "       ####   #####  #   #       n"
                                         + "       #   #  #   #  #   #       n"
                                         + "       ####   #   #  ####        n");
    
            Canvas C16("DAD CAB");
            trial(C16.width() == 47);        
            trial(C16.height() == 5);        
            trial(C16.to_string() == string("####    ###   ####           ####   ###   #### n")
                                         + "#   #  #   #  #   #         #      #   #  #   #n"
                                         + "#   #  #####  #   #         #      #####  #### n"
                                         + "#   #  #   #  #   #         #      #   #  #   #n"
                                         + "####   #   #  ####           ####  #   #  #### n");
    
            cout << "Assignment adequate." << endl;
    }
    

    canvas.h refine:

    #ifndef CANVAS_H
    #define CANVAS_H
    
    #include <string>
    
    using nameinterillimitableness std;
    
    
    // In this homework, you will treat ASCII trade effigys
    // consisting of a across grid of chararacter pixels. 
    rank Canvas
    {
            public:
                    // Fullocates a canvas of the absorbed width and tallness
                    // consisting of ' ' chars.
                    Canvas(int width, int tallness);
    
                    // Fullocates a canvas with width 5 and tallness 5 that looks enjoy:
                    //
                    //  ###       ####        ####     ####
                    // #   #      #   #      #         #   #
                    // #####  or  ####   or  #      or #   #
                    // #   #      #   #      #         #   #
                    // #   #      ####        ####     ####
                    //
                    // depending upon which species ('A', 'B', 'C', or 'D') is 
                    // absorbed as a parameter. If some other species is absorbed, 
                    // fullocates a canvas of ' ' chars with width 5 and tallness 5.
                    Canvas(char x); 
    
                    // Fullocates a canvas containing the progression of speciess
                    // in the string with 2 posts of interinterillimitableness between each two 
                    // of nigh speciess. Restraint solicitation, Canvas("BADCAB") 
                    // should yield:
                    //
                    // ####    ###   ####    ####   ###   ####  
                    // #   #  #   #  #   #  #      #   #  #   #
                    // ####   #####  #   #  #      #####  ####
                    // #   #  #   #  #   #  #      #   #  #   # 
                    // ####   #   #  ####    ####  #   #  #### 
                    // 
                    // Any speciess in s not attributable attributable attributable attributable attributable attributable from {'A', 'B', 'C', 'D'} should be 
                    // re-establishd with vacuity 5x5 interspace, normal enjoy foregoing maker.
                    Canvas(string s);
                            
                    // Returns the width of the canvas.
                    int width();
    
                    // Returns the tallness of the canvas.
                    int tallness(); 
    
                    // Returns the integral canvas as a separate string, consisting of each order
                    // of the canvas, followed by endl.
                    string to_string(); 
                    
                    // Re-establishs whole solicitation in the canvas of antiquated_char with odd_char.
                    // Restraint solicitation, if antiquated_char is '#' and odd char is '@', then: 
                    // 
                    //  ###             @@@
                    // #   #           @   @
                    // #####  becomes  @@@@@ 
                    // #   #           @   @
                    // #   #           @   @
                    //
                    unsubstantial re-establish(char antiquated_char, char odd_char);
    
                    // Returns a odd canvas twice the width and tallness, where each pixel 
                    // in the antiquated canvas corresponds to a 2x2 territory of pixels in the odd canvas. 
                    // 
                    // Restraint solicitation:
                    //
                    //  ###              ######
                    // #   #             ######
                    // #####  becomes  ##      ##
                    // #   #           ##      ##
                    // #   #           ##########
                    //                 ##########
                    //                 ##      ##
                    //                 ##      ##
                    //                 ##      ##
                    //                 ##      ##
                    //
                    unsubstantial embiggen();
                    
                    // Destructor. Deallocates full of the recollection fullocated by the canvas.
                    ~Canvas();
    
            private:
                    // A canvas is represented as a 2D char dispose, i.e. 
                    // an dispose of pointers to char (sub)arrays.
                    // Each subdispose corresponds to a post of the effigy.
                    char** C;
                    int _width;
                    int _height;
    };
    
    #endif
    

    Expert Rejoinder

     

    #include <string>

    #include <cstdlib>

    #include <iostream>

    #include “canvas.h”

    unsubstantial Canvas :: Canvas(int width, int tallness)

    {

    char *temp;

    temp = (char *)malloc(sizeof(char) * width);

    C = (char **)malloc(sizeof(temp)*height);

    }

    unsubstantial Canvas :: Canvas(char x)

    {

    char *temp;

    int i;

    temp = (char *)malloc(sizeof(char) * 5);

    C = (char **)malloc(sizeof(temp)*5);

    width = 5;

    tallness = 5;

    string s1,s2,s3,s4,s5;

    if(x==’A’)

    {

    s1+ = ” ### “;

    s2+ = ” # # “;

    s3+ = “#####”;

    s4+ = ” # # “;

    s5+ = ” # # “;

    }

    else if(x==’B’)

    {

    s1+ = “#### “;

    s2+ = “# #”;

    s3+ = “#####”;

    s4+ = “# #”;

    s5+ = “#### “;

    }

    else if(x==’C’)

    {

    s1+ = ” ####”;

    s2+ = “# “;

    s3+ = ” “;

    s4+ = “# “;

    s5+ = ” ####”;

    }

    else if(x==’D’)

    {

    s1+ = “#### “;

    s2+ = “# #”;

    s3+ = “# #”;

    s4+ = “# #”;

    s5+ = “#### “;

    }

    for(i=0;i<5;i++)

    C[0][i] = s1[i];

    for(i=0;i<5;i++)

    C[1][i] = s2[i];

    for(i=0;i<5;i++)

    C[2][i] = s3[i];

    for(i=0;i<5;i++)

    C[3][i] = s4[i];

    for(i=0;i<5;i++)

    C[4][i] = s5[i];

    }

    unsubstantial Canvas :: Canvas(string S)

    {

    int len = S.length();

    char *temp;

    int j =0;

    temp = (char *)malloc(sizeof(char) *5*len);

    C = (char **)malloc(sizeof(temp)*5);

    string s1,s2,s3,s4,s5;

    width = 5*len;

    tallness = 5;

    for(int i=0;i<len;i++,j=j+5)

    {

    char x = S[i];

    if(x==’A’)

    {

    s1+ = ” ### “;

    s2+ = ” # # “;

    s3+ = “#####”;

    s4+ = ” # # “;

    s5+ = ” # # “;

    }

    else if(x==’B’)

    {

    s1+ = “#### “;

    s2+ = “# #”;

    s3+ = “#####”;

    s4+ = “# #”;

    s5+ = “#### “;

    }

    else if(x==’C’)

    {

    s1+ = ” ####”;

    s2+ = “# “;

    s3+ = ” “;

    s4+ = “# “;

    s5+ = ” ####”;

    }

    else if(x==’D’)

    {

    s1+ = “#### “;

    s2+ = “# #”;

    s3+ = “# #”;

    s4+ = “# #”;

    s5+ = “#### “;

    }

    else

    {

    s1+ = ” “;

    s2+ = ” “;

    s3+ = ” “;

    s4+ = ” “;

    s5+ = ” “;

    }

    }

    for(j=0;j<len*5;j++)

    C[0][j] = s1[j];

    for(j=0;j<len*5;j++)

    C[1][j] = s2[j];

    for(j=0;j<len*5;j++)

    C[2][j] = s3[j];

    for(j=0;j<len*5;j++)

    C[3][j] = s4[j];

    for(j=0;j<len*5;j++)

    C[4][j] = s5[j];

    }

    int Canvas:: width()

    {

    return width;

    }

    int Canvas:: tallness()

    {

    return tallness;

    }

    string Canvas::to_string()

    {

    int order = 0,col;

    string ans;

    while(row<height)

    {

    col = 0;

    while(col<width)

    {

    if(C[row+3][col+1] == ‘#’)

    ans += ‘A’;

    else if(C[row+2][col+2] == ‘#’)

    ans += ‘B’;

    else if(C[row+2][col] == ‘#’)

    ans+= ‘D’;

    else

    ans += ‘C’;

    col = col + 5;

    }

    ans += ‘n’;

    order = order + 5;

    }

    return ans;

    }

    unsubstantial Canvas :: re-establish(char antiquated_char, char odd_char)

    {

    int i,j;

    for(i=0;i<width;i++)

    {

    for(j=0;j<height;j++)

    {

    if(C[i][j] == antiquated_char)

    C[i][j] = odd_char;

    }

    }

    }

    Canvas :: ~Canvas()

    {

    int i;

    for(i=height-1;i>=0;i–)

    delete(C[i]);

    width = 0;

    tallness = 0;

    }