home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c021 / 7.img / EXAMPLES.ZIP / VPOINT.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-04  |  1.2 KB  |  50 lines

  1. /* VPOINT.CPP--Example from Chapter 5 of Getting Started */
  2.  
  3. // VPOINT.CPP contains the definitions for the Point and Location
  4. // classes that are declared in the file vpoint.h
  5.  
  6. #include "vpoint.h"
  7. #include <graphics.h>
  8.  
  9. // member functions for the Location class
  10. Location::Location(int InitX, int InitY) {
  11.    X = InitX;
  12.    Y = InitY;
  13. };
  14.  
  15. int Location::GetX(void) {
  16.    return X;
  17. };
  18.  
  19. int Location::GetY(void) {
  20.    return Y;
  21. };
  22.  
  23. // member functions for the Point class: These assume
  24. // the main program has initialized the graphics system
  25.  
  26. Point::Point(int InitX, int InitY) : Location(InitX,InitY) {
  27.    Visible = false;                  // make invisible by default
  28. };
  29.  
  30. void Point::Show(void) {
  31.    Visible = true;
  32.    putpixel(X, Y, getcolor());       // uses default color
  33. };
  34.  
  35. void Point::Hide(void) {
  36.    Visible = false;
  37.    putpixel(X, Y, getbkcolor()); // uses background color to erase
  38. };
  39.  
  40. Boolean Point::IsVisible(void) {
  41.    return Visible;
  42. };
  43.  
  44. void Point::MoveTo(int NewX, int NewY) {
  45.    Hide();         // make current point invisible
  46.    X = NewX;       // change X and Y coordinates to new location
  47.    Y = NewY;
  48.    Show();         // show point at new location
  49. };
  50.