C program to Create a Analogue Cloack



#include<iostream.h>
#include<dos.h>
#include<conio.h>
#include<math.h>
#include<graphics.h>
class CLOCK
{

  private:
   int x,y;
   int x2,y2;
  public:
  void page();
  void needle();
  void clock()
      {
 setbkcolor(BLACK);
 setcolor(WHITE);
 circle(320,240,230);
 circle(320,240,220);
 setfillstyle(1,BLUE);
 floodfill(320+225,240,WHITE);
 setfillstyle(1,BLUE);
 setcolor(BLUE);
 settextstyle(8,0,3);
 x=320;
 y=240;
 outtextxy(x+100,y-180,"I");
 outtextxy(x+150,y-110,"II");
 outtextxy(x+170,y-20,"III");
 outtextxy(x+150,y+70,"IV");
 outtextxy(x+100,y+140,"V");
 outtextxy(x-10,y+180,"VI");
 outtextxy(x-120,y+140,"VII");
 outtextxy(x-180,y+70,"VIII");
 outtextxy(x-200,y-20,"IX");
 outtextxy(x-180,y-110,"X");
 outtextxy(x-120,y-180,"XI");
 outtextxy(x-15,y-220,"XII");
 x2=20;
       needle();
      }

};

void main()
{
CLOCK Clock;
int driver=DETECT,mode=DETECT;
initgraph(&driver,&mode,"C:\\tc\\bgi");
Clock.page();
getch();
clearviewport();
Clock.clock();
getch();
}
void CLOCK::page()
{int x=0;
while(!kbhit())
{
setbkcolor(BLUE);
setcolor(WHITE);
ellipse(320,240,0,360,20+x,x);
x++;
setcolor(BLUE);
settextstyle(7,0,5);
outtextxy(100,200,"Muhammad Ali");

delay(1);
 if(x>240)
  {
   while(!kbhit())
   {
   setcolor(BLACK);
    ellipse(320,240,0,360,20+x,x);
    x--;
    delay(1);
     if(x<0)
      {
       while(!kbhit())
       {
 setcolor(WHITE);
 ellipse(320,240,0,360,20+x,x);
 x++;
 delay(1);
 setcolor(BLUE);
 settextstyle(7,0,5);
 outtextxy(150,200,"06 SOFTWARE");
  if(x>240)
   {
    while(!kbhit())
    {
     setcolor(BLACK);
     ellipse(320,240,0,360,20+x,x);
     x--;
     delay(1);
    if(x<0)
     {
      while(!kbhit())
      {
  setcolor(WHITE);
  ellipse(320,240,0,360,20+x,x);
  x++;
  delay(1);
  setcolor(BLUE);
  settextstyle(7,0,5);
  outtextxy(200,200,"Roll No. 36");
        if(x>240)
        {
  while(!kbhit())
  {
      setcolor(BLACK);
      ellipse(320,240,0,360,20+x,x);
      x--;
      delay(1);
      if(x<0)
       {
        while(!kbhit())
        {
   setcolor(WHITE);
   ellipse(320,240,0,360,20+x,x);
   x++;
   delay(1);
   setcolor(BLUE);
   settextstyle(7,0,5);
   outtextxy(200,150,"Assign By");
   outtextxy(150,250,"Sir Shahzad Ahmed");
   if(x>240)
    {
     while(!kbhit())
     {
       setcolor(BLACK);
       ellipse(320,240,0,360,20+x,x);
       x--;
       delay(1);
       if(x<0)
       {
        while(!kbhit())
         {
    setcolor(WHITE);
    ellipse(320,240,0,360,20+x,x);
    x++;
    delay(1);
    setcolor(BLUE);
    settextstyle(7,0,5);
    outtextxy(150,150,"Deptt: of CS & SW");
    outtextxy(150,250,"Mehran Unversity");

    if(x>240)
    {
     while(!kbhit())
     {
        setcolor(BLACK);
        ellipse(320,240,0,360,20+x,x);
        x--;
        delay(1);
        if(x<0)
        {
        while(!kbhit())
        {
     setcolor(WHITE);
     ellipse(320,240,0,360,20+x,x);
     x++;
     delay(1);
     setcolor(BLUE);
     settextstyle(7,0,6);
     outtextxy(230,200,"Well Come");
     if(x>240)
     {
     while(!kbhit())
     {
     }
     }

        }
        }
     }
    }
         }
       }

     }
    }


        }
       }


  }
        }
      }
     }
    }
    }
 }
      }

   }
  }

}
}
void CLOCK::needle()
     {
     int sec=0,min=0,hour=0;
     while(!kbhit())
     {                    // second dial //

     setcolor(MAGENTA);
     setfillstyle(1,MAGENTA);
     pieslice(320,240,0,20,150);
     pieslice(320,240,340,360,150);
     pieslice(320,240,158,180,150);
     pieslice(320,240,68,112,150);
     pieslice(320,240,180,202,150);
     pieslice(320,240,248,292,150);
      setcolor(BLUE);
     circle(320,240,10);
     circle(320,240,8);
     setfillstyle(1,BLUE);
     floodfill(320,240,BLUE);

     setcolor(RED);
     setfillstyle(1,RED);
     pieslice(320,240,0-sec*6,1-sec*6,150);
     delay(850);

     setcolor(BLACK);
     setfillstyle(1,BLACK);
     pieslice(320,240,-1-sec*6,2-sec*6,160);
     sec++;
         /// minute dial ///
     setcolor(CYAN);
     pieslice(320,240,60-min*6,61-min*6,140);

     if(sec%60==0)
      {
      setcolor(BLACK);
      setfillstyle(1,BLACK);
      pieslice(320,240,58-min*6,62-min*6,150);
      min=min+1;
      }
   /// hour dial ///
      setcolor(LIGHTBLUE);
      setfillstyle(1,LIGHTBLUE);
      pieslice(320,240,320-hour*6,321-hour*6,120);

      if(sec%(3600/5)==0)
      {

      setcolor(BLACK);
      setfillstyle(1,BLACK);
      pieslice(320,240,318-hour*6,322-hour*6,130);
      hour++;
      }


     }
     }
Bhanu Namikaze

Bhanu Namikaze is an Ethical Hacker, Security Analyst, Blogger, Web Developer and a Mechanical Engineer. He Enjoys writing articles, Blogging, Debugging Errors and Capture the Flags. Enjoy Learning; There is Nothing Like Absolute Defeat - Try and try until you Succeed.

No comments:

Post a Comment