- Write a paragraph to explain what you did in order to create the pezant. In your explanation use each of the terms appearing in the "concept summary" of chapter 21 on page 16. Highlight the terms in the paragraph.
I first created a new class called box, so I could create a rectangle to create the body, the arms, and the legs. Since the Square class is a square figure, and the Box class is to be a rectangle, I copied the code from class Square into class Box. To evert confusions and problems, I clicked the ‘find and replace’ button on my computer and replaced all found ‘Square’ with the string ‘Box’. I tested out the box, by invoking method draw(). This showed me the box object, but it was in the shape of a circle, therefore I replaced the size field with a width field and a height field. I then edited the code so that I could create rectangular (Box) Objects. After the first Box was made, I corrected the size until it would be almost perfect to what the picture had shown us. Then I centered it by trying out horizontal and vertical numbers. After the first Box was made, named ‘body’, I created another public class called arms. I did the exact same thing for both the arms, and then for both the legs, as I did for the body (with adjustments to the size and placement). I then completed the body, and went on to create a circle, for a head. This was quite easy, but because I accidentally deleted my Circle class, it took a while. But after I received the coding for the Circle class again, I just named it face or I could keep it sun, and move it horizontally and vertically till it reaches the top end tip of the body. I changed the color green in the coding box, and went on to the Triangle class. I did the same as I did for the Circle and just moved it horizontally and vertically till it reached the top end tip of the head. I did not have to change the hat size because it was in proportion. I then clicked compile, checked for any errors, and invoked new Picture() and invoked void draw(). The pezant was completed.
No comments:
Post a Comment