Create a CartoonPanel class that takes an array of Pictures and displays the pictures from left to right. It should also have a title and author, and display the title at the top left edge and the author at the top right edge.
What will be an ideal response?
```
class CartoonPanel:
def __init__(self, picturesArray, title, author):
self.pictures = picturesArray
sumWidth = 0
maxHeight = 0
for p in picturesArray:
w = getWidth(p)
h = getHeight(p)
sumWidth = sumWidth+w
if h>maxHeight:
maxHeight = h
canvas = makeEmptyPicture(sumWidth, maxHeight+50)
currX = 0
for p in picturesArray:
copy(p, canvas, currX, 50)
currX =currX+ getWidth(p)
canvas.addText(black, 1,20, title)
canvas.addText(black, currX-100,20,author)
self.panel = canvas
def show(self):
show(self.panel)
def copy(source, target, targX, targY):
targetX = targX
for sourceX in range(0,getWidth(source)):
targetY = targY
for sourceY in range(0,getHeight(source)):
px=getPixel(source ,sourceX ,sourceY)
tx=getPixel(target ,targetX ,targetY)
setColor(tx,getColor(px))
targetY=targetY + 1
targetX=targetX + 1
```
You might also like to view...
What is the content of the Xfile after the following command is executed? ls > Xfile
a: nothing b: the word ls c: list of the filenames in the current directory d: an error message e: none of the above
A variable declared inside a class, but outside a method, is called a(n) _________
a) local variable b) hidden variable c) instance variable d) constant variable
Service bureaus use the term _________________________ to describe those gaps in printing that are out of the printer’s register or alignment.
Fill in the blank(s) with the appropriate word(s).
The _________ execute micro-operations, fetching the required data from the L1 data cache and temporarily storing results in registers.
A. execution units B. memory subsystem C. out-of-order execution logic D. fetch/decode unit