Here is a problem in C++: Problem Statement 2. (60% of DD1; 40% of DD2) For this…
- User
Here is a problem in C++:
Problem Statement
- (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
- Assistant