//circle.cpp
#include iostream.h>
#include conio.h>
#include graphics.h>
//两个<>在论坛上看不到,我少写了一个<   
enum BOOLEAN
{
 FALSE,
 TURE
};
//location.cpp
class LOCATION
{
public:
 LOCATION(int x,int y)
 {   x_pos=x;
     y_pos=y;
     return;
 }
 ~LOCATION()
 {
  return;
 }
 int get_x()
 {
  return(x_pos);
 }
 int get_y()
 {
   return(y_pos);
 }
protected:
int x_pos;
int y_pos;
};
//point.cpp
class POINT:public LOCATION
{
public:
POINT(int x,int y):LOCATION(x,y)
{
   visable=FALSE;
   return;
}
~POINT()
{
   return;
}
BOOLEAN is_visable()
{
  return(visable);
}
void show()
{
 if(!is_visable())
 {
   visable=TURE;
   putpixel(x_pos,y_pos,getcolor()); //draw a circle
 }
  return;
}
void hide()
{ if(is_visable())
  {
   visable=FALSE;
   putpixel(x_pos,y_pos,getbkcolor());
   //draw a circle with backcolor
  }
  return;
}
void move_to(int x,int y)
{
 hide();
 x_pos=x;
 y_pos=y;
 show();
 return;
}
protected:
 BOOLEAN visable;
};
//circle.cpp
class CIRCLE:public POINT
{
 CIRCLE(int x,int y,int r):POINT(x,y)
{
 radius=r;
 return;
}
~CIRCLE()
{
 return;
}
void show()
{
 if(!is_visable())
 {
  visable=TURE;
  circle(x_pos,y_pos,radius);//draw  a circle
 }
 return;
}
void hide()
{
 if(is_visable())
 {
  visable=FALSE;
  temp_color=getcolor(); //save current color
  setcolor(getbkcolor());
  circle(x_pos,y_pos,radius);
  setcolor(temp_color);
 }
 return;
}
void move_to(int x,int y)
{
 hide();
 x_pos=x;
 y_pos=y;
 show();
 return;
}
void expand(int delta)
{
 hide();
 radius=radius+delta;
 if(radius<0) radius=0;
 show();
 return;
}
void contract(int delta)
{ expand(-delta);
 return;
}
protected:
int radius;
int temp_color;
};
int main()
{
 int graphdriver=DETECT, graphmode;//define graph valiable
 CIRCLE  circle(100,200,50);
 initgraph(&graphdriver,&graphmode," ");//init graph model
 circle.show();
 getch();
 circle.move_to(200,250);
 getch();
 circle.expand(50);
 getch();
 circle.contract(65);
 getch();
 closegraph(); //close graph model
 return 0;
}

 
											





 
	    