Đây là code và lỗi,mọi người cho em xin cách để fix với ạ.
Code cua file banco:
#include <graphics.h>
#include <iostream>
#include <windows.h>
#include <string>
#include "oco.cpp"
using namespace std;
class BanCo
{
public:
int hang;
int cot;
int marginHang;//khai bao bien marginHang de tinh le cua hang
int marginCot;//khai bao bien marginCot de tinh le cua cot
Oco oco[100][100];
void vebanco()
{
int mh=6,mode=1,i;
initgraph(&mh,&mode," ");
settextstyle(1,0,3);
outtextxy(400,0,"CoCaro");
setcolor(RED);
outtextxy(350,50,"X");
setcolor(BLUE);
outtextxy(550,50,"O");
setcolor(WHITE);
for(int i =0; i<= hang; i++)
{
//toa do goc cua ban co la pixel: (marginCot, marginHang), (x=0, y=0)
//start (margin + x, margin+ y+i*doronghang), end (margin + x+cot*dorongcot, margin + y+i*doronghang)
int xpixelStart = marginCot ;
int ypixelStart = marginHang +i*Oco::dorongHang ;
int xpixelStop = marginCot + cot * Oco::dorongCot;
int ypixelStop = marginHang + i * Oco::dorongHang;
line(xpixelStart, ypixelStart, xpixelStop, ypixelStop);
}
for(int j = 0; j<=cot; j++)
{
//toa do goc cua ban co la pixel: (marginCot, marginHang), (x=0, y=0)
//start (margin + x, margin+ y+j*dorongCot), end (margin+j*doronghang, margin + y+j*dorongcot)
int xpixelStart = marginCot +j*Oco::dorongCot ;
int ypixelStart = marginHang ;
int xpixelStop = marginCot + j * Oco::dorongCot;
int ypixelStop = marginHang + hang * Oco::dorongHang;
line(xpixelStart, ypixelStart, xpixelStop, ypixelStop);
}
}
void vexo(int n,int m,char s)
{
}
};
int main()
{
int hang,cot,x;
BanCo bc;
bc.cot = 12;
bc.hang = 14;
bc.marginCot = 240;
bc.marginHang = 240;
bc.vebanco();
int c= Oco::convertCot2X(x);
cout<<c;
getch();
}
Code của file Oco:
#include "banco.cpp"
using namespace std;
class Oco
{
public :
static const int dorongHang = 35; //do rong cua moi hang cach nhau 35 pixel
static const int dorongCot = 35;//do rong cua moi cot cach nhau 35 pixel
int hang =0;//so hang
int cot = 0;
int pixelX =0;//Khi click chuot se tra ve toa do cua pixel x tu do convert sang cot
int pixelY = 0;//Khi click chuot se tra ve toa do cua pixel y tu do convert sang hang
int trangthai = 0 ;// 0: trong, 1: X, 2: O
//function
int convertX2Cot(int X); // truyen vao pixel x tra ve o cua cot thu bao nhieu
int convertY2Hang(int Y);
int convertCot2X(int cot);
int convertHang2Y(int hang);
static int convertX2Cot(int x)
{
return (x-BanCo.marginCot)/dorongCot;
}
};