import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class xo2 extends Applet implements MouseListener{ int n=0; int z=0; int a1=0; int a2=0; int a3=0; int b1=0; int b2=0; int b3=0; int c1=0; int c2=0; int c3=0; public void DrawX(int x, int y){ Graphics g=getGraphics(); Image img1=getImage(getCodeBase(), "g_x.jpg"); g.drawImage(img1, x, y, this); } public void DrawO(int x, int y){ Graphics g=getGraphics(); Image img1=getImage(getCodeBase(), "g_o.jpg"); g.drawImage(img1, x, y, this); } public void DrawOW(int x, int y){ Graphics g=getGraphics(); Image img1=getImage(getCodeBase(), "g_ow.jpg"); g.drawImage(img1, x, y, this); } public void DrawXW(int x, int y){ Graphics g=getGraphics(); Image img1=getImage(getCodeBase(), "g_xw.jpg"); g.drawImage(img1, x, y, this); } public void paint (Graphics g){ Image img1=getImage(getCodeBase(), "g_o.jpg"); g.drawImage(img1, 0, 0,getSize().width, getSize().height, this); Image img3=getImage(getCodeBase(), "g_ow.jpg"); g.drawImage(img3, 0, 0,getSize().width, getSize().height, this); Image img4=getImage(getCodeBase(), "g_xw.jpg"); g.drawImage(img4, 0, 0,getSize().width, getSize().height, this); Image img2=getImage(getCodeBase(), "g_x.jpg"); g.drawImage(img2, 0, 0,getSize().width, getSize().height, this); g.drawLine(40, 0, 40, 122); g.drawLine(81, 0, 81, 122); g.drawLine(0, 40, 122, 40); g.drawLine(0, 81, 122, 81); } public void init(){ addMouseListener(this); } public void mousePressed(MouseEvent e){ //a1 if(n!=10){ if(e.getX()<40 && e.getY()<40 && a1==0){ DrawX(0, 0); a1=1; z=1; n=n+1; } //a2 if(e.getX()>40 && e.getY()<40 && e.getX()<81 && a2==0){ DrawX(41, 0); a2=1; z=1; n=n+1; } //a3 if(e.getX()>81 && e.getY()<40 && a3==0){ DrawX(82, 0); a3=1; z=1; n=n+1; } //b1 if(e.getX()<40 && e.getY()>40 && e.getY()<81 && b1==0){ DrawX(0, 41); b1=1; z=1; n=n+1; } //b2 if(e.getX()>40 && e.getX()<81 && e.getY()>40 && e.getY()<81 && b2==0){ DrawX(41, 41); b2=1; z=1; n=n+1; } //b3 if(e.getX()>81 && e.getY()>40 && e.getY()<81 && b3==0){ DrawX(82, 41); b3=1; z=1; n=n+1; } //c1 if(e.getX()<40 && e.getY()>81 && c1==0){ DrawX(0, 82); c1=1; z=1; n=n+1; } //c2 if(e.getX()>40 && e.getY()>81 && e.getX()<81 && c2==0){ DrawX(41, 82); c2=1; z=1; n=n+1; } //c3 if(e.getX()>81 && e.getY()>81 && c3==0){ DrawX(82, 82); c3=1; z=1; n=n+1; } if(a1+a2+a3==3){DrawXW(0, 0);DrawXW(41, 0);DrawXW(82, 0);n=10;} if(b1+b2+b3==3){DrawXW(0, 41);DrawXW(41, 41);DrawXW(82, 41);n=10;} if(c1+c2+c3==3){DrawXW(0, 82);DrawXW(41, 82);DrawXW(82, 82);n=10;} if(a1+b1+c1==3){DrawXW(0, 0);DrawXW(0, 41);DrawXW(0, 82);n=10;} if(a2+b2+c2==3){DrawXW(41, 0);DrawXW(41, 41);DrawXW(41, 82);n=10;} if(a3+b3+c3==3){DrawXW(82, 0);DrawXW(82, 41);DrawXW(82, 82);n=10;} if(a1+b2+c3==3){DrawXW(0, 0);DrawXW(41, 41);DrawXW(82, 82);n=10;} if(a3+b2+c1==3){DrawXW(82, 0);DrawXW(41, 41);DrawXW(0, 82);n=10;} if(z==1){ if(n==1){ if(b2==0){ DrawO(41, 41); b2=5; } else{ DrawO(0, 0); a1=5; } } if(n==2 || n==3 || n==4){ if(a1+a2+a3==2){ if(a1==0){DrawO(0, 0); a1=5;} if(a2==0){DrawO(41, 0); a2=5;} if(a3==0){DrawO(82, 0); a3=5;} } else{ if(b1+b2+b3==2){ if(b1==0){DrawO(0, 41); b1=5;} if(b2==0){DrawO(41, 41); b2=5;} if(b3==0){DrawO(82, 41); b3=5;} } else{ if(c1+c2+c3==2){ if(c1==0){DrawO(0, 82); c1=5;} if(c2==0){DrawO(41, 82); c2=5;} if(c3==0){DrawO(82, 82); c3=5;} } else{ if(a1+b1+c1==2){ if(a1==0){DrawO(0, 0); a1=5;} if(b1==0){DrawO(0, 41); b1=5;} if(c1==0){DrawO(0, 82); c1=5;} } else{ if(a2+b2+c2==2){ if(a2==0){DrawO(41, 0); a2=5;} if(b2==0){DrawO(41, 41); b2=5;} if(c2==0){DrawO(41, 82); c2=5;} } else{ if(a3+b3+c3==2){ if(a3==0){DrawO(82, 0); a3=5;} if(b3==0){DrawO(82, 41); b3=5;} if(c3==0){DrawO(82, 82); c3=5;} } else{ if(a1+b2+c3==2){ if(a1==0){DrawO(0, 0); a1=5;} if(b2==0){DrawO(41, 41); b2=5;} if(c3==0){DrawO(82, 82); c3=5;} } else{ if(a3+b2+c1==2){ if(a3==0){DrawO(82, 0); a3=5;} if(b2==0){DrawO(41, 41); b2=5;} if(c1==0){DrawO(0, 82); c1=5;} } else{ if(a1==0){DrawO(0, 0); a1=5;} else{ if(a3==0){DrawO(82, 0); a3=5;} else{ if(c1==0){DrawO(0, 82); c1=5;} else{ if(c3==0){DrawO(82, 82); c3=5;} else{ if(b2==0){DrawO(41, 41); b2=5;} else{ if(b3==0){DrawO(82, 41); b3=5;} else{ if(a2==0){DrawO(41, 0); a2=5;} else{ if(c2==0){DrawO(41, 82); c2=5;} else{ if(b1==0){DrawO(0, 41); b1=5;} } } } } } } } } } } } } } } } } } z=0; } if(a1+a2+a3==15){DrawOW(0, 0);DrawOW(41, 0);DrawOW(82, 0);n=10;} if(b1+b2+b3==15){DrawOW(0, 41);DrawOW(41, 41);DrawOW(82, 41);n=10;} if(c1+c2+c3==15){DrawOW(0, 82);DrawOW(41, 82);DrawOW(82, 82);n=10;} if(a1+b1+c1==15){DrawOW(0, 0);DrawOW(0, 41);DrawOW(0, 82);n=10;} if(a2+b2+c2==15){DrawOW(41, 0);DrawOW(41, 41);DrawOW(41, 82);n=10;} if(a3+b3+c3==15){DrawOW(82, 0);DrawOW(82, 41);DrawOW(82, 82);n=10;} if(a1+b2+c3==15){DrawOW(0, 0);DrawOW(41, 41);DrawOW(82, 82);n=10;} if(a3+b2+c1==15){DrawOW(82, 0);DrawOW(41, 41);DrawOW(0, 82);n=10;} } } public void mouseReleased(MouseEvent e){} public void mouseExited(MouseEvent e){} public void mouseEntered(MouseEvent e){} public void mouseClicked(MouseEvent e){} }