home *** CD-ROM | disk | FTP | other *** search
/ C by Discovery (4th Edition) / C_By_Discovery_4th_Edition.tar / C_By_Discovery_4th_Edition / _DISK_ / ch12 / point.h < prev    next >
C/C++ Source or Header  |  2005-06-16  |  2KB  |  41 lines

  1. //                    point.h
  2. //
  3. // Contains the class declaration of class Point
  4.  
  5. class Point {                                        // Note 1
  6. public:                                              // Note 3
  7.     bool set_x( int x_val );                         // Note 6
  8.     // PRECONDITION:  x_val should be a non-negative integer
  9.     //
  10.     // POSTCONDITION: if x_val is non-negative, x will be 
  11.     //                set to x_val and true is returned.
  12.     //                If x_val is negative, x will be set
  13.     //                to 0 and false is returned.
  14.  
  15.     bool set_y( int y_val );                         // Note 6
  16.     // PRECONDITION:  y_val should be a non-negative integer
  17.     //
  18.     // POSTCONDITION: if y_val is non-negative, y will be 
  19.     //                set to y_val and true is returned.
  20.     //                If y_val is negative, y will be set
  21.     //                to 0 and false is returned.
  22.  
  23.     int x_is() const { return x; }                   // Note 7
  24.     // PRECONDITION:  the point should have its data initialized.
  25.     //
  26.     // POSTCONDITION: the value of x is returned.
  27.  
  28.     int y_is() const{  return y; }                   // Note 7
  29.     // PRECONDITION:  the point should have its data initialized.
  30.     //
  31.     // POSTCONDITION: the value of y is returned.
  32.  
  33.     void display() const;                            // Note 8
  34.     // PRECONDITION:  the point should have its data initialized.
  35.     //
  36.     // POSTCONDITION: the point is displayed on standard output.
  37.  
  38. private:                                             // Note 4
  39.     int x;                                           // Note 5
  40.     int y;                                           // Note 5
  41. };                                                   // Note 2