Click to See Complete Forum and Search --> : PLease Help me in C++-1


mrsrinath
November 6th, 2009, 01:45 PM
I have to submit my project tomorrow.Please help me.
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
#include<graphics.h>
#include<dos.h>
#include<math.h>
#include<process.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<fstream.h>
struct chess
{
int pc;
char pe;};

int checkb(int ipr,int ipc,int fpr,int fpc,char ch[][8],int pc[][8],int ip3,int ip4)
{ int i,j;
for(i=ipr-1,j=ipc-1;i<fpr&&j<fpc;i++,j--)
if(ch[i][j]!='A')
// if(pc[ip3][ip4]==pc[i][j])
return 1;
return 0;
}


int bishop(int ip3,int ip4, int fp3, int fp4,char ch[][8],int pc[][8])
{
int i,j;
if(fp3-ip3!=fp4-ip4&&fp3-ip3!=ip4-fp4)
return 1;
if(ip3<fp3)
{ if(ip4<fp4)
if(checkb(ip3,ip4,fp3,fp4,ch,pc,ip3,ip4)==1)
return 1;

if(fp4<ip4)
if(checkb(ip3,fp4,fp3,ip4,ch,pc,ip3,ip4)==1)
return 1;
}
if(fp3<ip3)
{
if(ip4<fp4)
if(checkb(fp3,ip4,ip3,fp4,ch,pc,ip3,ip4)==1)
return 1;

if(fp4<ip4)
if(checkb(fp3,fp4,ip3,ip4,ch,pc,ip3,ip4)==1)
return 1;

}
else
if(pc[ip3][ip4]==pc[fp3][fp4])
return 1;

else
return 0;

}

int horse(int ip3,int ip4,int fp3,int fp4,char ch[][8],int pc[][8])
{
int i,sum=0;

if(ip3!=fp3-1&&ip3!=fp3+1&&ip4!=fp4+1&&ip4!=fp4-1)
sum++;
if(ip3!=fp3+2&&ip3!=fp3-2&&ip4!=fp4+2&&ip4!=fp4-2)
sum++;
if(sum>=1)
return 1;
else
if(pc[ip3][ip4]==pc[fp3][fp4])
return 1;
else
return 0;

}
int rook(int ip3,int ip4,int fp3,int fp4,char ch[][8],int pc[][8])
{
int i;

if(ip3!=fp3&&ip4!=fp4)
return 1;

if(ip3==fp3)
{
if(ip4<fp4)
for(i=ip4+1;i<fp4;i++)
if(ch[ip3][i]!='A')
// if(pc[ip3][ip4]==pc[ip3][i])
return 1;

if(fp4<ip4)
for(i=fp4+1;i<ip4;i++)
if(ch[ip3][i]!='A')
//if(pc[ip3][ip4]==pc[ip3][i])
return 1;
}
else
if(ip4==fp4)
{
if(ip3<fp3)
for(i=ip3+1;i<fp3;i++)
if(ch[i][ip4]!='A')
//if(pc[ip3][ip4]==pc[i][ip4])
return 1;

if(fp3<ip3)
for(i=fp3+1;i<ip3;i++)
if(ch[i][ip4]!='A')
//if(pc[ip3][ip4]==pc[i][ip4])
return 1;
}
else
if(pc[ip3][ip4]==pc[fp3][fp4])
return 1;
else
return 0;
}

class place
{
public:
char name[50];
char type[50];
int lotno;
int own;
float lotvalue;
float sharebuy;
float sharesell;
int nobuild;
float buildvalue;
float total;
place()
{
own=0;
buildvalue=0;
}

}lot[22];

class player
{public:

int posn;
float cash;
float lots[20];
float lotval;
float build[20];
float buildval;
float share[20];
float shareval;
float loan;
float salary;
float total;
void disposn(char a);
void displayer(char a);
player()
{
posn=1;
cash=5000000;
for(int i=0;i<20;i++)
{
lots[i]=0;
build[i]=0;
share[i]=0;
}
lotval=0;
buildval=0;
shareval=0;
loan=0;
salary=30000;
total=5000000;
}
void totalcalc(int n);

};

void player :: totalcalc(int n)
{
float sharecost=0,lvalue=0,bvalue=0;
for(int i=0;i<20;i++)
{
sharecost+=share[i]*lot[i].sharesell;
if(lot[i].own==n)
{lvalue+=lot[i].lotvalue;
bvalue+=lot[i].buildvalue;
}
}
total=cash+sharecost+lvalue+bvalue-loan;

}
void player :: disposn(char a)
{ char b[3];
b[0]=a;
b[1]='\0';
settextstyle(7,0,0);
if (posn>=1&&posn<=6)
outtextxy(45+50*(posn-1),15,b);
else
if(posn>=6&&posn<=11)
outtextxy(295,15+50*(posn-6),b);
else
if(posn>=11&&posn<=16)
outtextxy(295-50*(posn-11),265,b);
else
if(posn>=16)
outtextxy(45,265-50*(posn-16),b);

}

void bothdisp(int posn)
{ settextstyle(7,0,0);
char a[3],b[3];
a[0]='A';
a[1]='\0';
b[0]='B';
b[1]='\0';
if (posn>=1&&posn<=6)
{ outtextxy(45+50*(posn-1)-15,15,a);
outtextxy(45+50*(posn-1)+12,15,b);}

else
if(posn>=6&&posn<=11)
{ outtextxy(295-15,15+50*(posn-6),a);
outtextxy(295+12,15+50*(posn-6),b);}
else
if(posn>=11&&posn<=16)
{outtextxy(295-50*(posn-11)-15,265,a);
outtextxy(295-50*(posn-11)+12,265,b);}
else
if(posn>=16)
{ outtextxy(45-15,265-50*(posn-16),a);
outtextxy(45+12,265-50*(posn-16),b);}

}


void lotinitialise()
{

strcpy(lot[0].name,"1. Cafe Charm");
lot[0].sharebuy=68;
lot[0].sharesell=floor( (lot[0].sharebuy*97)/100);
lot[0].lotvalue=600000;
lot[0].lotno=0;

int i=1,j=0;
strcpy(lot[i].name,"2. Pizza Almara");
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;

strcpy(lot[i].name,"3. Trees and Woods");
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;

strcpy(lot[i].name,"4. Danddy Furnitures");
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;

strcpy(lot[i].name,"5. Stassi Oil ");
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;

strcpy(lot[i].name,"6. Decent Harry");
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;

strcpy(lot[i].name,"7. Mclaven Tavern");
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;

strcpy(lot[i].name,"8. Others clothings");
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;

strcpy(lot[i].name,"9. Kwiki Mart");
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;

strcpy(lot[i].name,"10. Grand Threatre"); //i=9;
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;

strcpy(lot[i].name,"11. Homemakers"); //i=10;
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;

strcpy(lot[i].name,"12. Bouteq Resturant "); //i=11;
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;

strcpy(lot[i].name,"13. Bob's Car"); //i=12;
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;

strcpy(lot[i].name,"14. Flying Saucer"); //i=13;
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;

strcpy(lot[i].name,"15. Airways"); //i=14;
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;

strcpy(lot[i].name,"16. Share Invest"); //i=15;
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;

strcpy(lot[i].name,"17. Banana Computers"); //i=16;
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;

strcpy(lot[i].name,"18. Millinaire bank"); //i=17;
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;


strcpy(lot[i].name,"19. On & Off"); //i=18;
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;

strcpy(lot[i].name,"20. Electromania"); //i=19;
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;


}

void outstockmarket()
{
outtextxy(340,180,"Company");
outtextxy(510,180,"Buy");
outtextxy(590,180,"Sell");
for(int i=0;i<20;i++)
{
outtextxy(340,200+(i*13),lot[i].name);
char out[30];
sprintf(out,"%f",lot[i].sharebuy);
for(int j=0;j<strlen(out);j++)
if(out[j]=='.')
out[j]='\0';
outtextxy(510,200+(i*13),out);
sprintf(out,"%f",lot[i].sharesell);
for(j=0;j<strlen(out);j++)
if(out[j]=='.')
out[j]='\0';
outtextxy(590,200+(i*13),out);
}

}

void inflate()
{
int rate=random(7)-2;
int randomlot=random(20);
lot[randomlot].sharebuy+=(rate*lot[randomlot].sharebuy)/100.0;
lot[randomlot].sharesell=floor( (lot[randomlot].sharebuy*97)/100);
lot[randomlot].lotvalue+=(1.0*rate*lot[randomlot].lotvalue)/100;
}

void outplayerinfo(player a,player b)
{ settextstyle(0,0,1);
line(480,0,480,170);
line(380,140,480,140);
line(530,140,640,140);
line(332,170,640,170);
outtextxy(370,0,"Player 1");
outtextxy(530,0,"Player 2");
outtextxy(340,30,"Cash");
outtextxy(490,30,"Cash");
outtextxy(340,50,"Lots");
outtextxy(490,50,"Lots");
outtextxy(340,70,"Build");
outtextxy(490,70,"Build");
outtextxy(340,90,"Shares");
outtextxy(490,90,"Shares");
outtextxy(340,110,"Loan");
outtextxy(490,110,"Loan");
outtextxy(340,130,"Salary");
outtextxy(490,130,"Salary");
outtextxy(340,150,"Total");
outtextxy(490,150,"Total");
char out[30];
sprintf(out,"%f",a.cash);
for(int i=0;i<strlen(out);i++)
if(out[i]=='.')
out[i]='\0';
outtextxy(410,30,out);

sprintf(out,"%f",b.cash);
for(i=0;i<strlen(out);i++)
if(out[i]=='.')
out[i]='\0';
outtextxy(570,30,out);

for(i=0;i<20;i++)
{
if(lot[i].own==1)
{a.lotval+=lot[i].lotvalue;
a.buildval+=lot[i].buildvalue;
}
if(lot[i].own==2)
{b.lotval+=lot[i].lotvalue;
b.buildval+=lot[i].buildvalue;
}
}
sprintf(out,"%f",a.lotval);
for(i=0;i<strlen(out);i++)
if(out[i]=='.')
out[i]='\0';
outtextxy(410,50,out);

sprintf(out,"%f",b.lotval);
for(i=0;i<strlen(out);i++)
if(out[i]=='.')
out[i]='\0';
outtextxy(570,50,out);

sprintf(out,"%f",a.buildval);
for(i=0;i<strlen(out);i++)
if(out[i]=='.')
out[i]='\0';
outtextxy(410,70,out);

sprintf(out,"%f",b.buildval);
for(i=0;i<strlen(out);i++)
if(out[i]=='.')
out[i]='\0';
outtextxy(570,70,out);

a.shareval=0;
b.shareval=0;
for(int j=0;j<20;j++)
{
a.shareval+=a.share[j]*lot[j].sharesell;
b.shareval+=b.share[j]*lot[j].sharesell;
}
sprintf(out,"%f",a.shareval);
for(i=0;i<strlen(out);i++)
if(out[i]=='.')
out[i]='\0';
outtextxy(410,90,out);

sprintf(out,"%f",b.shareval);
for(i=0;i<strlen(out);i++)
if(out[i]=='.')
out[i]='\0';
outtextxy(570,90,out);

sprintf(out,"%f",a.loan);
for(i=0;i<strlen(out);i++)
if(out[i]=='.')
out[i]='\0';
outtextxy(410,110,out);

sprintf(out,"%f",b.loan);
for(i=0;i<strlen(out);i++)
if(out[i]=='.')
out[i]='\0';
outtextxy(570,110,out);

sprintf(out,"%f",a.salary);
for(i=0;i<strlen(out);i++)
if(out[i]=='.')
out[i]='\0';
outtextxy(410,130,out);

sprintf(out,"%f",b.salary);
for(i=0;i<strlen(out);i++)
if(out[i]=='.')
out[i]='\0';
outtextxy(570,130,out);

sprintf(out,"%f",a.total);
for(i=0;i<strlen(out);i++)
if(out[i]=='.')
out[i]='\0';
outtextxy(410,150,out);

sprintf(out,"%f",b.total);
for(i=0;i<strlen(out);i++)
if(out[i]=='.')
out[i]='\0';
outtextxy(570,150,out);

}Cont...