Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

#include <afxwin.h> #include \"resource2.h\" //2.3 #include <afxtempl.h> //using

ID: 3653217 • Letter: #

Question

#include <afxwin.h>

#include"resource2.h"//2.3

#include<afxtempl.h>

//using namespace std;

CArray<CPoint,CPoint> array1;

//CArray<CPoint, CPoint> array1;

//CArray

class MyFrame:public CFrameWnd

{

private:

CMenu *pMenu;//2.3

CPoint bpoint;

public:

MyFrame()

{

Create( NULL, "Tic Tac Toe" );

pMenu = new CMenu();//2.3

pMenu->LoadMenu( IDR_MENU1 );//2.3

SetMenu( pMenu );//2.3

}

afx_msg void OnPaint()

{

CPaintDC dc(this);

dc.Rectangle( 0,0,50,50 );

dc.Rectangle( 50,0,100,50 );

dc.Rectangle( 100,0,150,50 );

dc.Rectangle( 0,50,50,100 );

dc.Rectangle( 50,50,100,100 );

dc.Rectangle( 100,50,150,100 );

dc.Rectangle( 0,100,50,150 );

dc.Rectangle( 50,100,100,150 );

dc.Rectangle( 100,100,150,150 );


}




afx_msg void OnLButtonDown( UINT nFlags, CPoint point )

{

SetCapture();

}


afx_msg void OnLButtonUp( UINT nFlags, CPoint point )

{

CClientDC dc(this);

//dc.MoveTo(bpoint);


//int r,g,b;

//CBrush brush( RGB( 255, 255, 255 ) );

//dc.FillRect( CRect( 0,0,320,320 ), &brush );

for( int i=0; i<10; i++ )

{


CPen pen1( PS_SOLID, 5, RGB( 0,0,255 ) );

dc.SelectObject( &pen1 );


CRect circle1( 0,0,50,50 );

CRect circle2( 50,0,100,50 );

CRect circle3( 100,0,150,50 );

CRect circle4( 0,50,50,100 );

CRect circle5( 50,50,100,100 );

CRect circle6( 100,50,150,100 );

CRect circle7( 0,100,50,150 );

CRect circle8( 50,100,100,150 );

CRect circle9( 100,100,150,150 );

if (circle1.PtInRect(point) )

{

//dc.Ellipse( 5,5,45,45 );

dc.MoveTo( 5, 5 );

dc.LineTo( 45, 45 );


dc.MoveTo( 45, 5 );

dc.LineTo( 5, 45 );

}


else if (circle2.PtInRect(point) )

{

//dc.Ellipse( 55,5,95,45 );

dc.MoveTo( 55, 5);

dc.LineTo( 95, 45 );

dc.MoveTo( 95, 5 );

dc.LineTo( 55, 45 );

}

else if (circle3.PtInRect(point) )

{

//dc.Ellipse(105,5,145,45 );

dc.MoveTo( 105, 5);

dc.LineTo( 145, 45 );

dc.MoveTo( 145, 5 );

dc.LineTo( 105, 45 );


}

else if (circle4.PtInRect(point) )

{

//dc.Ellipse(5,55,45,95 );

dc.MoveTo( 5, 55);

dc.LineTo( 45, 95 );

dc.MoveTo( 45, 55 );

dc.LineTo( 5, 95 );

}

else if (circle5.PtInRect(point) )

{

//dc.Ellipse(55,55,95,95 );

dc.MoveTo( 55, 55);

dc.LineTo( 95, 95 );

dc.MoveTo( 95, 55 );

dc.LineTo( 55, 95 );

}

else if (circle6.PtInRect(point) )

{

//dc.Ellipse(105,55,145,95 );

dc.MoveTo( 105, 55);

dc.LineTo( 145, 95 );

dc.MoveTo( 145, 55 );

dc.LineTo( 105, 95 );

}

else if (circle7.PtInRect(point) )

{

//dc.Ellipse(5,105,45,145 );

dc.MoveTo( 5, 105);

dc.LineTo( 45, 145 );

dc.MoveTo( 45, 105 );

dc.LineTo( 5, 145 );

}

else if (circle8.PtInRect(point) )

{

//dc.Ellipse(55,105,95,145 );

dc.MoveTo( 55, 105);

dc.LineTo( 95, 145 );

dc.MoveTo( 95, 105 );

dc.LineTo( 55, 145 );

}

else if (circle9.PtInRect(point) )

{

//dc.Ellipse(105,105,145,145);

dc.MoveTo( 105, 105);

dc.LineTo( 145, 145 );

dc.MoveTo( 145, 105 );

dc.LineTo( 105, 145 );

}

//dc.Rectangle( x1, y1, x2, y2 );

}


ReleaseCapture();

}

afx_msg void RESTART()

{

CClientDC dc(this);

CBrush brush( RGB( 255, 255, 255 ) );

dc.SelectObject( &brush );

dc.Rectangle( 0,0,50,50 );

dc.Rectangle( 50,0,100,50 );

dc.Rectangle(100,0,150,50 );

dc.Rectangle(0,50,50,100 );

dc.Rectangle(50,50,100,100 );

dc.Rectangle(100,50,150,100 );

dc.Rectangle(0,100,50,150 );

dc.Rectangle(50,100,100,150 );

dc.Rectangle(100,100,150,150);


}


DECLARE_MESSAGE_MAP()


};

BEGIN_MESSAGE_MAP(MyFrame,CFrameWnd)

ON_WM_PAINT()

ON_WM_LBUTTONDOWN()

ON_WM_LBUTTONUP()

ON_WM_MOUSEMOVE()

ON_COMMAND( ID_APP_RESTART, RESTART )


END_MESSAGE_MAP()



class MyApp :public CWinApp

{

public:

BOOL InitInstance()

{

CFrameWnd *frame=new MyFrame();

m_pMainWnd=frame;

//frame->Create(NULL,"Hello MFC");

frame->ShowWindow(SW_SHOW);

return true;

}

};

MyApp app;

Explanation / Answer

//Tic Tac Toe Game #include #define X 'X' #define O 'O' #define yes 1 #define no 0 int check (char[][3], int, int); void counteratk (char x[][3], char turn); void progress (char x[][3]); void main() { char x[3][3]; int row,col,correct=yes,turn,game=yes,counter=0,r,c,d; for (row=0; row