#### Module 11

Last updated: Wed, 8 Apr 2015 15:29:36 -0400

##### Supplemental Materials
• Note: These slides are from a previous semester. We provide them because learning is often aided by looking at different presentations of the same material. However, previous iterations of the course had a different structure and different style requirements. Read these slides for their ideas only. When there are discrepancies, follow the rules of our current course.
• CS5010f14: Classes, Objects, and Methods [pptx] [pdf]

• CS5010f14: Interfaces [pptx] [pdf]

• CS5010f14: Functions vs Classes [pptx] [pdf]

• CS5010f14: Design Recipe Using Classes [pptx] [pdf]

• CS5010f14: Testing Simple Objects [pptx] [pdf]

• CS5010f14: Observables vs Fields [pptx] [pdf]

• CS3500sp15: The Essence of Objects

##### Goals
• Understand the key concepts of object-oriented programming.

• Understand how interfaces and classes relate to the course materials thus far.

• Understand how to properly define interfaces and classes in Racket.

• Understand the tradeoffs between OOP and the function-based programs you have written in this course so far.

##### In-class

Define Circle%, Square%, and Composite% classes that implement the following Shape<%> interface.
 (define Shape<%> (interface () ; weight : -> NonNegReal ; Returns the weight of this shape, which is related to its area in Pixels. weight ; render : Image -> Image ; Returns an Image with this shape added to the given Image. render)) ; A Pixels is a NonNegReal ; A Circle is a (new Circle% [x Coordinate][y Coordinate][r Pixels][c Color]) ; Represents a circle. ; A Square is a (new Square% [x Coordinate][y Coordinate][l Pixels][c Color]) ; Represents a square parallel to sides of a canvas. ; A Composite is a (new Composite% [front Shape<%>][back Shape<%>]) ; Represents a group of two overlapping Shape<%>s.
Be sure to follow the OOP Style guide!

Problem Set 11