Finish the Joe the Box example.

(a) Implement grow and move. The method move takes as input a relative distance like (?10,15) to move 10 pixels left (x position) and 15 pixels down (y position).
(b) Draw patterns by creating joe and jane, then move a little and draw, grow a little and draw, then repaint the new canvas.


(a) ```
class Box:

def move(self, x, y):
xPos = self.position[0]
yPos = self.position[1]
xPos = xPos + x
yPos = yPos + y

self.position = (xPos, yPos)
```

(b) ```
def makePattern():
jane = SadBox ()
joe = Box ()
canvas = makeEmptyPicture(300,300)
canvas.show()
for i in range(0, 30):
jane.move(i, 0)
joe.move(0,i)
jane.draw(canvas)
joe.draw(canvas)

repaint(canvas)
joe.grow(i)
jane.grow(i)
jane.draw(canvas)
joe.draw(canvas)

repaint(canvas)
```

Computer Science & Information Technology

You might also like to view...

Why is a double linked list used for a queue data structure?

a. Because a queue enqueues and dequeues elements at both ends. b. Because a double linked list is simpler to implement. c. For a queue to have LIFO ordering. d. To make a queue searchable.

Computer Science & Information Technology

An informal report is written to assist with making better business decisions

Indicate whether the statement is true or false

Computer Science & Information Technology

Approximates a first order differential equation using the classical fourth order Runge-Kutta method

What will be an ideal response?

Computer Science & Information Technology

____provide descriptive text for the individual data markers, such as pie slices

A. Asset labels B. Legend values C. Data labels D. Leader lines

Computer Science & Information Technology