CS172 - Lab5 - A Winter Wonderland In this lab we'll use OOP for graphics programming and add some interactivity to the application Your Classes

CS172 - Lab5 - A Winter Wonderland In this lab we'll...

This preview shows page 1 - 3 out of 7 pages.

A Winter Wonderland In this lab, we'll use OOP for graphics programming and add some interactivity to the application. Your Classes The Drawable Class In this week's lecture we discussed how we can used object oriented programming concepts to make graphics applications more organized and easier to create. One of the things that we'll leverage is inheritance, polymorphism, and abstract base classes. We have included drawable.py that contains an abstract base class called (shocker) Drawable This class has the following methods: A constructor ( __init__ ) method where you can set the x and y locations for your object. Accessor and mutator methods for the x and y locations. An abstract method called draw that takes a surface to draw on as a parameter. Rectangle class Now we're going to derive from this class. The first derived class you'll want to make is Rectangle To instantiate the Rectangle class you need: The (x,y) location where the Rectangle is to be drawn It's width and height It's color Then in the class's draw method you draw a rectangle starting at (x,y) of dimensions (width, height) on the surface in the chosen color. NOTE: For credit you must derive from Drawable and use it's constructor. The Snowflake Class Next up let's create a Snowflake!
A Snowflake will be made up of 4 lines. If the Snowflake is to be centered at (x,y) then those four lines are

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture