hi,
dis is 4 ya
#include<iostream.h>
#include<bios.h>
#include<conio.h>
#include<dos.h>
#include<graphics.h>
#include<math.h>
#include<time.h>
#include<string.h>
#include<stdlib.h>
class point
{
public:
float x,y;
point(float m,float v)
{x=m+320;
y=v+260;
}
};
point conv(float rad,float ang)
{
float x,y,t,te,tem;
tem=ang-90;
te=tem-360;
float angr= 3.14/180*(te);
x=rad*cos(angr);
y=rad*sin(angr);
point temp(x,y);
return(temp);
}
class clock
{
float rad;
float minr,secr,horr;
public:
clock()
{rad=180;
minr=60;secr=80;horr=30;}
void drawc();
void draw();
}c;
void clock::draw()
{
char tem[12][2];char str[80];
int tot,net;
float mang,hang,sang,i,x;
float schg,mchg,hchg,sconv,mconv,hconv;
point c(0,0);
setcolor(4);
setlinestyle(0,0,2);
circle(c.x,c.y,rad-65);
setfillstyle(SOLID_FILL,11);
floodfill(c.x,c.y,4);
schg=6.0;
mchg=0.1;
hchg=0.0083;
tm *times=NULL;
time_t timer;
timer = time(NULL);
times = localtime(&timer);
sconv=times->tm_sec;
mconv=times->tm_min*60+times->tm_sec;
hconv=fabs(times->tm_hour%12)*60*60+times->tm_min*60+times->tm_sec;
sang=sconv*schg;
mang=mconv*mchg;
hang=hconv*hchg;
cprintf("Local time is: %s", asctime(times));
point min=conv(minr,mang),sec=conv(secr,sang),hor=conv(horr,hang);
point centre(0,0);
setlinestyle(0,0,3);
setcolor(0);
line(centre.x,centre.y,min.x,min.y);
setlinestyle(0,0,1);
setcolor(0);
line(centre.x,centre.y,sec.x,sec.y);
setlinestyle(0,0,3);
setcolor(0);
line(centre.x,centre.y,hor.x,hor.y);
delete times;
}
void clock::drawc()
{
char tem[12][2];
float radi=150,red=10,pi=3.14/6;
int tempx[]={0,0,0,0,-5,-5,-20,-25,-15};
int tempy[]={-5,-5,-5,-9,-12,-13,-10,-15,-23};
point centre(0,0);
setlinestyle(0,0,3);
setcolor(4);
settextstyle(4,HORIZ_DIR,5);
outtextxy(160,5,"ANALOG CLOCK");
outtextxy(160,25,"*********** ********");
setcolor(4);
circle(centre.x,centre.y,rad);
circle(centre.x,centre.y,rad+2);
setfillstyle(SOLID_FILL,3);
floodfill(centre.x,centre.y,4);
settextstyle(4,HORIZ_DIR,5);setcolor(0);
outtextxy(centre.x+radi*cos(pi*10)-red+10,centre.y+radi*sin(pi*10)-red-17,itoa(1,tem[0],10));
outtextxy(centre.x+radi*cos(pi*11)-red+10,centre.y+radi*sin(pi*11)-red-10,itoa(2,tem[1],10));
outtextxy(centre.x+radi*cos(pi*12)-red+10,centre.y+radi*sin(pi*12)-red-10,itoa(3,tem[2],10));
for(int k=1;k<=9;k++)
outtextxy(centre.x+radi*cos(pi*k)-red+tempx[k-1],centre.y+radi*sin(pi*k)-red+tempy[k-1],itoa(k+3,tem[2],10));
}
void tick()
{
int k;
for(int i=0;i<=5;i++)
{k=tan(i)*5000;
sound(k);delay(1);nosound();
}
}
void main()
{
int driver,mode;
driver=DETECT;
initgraph(&driver,&mode,"c:\\tc\\bgi");
cleardevice();
c.drawc();
c.draw();
while (bioskey(1) == 0)
{c.draw();tick();
sleep(1);}
getch();
}
here u go!
any doubts?
contact me:
venkhatapriya@yahoo.co.in
|