CS 2110 Midterm: CS 211 Cornell 2006 Fall t1 Examst1solcs211fa03

16 views5 pages
31 Jan 2019
Course
Professor

Document Summary

9 march 2006: short answers [24 pts] (parts a f) Four points off for each missing or wrong answer. Suppose we have an interface shape that is part of a geometry package. /** a two-dimensional shape on the plane, with cartesian coordinates. interface shape { // these four methods give coordinates that bound the shape in a. // rectangle. float leftx(); float rightx(); float bottomy(); float topy(); /** the area of the shape. float area(); Now, we want to implement some different shapes as part of the package. Observer. public float topy() { return center_y + radius; } (b) [10 pts] suppose we want to implement a class square that inherits from rectangle, but has a construc- tor square(float center_x, float center_y, float size). Square(float cx, float cy, float size) { super(cx - size/2, cx + size/2, cy - size/2, cy + size/2); (c) [12 pts]