Question: (Jython Code) Currently, the function only allows the pattern to be added on to empty picture objects of a fixed size. The end result is

 (Jython Code) Currently, the function only allows the pattern to be

(Jython Code) Currently, the function only allows the pattern to be added on to empty picture objects of a fixed size. The end result is also shown on the screen and cannot be used outside of the function. The function is less reusable/general due these reasons. Your task is to overcome the above limitations by re-writing this function in a more general and reusable form. Your new code must meet the following requirements:

1. The function must take the width and height of the picture object to be created as its parameters and draw the pattern relative to these values. It must not take any other parameters or any other inputs.

2. Assume that only valid parameter values will be passed in to the function. You must not validate any values. The logic of the pattern must be valid on any (valid) combination of parameter values.

3. The picture must not be displayed.

def makePattern picture-makeEmptyPicture (600,400) # addRect usage: addRect (picture,startx,starti, rectWidth, rectHeight) addRect (picture, 0,0,600, 400) addRect (picture, 150,100, 300,200) addRect (picture, 225,150,150,100) repaint (picture)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!