برنامه ساعت عقربه دار و دیجیتال

برنامه ساعت عقربه دار و دیجیتال

قیمت :   ۵۵۰۰ تومان ( پنج هزار و پانصد تومان)

رشته :

کامپیوتر

نوع فایل:

CPP , EXE

توضیحات:


توضیحات : 

سورس کد پیاده سازی برنامه ساعت عقربه دار و دیجیتالی با سی پلاس  

در این برنامه بصورتی زیبا در قسمت بالا ساعت عقربه دار و در پایین آن نیز ساعت بصورت دیجیتالی نمایش داده شده است .   

همراه با فایلهای EXE , CPP


لینک دانلود نمونه پروژه

مشاهده بخشهایی از سورس کد این پروژه :

class coordinate
{
protected:
int x,y; public:

coordinate()
{
x=y=0;
}

coordinate(int initx,int inity)
{
x = initx;
y = inity;
}
};

class timenow
{
private:
struct time tm;public:
int tellhour(void)
{
gettime(&tm);
return tm.ti_hour;
}

int tellminute(void)
{
gettime(&tm);
return tm.ti_min;
}

int tellsecond(void)
{
gettime(&tm);
return tm.ti_sec;
}
};

class mouse
{
private:
union REGS i,o;
public:
mouse()
{
initmouse();
showmousepointer();
setmouseptrpos(425,320);
restrictmousepointer(1,1,630,478);
}

void initmouse()
{
i.x.ax = 0;
int86(0x33,&i,&o);
if(o.x.ax == 0)
{
cleardevice();
closegraph();
restorecrtmode();
printf(“\nMouse driver not installed.\nQuitting…\n”);
}
}

void showmousepointer()
{
i.x.ax = 1;
int86(0x33,&i,&o);
}

void setmouseptrpos(int row, int col)
{
i.x.ax = 4;
i.x.cx = col;
i.x.dx = row;
int86(0x33,&i,&o);
}

void hidemousepointer()
{
i.x.ax = 2;
int86(0x33,&i,&o);
}

void getmousepos(int &button, int &x, int &y)
{
i.x.ax = 3;
int86(0x33,&i,&o);
button = o.x.bx;
x = o.x.cx;
y = o.x.dx;
}

void restrictmousepointer(int x1, int y1, int x2, int y2)
{
i.x.ax = 7;
i.x.cx = x1;
i.x.dx = x2;
int86(0x33,&i,&o);
i.x.ax = 8;
i.x.cx = y1;
i.x.dx = y2;
int86(0x33,&i,&o);
}
};

class textbox
{
public:
textbox(int col1,int row1, int col2, int row2)
{
setfillstyle(SOLID_FILL,WHITE);
bar(col1,row1,col2,row2);
setcolor(LIGHTGRAY);
line(col1 + 1,row2-1,col2-1,row2-1);
line(col2-1,row1+1,col2-1,row2-1);
setcolor(DARKGRAY);
line(col1,row1-1,col2,row1-1);
line(col1-1,row1-1,col1-1,row2);
}
};

class BUTTON
{
private:
int row1,col1,row2,col2; public:
BUTTON()
{
}
BUTTON(int col1, int row1,int col2,int row2)
{
this -> col1=col1;
this -> row1=row2;
this -> col2=col2;
this -> row2=row2;
setcolor(BLACK);
rectangle(col1,row1,col2,row2);
setcolor(WHITE);
line(col1,row1,col2,row1);
line(col1,row1,col1,row2);
}

void Select(void)
{
setcolor(WHITE);
settextstyle(SANS_SERIF_FONT,0,1);
setcolor(BLACK);
line(this -> col1, this->row1,this->col2,this->row1);
line(this -> col1, this->row1,this->col1,this->row2);
setcolor(WHITE);
line(this -> col2, this->row1,this->col2,this->row2);
line(this -> col2, this->row2,this->col1,this->row2);
settextstyle(DEFAULT_FONT,0,1);
}

void UnSelect(void)
{
setcolor(BLACK);
settextstyle(SANS_SERIF_FONT,0,1);
setcolor(WHITE);
line(col1,row1,col2,row1);
line(col1,row1,col1,row2);
setcolor(BLACK);
line(col2,row1,col2,row2);
line(col2,row2,col1,row2);
settextstyle(DEFAULT_FONT,0,1);
}
};

class clockbody:public coordinate
{
private:
int radius; public:
clockbody(int centreX,int centreY):coordinate(centreX,centreY)
{
int inner_radius;
int i;
setcolor(WHITE);
settextstyle(TRIPLEX_FONT,0,1);
outtextxy(260,82,”TIME VIEWER”);
radius = (200*8)/20;
inner_radius = (radius*8)/10;
setcolor(WHITE);
circle(x,y,radius);
setfillstyle(SOLID_FILL,LIGHTGRAY);
floodfill(x,y,getmaxcolor());
setcolor(WHITE);
circle(x,y,inner_radius-5);
setfillstyle(SOLID_FILL,WHITE);
floodfill(x,y,getmaxcolor());
setcolor(BLACK);
circle(x,y,1);
int row,col;
char no[5];
settextstyle(SANS_SERIF_FONT,0,1);
radius = 70;
settextstyle(DEFAULT_FONT,0,1);
for(i=1;i<=12;i++)
{
row = (x+radius*sin(_2PI*i/12.0));
col = (y-radius*cos(_2PI*i/12.0));
itoa(i,no,10);
outtextxy((row-textwidth(no)/2),(col+textheight(no)/2)-5,no);
}

}

int tellradius(void)
{
return radius;
}

int tellcentreX(void)
{
return x;
}

int tellcentreY(void)
{
return y;
}

};

void main(void)
{
int gd = DETECT,gm;
int hr,min,sec,acchr;
int button,x,y;
char strtime[3],opt;
struct time ot,nt;
static char apflg;
void frame(int,int,int,int);
void background(int,int,int,int);
void clockhands(int,int,int,clockbody,char);
char *putzero(char[]);

initgraph(&gd,&gm,”C:\\TC\\BGI”);
cleardevice();
frame(190,125,450,350);
frame(190,70,450,120);
background(190,360,450,400);
background(190,410,450,450);

BUTTON hrup(238,370,250,380),hrdn(238,381,250,390),
mnup(303,370,315,380),mndn(303,381,315,390),
scup(368,370,380,380),scdn(368,381,380,390),
apup(428,370,440,380),apdn(428,381,440,390),
Ok(200,418,270,443),Cancel(370,418,440,443);
setcolor(BLACK);
outtextxy(240,371,””);outtextxy(305,371,””);
outtextxy(370,371,””);outtextxy(430,371,””);
outtextxy(240,382,””);outtextxy(305,382,””);
outtextxy(370,382,””);outtextxy(430,382,””);
outtextxy(230,428,”Ok”);outtextxy(382,428,”Cancel”);
textbox hour(200,370,235,390),minute(265,370,300,390),
second(330,370,365,390),ampm(390,370,425,390);
clockbody clock(getmaxx()/2,getmaxy()/2);
timenow time;
mouse m;
gettime(&ot);
setcolor(WHITE);
outtextxy(100,470,”Digital Clock”);

while(1)
{
hr = time.tellhour();
min = time.tellminute();
sec = time.tellsecond();

if(hr>=12)
apflg = ‘p’;
if(hr < 12)
apflg = ‘a’;

m.getmousepos(button,x,y);

if(IS_OK_SELECTED(x,y,button))
{
while(IS_OK_SELECTED(x,y,button))
{
Ok.Select();
m.getmousepos(button,x,y);
setcolor(WHITE);
outtextxy(230,428,”Ok”);
}

Ok.UnSelect();
setcolor(BLACK);
outtextxy(230,428,”Ok”);
gettime(&nt);
if(nt.ti_hour==0)
nt.ti_hour=12;
settime(&nt);
break;
}

if(IS_CANCEL_SELECTED(x,y,button))
{
while(IS_CANCEL_SELECTED(x,y,button))
{
Cancel.Select();
m.getmousepos(button,x,y);
setcolor(WHITE);
outtextxy(382,428,”Cancel”);
}
Cancel.UnSelect();
setcolor(BLACK);
outtextxy(382,428,”Cancel”);
settime(&ot);
break;
}

if(IS_HRUP_SELECTED(x,y,button))
{
gettime(&nt);
while(IS_HRUP_SELECTED(x,y,button))
{
hrup.Select();
m.getmousepos(button,x,y);
setcolor(WHITE);
outtextxy(240,371,””);
}
hrup.UnSelect();
nt.ti_hour++;
if(nt.ti_hour>23)
nt.ti_hour = 12;
else if(nt.ti_hour > 11 && nt.ti_hour < 13)
nt.ti_hour = 0;
settime(&nt);
hr = time.tellhour();
setcolor(BLACK);
outtextxy(240,371,””);
}

if(IS_HRDN_SELECTED(x,y,button))
{
gettime(&nt);
while(IS_HRDN_SELECTED(x,y,button))
{
hrdn.Select();
m.getmousepos(button,x,y);
setcolor(WHITE);
outtextxy(240,382,””);
}
hrdn.UnSelect();
if(nt.ti_hour < 1 && apflg == ‘a’)
nt.ti_hour = 12;
nt.ti_hour–;
if(nt.ti_hour < 12 && apflg == ‘p’)
nt.ti_hour = 23;
else if(nt.ti_hour < 1 && apflg ==’a’)
nt.ti_hour = 0;
settime(&nt);
hr = time.tellhour();
setcolor(BLACK);
outtextxy(240,382,””);
}

if(IS_MNUP_SELECTED(x,y,button))
{
gettime(&nt);
while(IS_MNUP_SELECTED(x,y,button))
{
mnup.Select();
m.getmousepos(button,x,y);
setcolor(WHITE);
outtextxy(305,371,””);
}
mnup.UnSelect();
nt.ti_min++;
if(nt.ti_min > 59)
nt.ti_min = 0;
min = time.tellminute();
settime(&nt);
setcolor(BLACK);
outtextxy(305,371,””);
}

if(IS_MNDN_SELECTED(x,y,button))
{
gettime(&nt);

while(IS_MNDN_SELECTED(x,y,button))
{
mndn.Select();
m.getmousepos(button,x,y);
setcolor(WHITE);
outtextxy(305,382,””);
}
mndn.UnSelect();
nt.ti_min–;
if(nt.ti_min == 0)
nt.ti_min = 59;
settime(&nt);
min = time.tellminute();
setcolor(BLACK);
outtextxy(305,382,””);
}

if(IS_SCUP_SELECTED(x,y,button))
{
gettime(&nt);

while(IS_SCUP_SELECTED(x,y,button))
{
scup.Select();
m.getmousepos(button,x,y);
setcolor(WHITE);
outtextxy(370,371,””);
}

scup.UnSelect();
nt.ti_sec++;

if(nt.ti_sec > 59)
nt.ti_sec = 0;

settime(&nt);
sec = time.tellsecond();
setcolor(BLACK);
outtextxy(370,371,””);
}

if(IS_SCDN_SELECTED(x,y,button))
{
gettime(&nt);
while(IS_SCDN_SELECTED(x,y,button))
{
scdn.Select();
m.getmousepos(button,x,y);
setcolor(WHITE);
outtextxy(307,382,””);
}
scdn.UnSelect();
nt.ti_sec–;
if(nt.ti_sec == 0)
nt.ti_sec = 59;
min = time.tellminute();
settime(&nt);
sec = time.tellminute();
setcolor(BLACK);
outtextxy(305,382,””);
}

if(IS_APUP_SELECTED(x,y,button))
{
gettime(&nt);
while(IS_APUP_SELECTED(x,y,button))
{
apup.Select();
m.getmousepos(button,x,y);
setcolor(WHITE);
outtextxy(430,371,””);
}
apup.UnSelect();
setcolor(BLACK);
outtextxy(430,371,””);
switch(apflg)
{
case ‘a’: nt.ti_hour += 12;
settime(&nt);
break;
case ‘p’: nt.ti_hour -= 12;
settime(&nt);
break;
}
settime(&nt);
}

if(IS_APDN_SELECTED(x,y,button))
{
gettime(&nt);
while(IS_APDN_SELECTED(x,y,button))
{
apdn.Select();
m.getmousepos(button,x,y);
setcolor(WHITE);
outtextxy(430,382,””);
}
apdn.UnSelect();
setcolor(BLACK);
outtextxy(430,382,””);
switch(apflg)
{
case ‘a’: nt.ti_hour += 12;
settime(&nt);
break;
case ‘p’: nt.ti_hour -= 12;
settime(&nt);
break;
}
settime(&nt);
}

setcolor(BLACK);
if(hr == 0)
acchr = 12;
else if(hr>12)
acchr = hr-12;
else
acchr = hr;

if(hr>=12)
setcolor(WHITE),outtextxy(400,375,”AM”),
setcolor(BLACK),outtextxy(400,375,”PM”),
apflg = ‘p’;

else
setcolor(WHITE),outtextxy(400,375,”PM”),
setcolor(BLACK),outtextxy(400,375,”AM”),
apflg = ‘a’;

outtextxy(210,375,putzero(itoa(acchr,strtime,10)));
outtextxy(275,375,putzero(itoa(min,strtime,10)));
outtextxy(340,375,putzero(itoa(sec,strtime,10)));
opt=’n’;
clockhands(hr,min,sec,clock,opt);
delay(50);
setcolor(WHITE);
outtextxy(210,375,putzero(itoa(acchr,strtime,10)));
outtextxy(275,375,putzero(itoa(min,strtime,10)));
outtextxy(340,375,putzero(itoa(sec,strtime,10)));
opt = ‘y’;
clockhands(hr,min,sec,clock,opt);
}

closegraph();
restorecrtmode();
}

char* putzero(char strtime[])
{
if(strlen(strtime) == 1)
{
strtime[1] = strtime[0];
strtime[0] = ‘0’;
strtime[2] = ‘\0’;
}
return strtime;
}

void clockhands(int h, int m,int s,clockbody clock,char opt)
{
int x = clock.tellcentreX();
int y = clock.tellcentreY();
int r = clock.tellradius();
int h_len = (r*5)/10;
int m_len = (r*7)/10;
int s_len = (r*6)/10;

double hour_value = h+m/60.0 + s/3600.00;
hour_value *= _2PI/12.0;
if(opt!=’y’)
setcolor(BLACK);
setlinestyle(0,0,3);
line(x,y,(int)(x+h_len*sin(hour_value)),(int)(y-h_len*cos(hour_value)));
line(x,y+1,(int)(x+h_len*sin(hour_value)),(int)(y-h_len*cos(hour_value))+1);

double minute_value = m+ s/60.0;
minute_value *= _2PI/60.0;
if(opt!=’y’)
setcolor(BLACK);
setlinestyle(0,0,3);
line(x,y,(int)(x+m_len*sin(minute_value)),(int)(y-m_len*cos(minute_value)));
line(x,y+1,(int)(x+m_len*sin(minute_value)),(int)(y-m_len*cos(minute_value))+1);

double second_value = s*_2PI/60.0;
minute_value *= _2PI/60.0;
if(opt!=’y’)
setcolor(BLACK);
setlinestyle(0,0,1);
line(x,y,(int)(x+s_len*sin(second_value)),(int)(y-s_len*cos(second_value)));
}

void background(int c1,int r1, int c2, int r2)
{
setfillstyle(SOLID_FILL,LIGHTGRAY);
bar(c1,r1,c2,r2);
setcolor(WHITE);
line(c1,r1,c2,r1);
line(c1,r1+1,c2,r1+1);
line(c2,r1,c2,r2);
line(c2-1,r1,c2-1,r2);
setcolor(DARKGRAY);
line(c1,r1,c1,r2);
line(c1+1,r1,c1+1,r2);
line(c1,r2,c2,r2);
line(c1,r2-1,c2,r2-1);
}

 

دانلود کامل پروژه همراه با فایل سورس کد و فایل اجرایی آن
در تمامی ساعات شبانه روز >> پرداخت آنلاین و دانلود آنلاین پروژه


پذیرش و انجام سفارشات پروژه های شما
شماره تماس پشتیبانی سایت : ۰۹۳۹۲۷۶۱۶۳۰



Related posts

پاسخ دهید

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *

Translate »