Lab Assignment 9

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

Kevin Bennett

Our first task was to create a module, containing a Tree class, derived from the Shape class. I pretty much just followed the directions and ended up with a working Tree class. Here is the result of my test function (using systemF):

The second task was to create new shapes in the module and test them. I created a triangle, rectangle, pentagon, hexagon, and octagon, as well as separate filled versions of each of those, which the only difference being the istring having curly braces at either end. Here is the test code, containing all of my shapes, shaded and unshaded, and shapes of difference sizes and rotations:

The third task was to create a tile and grid of tiles. I found this fairly straightforward. My tile is a filled square with rotated filled triangles at each corner and a filled octagon in the middle, with a smaller, unfilled octagon inside that. It was interesting how the turtle messed up drawing the octagon if it got too small. Here is the drawing from my mosaic code (a 6x5 grid):

The last task was to create a scene module made up entirely of shapes and trees, containing a picture with trees in it. I used my tile mosaic code for the wallpaper, a filled rectangle for the floor, and two filled squares for a fireplace. Two filled rectangles were the wood in the fireplace. For the picture, I drew a gray square, then a green rectangle and blue rectangle for grass and sky. Three gray triangles made mountains and one light gray triangle was snow on the tallest mountain. For all of these shapes (including the wallpaper), I made the bottom-left corner be (x, y) with the exception of the second piece of fireplace wood, which was easier just to place using quick trial and error. Finally, I used two different types of trees in the picture. To systemG, I added leaves and placed its tree in four places on one horizontal plane. I added leaves and apples to systemF and placed three of them in between the systemG trees. Here is the picture I ended up with:

I really did not encounter too many problems while coding for this lab. I had to alter a little of the leaf color code in my drawString methd in, but beyond that, I didn't run into any major problems. I didn't learn anything drastically new while doing this lab, but did get more comfortable with classes and l-systems, etc.