Here is a problem in C++:

## Problem Statement
2. (60% of DD1; 40% of DD2) For this question: use #includes. Compile your program with g++20.
In this question you will be building a fun ASCII art drawing and animation program! You’ll start with a blank canvas
(files studio.{h,cc}), and will draw rectangles consisting of characters of your choosing on that canvas (remember
that any point is a 1x1 rectangle, so you can draw anything!), and choose how your drawing will evolve with time. The
rectangles may be larger than the canvas, and may disappear from the canvas by moving outside the canvas boundaries.
The key to the functioning of this program is the Decorator design pattern. A blank canvas (files blank.{h,cc})
will respond with a blank space to any query about the contents of a cell at a particular row or column. However,
it can be decorated by rectangles, which will respond in their own way to the same query, or will pass it along to the
ASCII art element behind them. (See the provided file boxdimensions.pdf for an explanation of how the rectangle
dimensions are specified and drawn.)
Moreover, the key to the animation aspect of this program is that the response to a query for a cell can be time-varying.
So a query to a cell actually involves three parameters: the row, the column, and the tick count. The tick count is an
abstraction of a clock that represents the number of rendering events that have occurred since the last time the animation
was reset. There’s an internal counter representing how many “ticks” have elapsed so far, and each call to “render”
advances the tick counter (clock) by 1. “reset” puts it back to 0.
You are to support the following kinds of ASCII art elements:
Page 2 of 4
ASSIGNMENT #4: DESIGN PATTERNS CS246, FALL 2024
• filled box: A simple solid rectangle, specified by top and bottom row (inclusive) and left and right column (inclu-
sive). Does not move.
• blinking box: A box that is displayed when the tick count is even, and is transparent otherwise.
• moving box: A box that moves one position (either up, down, left, or right) with each tick.
• mask box: A box that is invisible unless there is a visible art element beneath it. In that case, the part of the mask
that lies above the art below becomes visible and covers that art. Does not move.
The provided starter code comes with a test harness main.cc that supports the following commands:
• render — causes the current artwork to be displayed, with a frame around it, so that the boundaries are clear
(see the provided executable for details). Counts as a tick.
• animate n — renders the artwork n times, where n must be ≥0.
• reset — resets the tick count to 0.
• filledbox t b l r c — adds a filled box with given top, bottom, left, right boundaries, filled with the
character c (assumed to be printable ASCII in the range 33–127). Invalid if top exceeds bottom or left exceeds
right.
• blinkingbox t b l r c — adds a blinking box, with parameters understood as above.
• movingbox t b l r c dir — adds a moving box, with first five parameters understood as above and a
direction dir, which can be one of u d l r. Clarification: These parameters are understood to be the position
of the box when the tick count is 0. If the tick count is not 0 when the moving box is placed, it will show up shifted
by a number of positions equal to the current tick count.
• maskbox t b l r c — adds a mask, with parameters understood as above.
Note: Some implementation notes for this problem can be found in the provided README.txt. Be sure to read and
follow it!
Important: As the point of this problem is to use the Decorator design pattern, if your solution is found in hand-marking
to not employ the Decorator design pattern, your correctness marks from Marmoset will be revoked.
Note: Your program should be well documented and employ proper programming style. It should not leak memory.
Markers will be checking for these things.
a) Due on Due Date 1: Submit your test suite (suiteq2.txt and all necessary files) in the file a4q2a.zip

## Blank

#ifndef BLANK_H
#define BLANK_H
#include "asciiart.h"
#include <iostream>

class Blank: public AsciiArt {
 public:
  char charAt(int row, int col, int tick) override;
};

#endif

#include "blank.h"
#include <iostream>

char Blank::charAt(int row, int col, int tick) { return ' '; }



## AsciiArt

#ifndef ASCIIART_H
#define ASCIIART_H
#include <iostream>

class AsciiArt {
 public:
   virtual ~AsciiArt();

   virtual char charAt(int row, int col, int tick) = 0;
};

#endif
#include "asciiart.h"
#include <iostream>

AsciiArt::~AsciiArt() {}

## Studio

#ifndef STUDIO_H
#define STUDIO_H
#include <iostream>
class AsciiArt;

class Studio {
  int rows = 10, cols = 10, ticks = 0;
  std::ostream &out = std::cout;

  AsciiArt *thePicture;

 public:
  explicit Studio(AsciiArt *picture): thePicture{picture} {}

  AsciiArt *&picture() { return thePicture; }
  void reset();
  void render();
  void animate(int numTicks);
  ~Studio();
};

#endif
#include "studio.h"
#include "asciiart.h"

void Studio::reset() { ticks = 0; }

void Studio::render() {
  out << '+';
  for (int j = 0; j < cols; ++j) out << '-';
  out << '+' << std::endl;
  for (int i = 0; i < rows; ++i) {
    out << '|';
    for (int j = 0; j < cols; ++j) {
      out << picture()->charAt(i, j, ticks);
    }
    out << '|' << std::endl;
  }
  out << '+';
  for (int j = 0; j < cols; ++j) out << '-';
  out << '+' << std::endl;
  ++ticks;
}

void Studio::animate(int numTicks) {
  for (int i = 0; i < numTicks; ++i) render();
}

Studio::~Studio() { delete thePicture; }


## Testing Harness (main.cc)

#include <iostream>
#include "asciiart.h"
#include "blank.h"
#include "studio.h"

int main () {
  AsciiArt *canvas = new Blank;

  Studio s{canvas};

  std::string command;

  while (std::cin >> command) {
    if (command == "render" ) {
      s.render();
    }
    else if (command == "animate") {
      int n;
      std::cin >> n;
      s.animate(n);
    }
    else if (command == "reset") {
      s.reset();
    }
    else if (command == "filledbox") {
      int top, bottom, left, right;
      char what;
      std::cin >> top >> bottom >> left >> right >> what;

    }
    else if (command == "blinkingbox") {
      int top, bottom, left, right;
      char what;
      std::cin >> top >> bottom >> left >> right >> what;

    }
    else if (command == "movingbox") {
      int top, bottom, left, right;
      char what, dir;
      std::cin >> top >> bottom >> left >> right >> what >> dir;

    }
    else if (command == "maskbox") {
      int top, bottom, left, right;
      char what;
      std::cin >> top >> bottom >> left >> right >> what;

    }
  }
}

## Instructions
Create 10-20 tests (or more if necessary) that properly test the functionality of this program including any and all edge cases. State each case/testing functionality. I will also present you with a sample test below.

## Sample Test
filledbox 0 5 3 5 A
render
movingbox 3 8 0 5 B r
animate 5