|
|
|
|
|
|
|
1. Fill in the blanks: Structured (procedural) programming results in a program that is a collection of interacting ______, whereas OOP results in a program that is a collection of interacting ______. (pp. 906909) |
|
|
|
|
|
|
|
|
2. Name the three language features that characterize object-oriented programming languages. (pp. 906909) |
|
|
|
|
|
|
|
|
3. Given the class declaration |
|
|
|
|
|
|
|
|
class Point
{
public:
int X_Coord() const; // Return the x-coordinate
int Y_Coord() const;
// Return the y-coordinate
Point( /* in */ int initX, // Constructor
/* in */ int initY );
private:
int x;
int y;
}; |
|
|
|
 |
|
|
|
|
and the type declaration |
|
|
|
|
|
|
|
|
enum StatusType {ON, OFF}; |
|
|
|
 |
|
|
|
|
declare a class Pixel that inherits from class Point. Class Pixel has an additional data member of type StatusType named status; it has an additional member function CurrentStatus that returns the value of status; and it supplies its own constructor that receives three parameters. (pp. 909917) |
|
|
|
|
|
|
|
|
4. Write a client statement that creates a Pixel object named onePixel with an initial (X, Y) position of (3, 8) and a status of OFF. (pp. 909917) |
|
|
|
|
|
|
|
|
5. Assuming somePixel is an object of type Pixel, write client code that prints out the current x-and y-coordinates and status of somePixel. (pp. 909917) |
|
|
|
|
|
|
|
|
6. Write the function definitions for the Pixel class constructor and the CurrentStatus function. (pp. 917920) |
|
|
|
|
|
|
|
|
7. Fill in the private part of the following class declaration, which uses composition to define a Line object in terms of two Point objects. (pp. 921922) |
|
|
|
|
|
|
|
|
class Line
{
public:
Point StartingPoint() const; // Return line's starting point
Point EndingPoint() const; // Return line's ending point
float Length() const; // Return length of the line
Line( /* in */ int startX, // Constructor
/* in */ int startY,
|
|
|
|
|
|