سلام دوستان
این هم کد یه برنامه بانک البته کامل نیست
#include "graphics.h"
#include "conio.h"
#include"iostream.h"
#include "time.h"
#include "stddef.h"
#include "stdio.h"
#include "dos.h"
#include "fstream.h"
#include "string.h"
//***********************************//
void box(int,int,int,int);
static int choise,driver=DETECT,mode=0,i;
static char save1,save2;
//***********************************//
class banck
{
public:
void onemenu();
void EftetaheHesab();
void towmenu();
void daryaftmojodi();
int graph();
}banckshaey;
//***********************************//
/* START KOTAHMODAT PROGRAM NUMBER 1 MENU */
class kotahmodat:private banck
{
int choise1;
int enterf1();
char name1[10];
char lname1[10];
char sex1[10];
char fname1[10];
char tt1[10];
char te1[10];
char sh1[10];
char dmablagh1[10];
char td1[10];
friend ostream &operator<<(ostream &stream, kotahmodat ob);
friend istream &operator>>(istream &stream, kotahmodat &ob);
public:
void cindaryaftmojodi1();
void menu1();
void filedaryadt1();
kotahmodat(){ }
kotahmodat(char *n01, char *l01, char *s01,char *f01,
char *tt01, char *te01,char *sh01, char *dma01, char *td01)
{
strcpy(name1, n01);
strcpy(lname1, l01);
strcpy(sex1, s01);
strcpy(fname1, f01);
strcpy(tt1, tt01);
strcpy(te1, te01);
strcpy(sh1, sh01);
strcpy(dmablagh1, dma01);
strcpy(td1, td01);
}
};
//*************************************//
ostream &operator<<(ostream &output, kotahmodat ob)
{
output << ob.name1<<" "<< ob.lname1<<" " << ob.sex1
<<" " << ob.fname1<<" "<< ob.tt1 <<" "<< ob.te1
<<" "<< ob.sh1 <<" "<< ob.dmablagh1 <<" "<< ob.td1;
return output;
}
//*************************************//
istream &operator>>(istream &input, kotahmodat &ob)
{
banckshaey.EftetaheHesab();
gotoxy(30,12);
input >> ob.name1;
gotoxy(30,14);
input >>ob.lname1;
gotoxy(30,16);
input>>ob.sex1;
gotoxy(30,18);
input>>ob.fname1;
gotoxy(30,20);
input>>ob.tt1;
gotoxy(30,22);
input>>ob.te1;
gotoxy(30,24);
input>>ob.sh1;
return input;
}
//*********************************//
int kotahmodat::enterf1()
{
kotahmodat ob;
fstream pb("file1.dat", ios::in | ios::out | ios::app);
if(!pb)
{
cout << "Cannot open file1.dat file:";
cin.get();
return 1;
}
cin >> ob;
pb << ob ; // for write to disk.
cout << ob.name1<
return 0;
}
//**********************************//
void kotahmodat::filedaryadt1()
{
gotoxy(30,22);
cin>>save1;
if (save1=='s')
{
gotoxy(15,24);
cout<<"Motmanin ke mikhain Seve Beshe! [Y/N]:";
}
}
//**********************************//
void kotahmodat::menu1()
{
if (choise==1)
{
clrscr();
banckshaey.graph();
banckshaey.towmenu();
gotoxy(45,22);
cin>>choise1;
switch (choise1)
{
case 1:
clrscr();
banckshaey.graph();
enterf1();
break;
case 2:
clrscr();
banckshaey.graph();
break;
case 3:
clrscr();
menu1();
break;
}
}
}
//**********************************//
void kotahmodat::cindaryaftmojodi1()
{
gotoxy(30,12);
cin>>name1;
gotoxy(30,14);
cin>>lname1;
gotoxy(30,16);
cin>>sh1;
gotoxy(30,18);
cin>>dmablagh1;
gotoxy(30,20);
cin>>td1;
getch();
}
/* END KOTAHMODAT PROGRAM */
//**********************************//
/* START BOLAND MODAT PROGRAM NUMBER 2 MENU */
class bolandmodat:private banck
{
public:
char name2[10];
char lname2[10];
char sex2[10];
char fname2[10];
char tt2[10];
char te2[10];
char sh2[10];
char dmablagh2[10];
char td2[10];
void cineftetah2();
void cindaryaftmojodi2();
void menu2();
void filedaryaft2();
int choise2;
};
//**********************************//
void bolandmodat::cineftetah2()
{
gotoxy(30,12);
cin>>name2;
gotoxy(30,14);
cin>>lname2;
gotoxy(30,16);
cin>>sex2;
gotoxy(30,18);
cin>>fname2;
gotoxy(30,20);
cin>>tt2;
gotoxy(30,22);
cin>>te2;
gotoxy(30,24);
cin>>sh2;
}
//**********************************//
void bolandmodat::cindaryaftmojodi2()
{
gotoxy(30,12);
cin>>name2;
gotoxy(30,14);
cin>>lname2;
gotoxy(30,16);
cin>>sh2;
gotoxy(30,18);
cin>>dmablagh2;
gotoxy(30,20);
cin>>td2;
}
//**********************************//
void filedaryadt2()
{
gotoxy(30,22);
cin>>save1;
if (save1=='s')
{
gotoxy(15,24);
cout<<"Motmanin ke mikhain Seve Beshe! [Y/N]:";
}
}
//**********************************//
void bolandmodat::menu2()
{
if (choise==2)
{
clrscr();
banckshaey.graph();
banckshaey.towmenu();
gotoxy(45,22);
cin>>choise2;
switch (choise2)
{
case 1:
clrscr();
banckshaey.graph();
banckshaey.EftetaheHesab();
cineftetah2();
break;
case 2:
clrscr();
banckshaey.graph();
banckshaey.daryaftmojodi();
cindaryaftmojodi2();
filedaryadt2();
break;
}
}
}
/* END BOLAND MODAT PROGRAM */
//**********************************//
/* START JARI PROGRAM */
class jari:private banck
{
public:
char name3[10];
char lname3[10];
char sex3[10];
char fname3[10];
char tt3[10];
char te3[10];
char sh3[10];
char dmablagh3[10];
char td3[10];
void cineftetah3();
void cindaryaftmojodi3();
void menu3();
int choise3;
};
//**********************************//
void jari::cineftetah3()
{
gotoxy(30,12);
cin>>name3;
gotoxy(30,14);
cin>>lname3;
gotoxy(30,16);
cin>>sex3;
gotoxy(30,18);
cin>>fname3;
gotoxy(30,20);
cin>>tt3;
gotoxy(30,22);
cin>>te3;
gotoxy(30,24);
cin>>sh3;
}
//**********************************//
void jari::cindaryaftmojodi3()
{
gotoxy(30,12);
cin>>name3;
gotoxy(30,14);
cin>>lname3;
gotoxy(30,16);
cin>>sh3;
gotoxy(30,18);
cin>>dmablagh3;
gotoxy(30,20);
cin>>td3;
getch();
}
//**********************************//
void jari::menu3()
{
if (choise==3)
{
clrscr();
banckshaey.graph();
banckshaey.towmenu();
gotoxy(45,22);
cin>>choise3;
switch (choise3)
{
case 1:
clrscr();
banckshaey.graph();
banckshaey.EftetaheHesab();
cineftetah3();
break;
case 2:
clrscr();
banckshaey.graph();
banckshaey.daryaftmojodi();
cindaryaftmojodi3();
break;
}
}
}
/* END JARI PROGRAM */
//**********************************//
/* START GHARZOLHASANE PROGRAM */
class gharzolhasane:private banck
{
public:
char name4[10];
char lname4[10];
char sex4[10];
char fname4[10];
char tt4[10];
char te4[10];
char sh4[10];
char dmablagh4[10];
char td4[10];
void cineftetah4();
void cindaryaftmojodi4();
void menu4();
int choise4;
};
//**********************************//
void gharzolhasane::cineftetah4()
{
gotoxy(30,12);
cin>>name4;
gotoxy(30,14);
cin>>lname4;
gotoxy(30,16);
cin>>sex4;
gotoxy(30,18);
cin>>fname4;
gotoxy(30,20);
cin>>tt4;
gotoxy(30,22);
cin>>te4;
gotoxy(30,24);
cin>>sh4;
}
//**********************************//
void gharzolhasane::cindaryaftmojodi4()
{
gotoxy(30,12);
cin>>name4;
gotoxy(30,14);
cin>>lname4;
gotoxy(30,16);
cin>>sh4;
gotoxy(30,18);
cin>>dmablagh4;
gotoxy(30,20);
cin>>td4;
getch();
}
//**********************************//
void gharzolhasane::menu4()
{
if (choise==4)
{
clrscr();
banckshaey.graph();
banckshaey.towmenu();
gotoxy(45,22);
cin>>choise;
switch (choise4)
{
case 1:
clrscr();
banckshaey.graph();
banckshaey.EftetaheHesab();
cineftetah4();
break;
case 2:
clrscr();
banckshaey.graph();
banckshaey.daryaftmojodi();
cindaryaftmojodi4();
break;
}
}
}
/* END GHARZOLHASANE PROGRAM */
//**********************************//
void main()
{
kotahmodat kotah;
bolandmodat boland;
jari jarish;
gharzolhasane gh;
banckshaey.graph();
banckshaey.onemenu();
kotah.menu1();
boland.menu2();
jarish.menu3();
gh.menu4();
getch();
closegraph();
restorecrtmode();
}
//**********************************//
void box(int startx, int starty,int endx,int endy,int color)
{
setcolor(color);
line(startx,starty,startx,endy);
line(startx,starty,endx,starty);
line(endx,starty,endx,endy);
line(endx,endy,startx,endy);
}
//**********************************//
void banck::onemenu()
{
gotoxy(18,12);
cout<<"1-Hesab Kotah Modat:"<
cout<<"2-Hedsb Boland Modat:"<
cout<<"3-Hesab jari:"<
cout<<"4-Hesab Gharzolhasane:"<
cout<<"5-Vam"<
cout<<"6-Exit"<
cout<<"Enter Menu Select Number: [ ";
gotoxy(46,24);
cout<<"]";
gotoxy(45,24);
cin>>choise;
}
//****************************************//
void banck::EftetaheHesab()
{
gotoxy(10,12);
cout<<"Nmae:";
gotoxy(28,12);
cout<<"[ ]"<<" Ali";
gotoxy(10,14);
cout<<"Last Name:";
gotoxy(28,14);
cout<<"[ ]"<<" Ahmadi";
gotoxy(10,16);
cout<<"Sex:";
gotoxy(28,16);
cout<<"[ ]"<<" Maile";
gotoxy(10,18);
cout<<"Father Name:";
gotoxy(28,18);
cout<<"[ ]"<<" Khalil";
gotoxy(10,20);
cout<<"Tarikh Tavalod:";
gotoxy(28,20);
cout<<"[ ]"<<" 24/2/65";
gotoxy(10,22);
cout<<"Tarikh Eftetah:";
gotoxy(28,22);
cout<<"[ ]"<<" 18/4/86";
gotoxy(10,24);
cout<<"Somare Hesab:";
gotoxy(28,24);
cout<<"[ ]"<<" 802173";
}
//*********************************//
int banck::graph()
{
initgraph(&driver,&mode,"c:\\tc\\bgi");
setbkcolor(9);
box(5,5,632,470,WHITE);
setviewport(20,20,630,470,1);
box(5,5,590,110,GREEN);
settextstyle(GOTHIC_FONT,HORIZ_DIR,8);
outtextxy(120,14,"H&A Bank");
box(5,110,590,135,GREEN);
box(5,135,590,430,GREEN);
settextstyle(1,HORIZ_DIR,3);
outtextxy(140,108,"Hamishe Hagh Ba Moshtarist!");
//***************** for time program:
time_t t ;
struct time dos_time ;
struct date dos_date ;
struct tm *local ;
getdate(&dos_date) ;
gettime(&dos_time) ;
t = dostounix(&dos_date, &dos_time) ;
local = localtime(&t) ; // braye eshare be yek sakhteman az noe tm
gotoxy(50,28);
printf(asctime(local)); //asctime braye format dadan be sakhtemane time
return driver,mode;
}
//*********************************//
void banck::towmenu()
{
gotoxy(18,12);
cout<<"1-Eftetah Hesab:";
gotoxy(18,14);
cout<<"2-Daryaft Mojodi:";
gotoxy(18,16);
cout<<"3-Pardakht Mojodi:";
gotoxy(18,18);
cout<<"4-Mohasebe sood:";
gotoxy(18,20);
cout<<"5-safhe asli:";
gotoxy(18,22);
cout<<"Enter Menu Select Number: [ ";
gotoxy(46,22);
cout<<"]";
}
//******************************************//
void banck::daryaftmojodi()
{
gotoxy(10,12);
cout<<"Nmae:";
gotoxy(28,12);
cout<<"[ ]"<<" Ali";
gotoxy(10,14);
cout<<"Last Name:";
gotoxy(28,14);
cout<<"[ ]"<<" Ahmadi";
gotoxy(10,16);
cout<<"Somare Hesab:";
gotoxy(28,16);
cout<<"[ ]"<<" 802173";
gotoxy(10,18);
cout<<"Mablagh Be Adad:";
gotoxy(28,18);
cout<<"[ ] Riyal "<<" 50000";
gotoxy(10,20);
cout<<"Tarikh Daryaft:";
gotoxy(28,20);
cout<<"[ ]"<<" 19/4/86";
gotoxy(10,22);
cout<<"Prees S Key To Save:";
gotoxy(28,22);
cout<<"[ ]"<<" S";
}
//******************************************//