Trending ▼   ResFinder  

ICSE − Q & A

475 Users in the Group
Moderator: Trisha Pattnaik  
+Join

Ask a Question

Answer a Question!

ResFinder - Thousands of Practice Papers

Guys just for a bit of fun i did create a small and choti game ( X and O game ) ...everyone know it right.....Just for the sake of my happiness just copy this and try executing it and see the output once.....i did put in lot of effort during creation...there were days where i stayed till 4 AM to fix the bugs.....It is quite a lengthy one...heheh..dont get irritated and do it patiently....( shortcut way is to press Ctrl +A and remove this above stuff in your blue j window..........thaanku eri much
//This program was uploaded on TextUploader site and the link is : http://textuploader.com/ac9ds
package Strings;
import java.io.*;
/**
 * Play this game with zeal ....A game of X and O
 * 
 * Here you enter the world of Tic Tac Toe ....
 * 
 * Any Bugs ! Let me Know ....
 * 
 * Programmer@MP Harsha !! 
 * 
 * My first game ever created .......
 * 
 * Enjoy the game ...Hope you will like it GUYS ..
 */
class OX_GAME
{
  static char check(char ch[],int i)
   {
       char win2=' ';
       if(ch[8]=='X'&&ch[10]=='X'&&ch[12]=='X')
          {
            win2='X';
            i=60;
         }
            else if(ch[8]=='O'&&ch[10]=='O'&&ch[12]=='O')
            { 
            win2='O';
            i=60;
            }
        if(ch[8]=='X'&&ch[24]=='X'&&ch[40]=='X')
        {
            win2='X';
            i=60;
        }
        else if(ch[8]=='O'&&ch[24]=='O'&&ch[40]=='O')
        {
            win2='O';
            i=60;
        }
        if(ch[24]=='X'&&ch[26]=='X'&&ch[28]=='X')
        {
            win2='X';
            i=60;
        }
        else if(ch[24]=='O'&&ch[26]=='O'&&ch[28]=='O')
        {
            win2='O';
            i=60;
        }
        if(ch[40]=='X'&&ch[42]=='X'&&ch[44]=='X')
        {
            win2='X';
            i=60;
        }
        else if(ch[40]=='O'&&ch[42]=='O'&&ch[44]=='O')
        {
            win2='O';
            i=60;
        }
        if(ch[10]=='X'&&ch[26]=='X'&&ch[42]=='X')
        {
            win2='X';
            i=60;
        }
        else if(ch[10]=='O'&&ch[26]=='O'&&ch[42]=='O')
        {
            win2='O';
            i=60;
        }
        if(ch[12]=='X'&&ch[28]=='X'&&ch[44]=='X')
        {
            win2='X';
            i=60;
        }
        else if(ch[12]=='O'&&ch[28]=='O'&&ch[44]=='O')
        {
            win2='O';
            i=60;
        }
        if(ch[8]=='X'&&ch[26]=='X'&&ch[44]=='X')
        {
            win2='X';
            i=60;
        }
        else if(ch[8]=='O'&&ch[26]=='O'&&ch[44]=='O')
        {
            win2='O';
            i=60;
        }
        if(ch[12]=='X'&&ch[26]=='X'&&ch[40]=='X')
        {
            win2='X';
            i=60;
        }
        else if(ch[12]=='O'&&ch[26]=='O'&&ch[40]=='O')
        {
            win2='O';
            i=60;
        }
        return win2;
    }
  public static void main()throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        System.out.print("Enter the name of PLAYER 1 :");
        String s1=br.readLine();
        System.out.print("Enter the name of PLAYER 2 :");
        String s2=br.readLine();
        int fill=0,flag=1;
        int i=8,m=8,p=8,n2=0,a=0,a1=0,b=0,h=0,h1=0,a2=0,a3=0;
        char ch[]={' ','_',' ','_',' ','_','\n',
                   '|',' ','|',' ','|',' ','|',' ','\n',
                   ' ','-',' ','-',' ','-','\n',
                   '|',' ','|',' ','|',' ','|',' ','\n',
                   ' ','-',' ','-',' ','-','\n',
                   '|',' ','|',' ','|',' ','|',' ','\n',
                   ' ','-',' ','-',' ','-','\n',
                  };
                  System.out.print("\f");
                  ch[8]='X';
                  System.out.print(ch);
          for(;(i<=53&&fill<9);)
         {
             if(check(ch,i)!='X'||check(ch,i)!='O')flag=0;
        for(;(flag<1&&fill<9);)
          {
            while(a==1)
            {
                if(m==14||m==30||m==46) m=m+10;
                if(ch[m]==' ')
                {
                ch[m]='X';
                a=0;
                System.out.print(ch);
                }
                else
                m=m+2;          
            }
            System.out.print("6 :come towards RIGHT\n5 :FIX X\nPLAYER 1(X):");
            int n=Integer.parseInt(br.readLine());
            if(n==6&&m!=44)
            {
                i=m;
                if(i==12||i==28||i==44)
                {
                    if(ch[i+12]!=' ')
                    {
                     ch[i]=' ';
                     i=i+2;
                     m=m+2;
                    }
                    if(ch[i+12]!=' ')
                    {
                      ch[i]=' ';
                     i=i+2;
                     m=m+2;
                    }
                    if(ch[i+12]!=' ')
                    {
                     i=i+24;
                     m=m+24;
                    }
                    if(i==40)
                    {
                        while(a2==0&&i<=42)
                        {
                            if(ch[i]==' ')break;
                            if(ch[i+2]==' ')
                            {
                                i=i+2;
                                m=m+2;
                                break;
                            }
                            if(ch[i+2]!=' ')
                            {
                                i=i+2;
                                m=m+2;
                            }
                            else
                            {
                                i=i+2;
                                m=m+2;
                            }
                        }
                        if(i==42&&ch[i]!=' ')
                        {
                            i=i+2;
                            m=m+2;
                        }
                    }
                    else
                    {
                     ch[i]=' ';
                     i=i+12;
                     m=m+12;
                    }
                    ch[i]='X';
                    System.out.print("\f");
                    System.out.print(ch);
                }
                else 
                {
                    char temp=ch[i];
                    if(ch[i+2]=='O'||ch[i+2]=='X')
                    {
                        if(i==10||i==26||i==42)
                         {
                             ch[i]=' ';
                             if(ch[i+14]==' ')
                                {
                                    i=i+14;
                                    m=m+14;
                                    ch[i]=temp;
                                }
                                else
                                {
                                    i=i+16;
                                    m=m+16;
                                    if(ch[i]==' ')ch[i]=temp;
                                    else
                                    {
                                        i=i+2;
                                        m=m+2;
                                        if(ch[i]==' ')ch[i]=temp;
                                        else
                                        {
                                            i=i+12;
                                            m=m+12;
                                            if(ch[i]==' ')ch[i]=temp;
                                            else
                                            {
                                                i=i+2;
                                                m=m+2;
                                                if(ch[i]==' ')ch[i]=temp;
                                                else
                                                {
                                                    i=i+2;
                                                    m=m+2;
                                                    if(ch[i]==' ')ch[i]=temp;
                                                }
                                            }
                                        }
                                    }
                                }
                             if(i==14&&ch[i+14]!=' ')
                                 {
                                     i=i+26;
                                     m=m+26;
                                     if(ch[i]==' ')ch[i]=temp;
                                     else
                                     {
                                       i=i+2;
                                       m=m+2;
                                       if(ch[i]==' ')ch[i]=temp;
                                       else
                                       {
                                         i=i+2;
                                         m=m+2;
                                         if(ch[i]==' ')ch[i]=temp;
                                       }
                                     }
                                 }    
                             if(i==26&&ch[i]==' ')
                              {
                                     if(ch[i+2]==' ')
                                     {
                                         i=i+2;
                                         m=m+2;
                                         ch[i]=temp;
                                        }
                                        else
                                        {
                                            i=i+14;
                                            m=m+14;
                                            if(ch[i]==' ')ch[i]=temp;
                                            else
                                            {
                                                i=i+2;
                                                m=m+2;
                                                if(ch[i]==' ')ch[i]=temp;
                                                else
                                                {
                                                    i=i+2;
                                                    m=m+2;
                                                    if(ch[i]==' ')ch[i]=temp;
                                                }
                                            }
                                        }
                              }
                        }
                         else if((i==8||i==24)&&ch[i+4]!=' ')
                        {
                            if(ch[i+4]!=' ')
                            {
                                ch[i]=' ';
                                i=i+16;
                                m=m+16;
                                if(ch[i]==' ')ch[i]=temp;
                                else 
                                {
                                    i=i+2;
                                    m=m+2;
                                    if(ch[i]==' ')ch[i]=temp;
                                    else
                                    {
                                        i=i+2;
                                        m=m+2;
                                        if(ch[i]==' ')ch[i]=temp;
                                        else
                                        {
                                              if(ch[i]!=' '&&i==28)
                                               {
                                                 i=i+12;
                                                 m=m+12;
                                                 if(ch[i]==' ')ch[i]=temp;
                                                 else
                                                 {
                                                    i=i+2;
                                                    m=m+2;
                                                    if(ch[i]==' ')ch[i]=temp;
                                                    else
                                                    {
                                                      i=i+2;
                                                      m=m+2;
                                                      if(ch[i]==' ')ch[i]=temp;
                                                    }
                                                 }
                                              }
                                           
                                        }
                                    }
                                }
                            }
                        }
                        else
                         {
                             ch[i]=ch[i+4];
                             ch[i+4]=temp;
                             i=i+4;
                             m=m+4;
                            }
                    }
                    else
                    {
                        ch[i]=ch[i+2];
                        ch[i+2]=temp;
                        i=i+2;
                        m=m+2;
                    }
                    System.out.print("\f");
                    System.out.print(ch);
                }
            }
            else if(n==6&&m==40) break;
            else if(n==5)
                {
                    fill++;
                    if(check(ch,i)=='X'||check(ch,i)=='O')
                    {
                        i=60;
                        b=1;
                        p=61;
                        fill=10;
                        break;
                    }
                    System.out.println(i);
                    n2=0;
                    System.out.print("\f");
                    while(b==0&&fill<9)
                    {
                        if(p==14||p==30||p==46) p=p+10;
                        if(ch[p]==' ')
                        {
                            ch[p]='O';
                            b=1;
                             System.out.print(ch);
                        }
                        else
                        p=p+2;
                    }
                    for(int j=p;(j<=60&&n2!=5&&fill<9);)
                    {
                          while(n2!=5)
                         {
                           System.out.print("6 :come towards RIGHT\n5 :FIX O\nPLAYER 2(O):");
                           n2=Integer.parseInt(br.readLine());
                           if(n2==6&&p!=44)
                           {
                              j=p;
                              if(j==12||j==28||j==44)
                               {
                                     if(ch[j+12]!=' ')
                                     {
                                         ch[j]=' ';
                                         j=j+2;
                                         p=p+2;
                                     }
                                     if(ch[j+12]!=' ')
                                     {
                                         j=j+2;
                                         p=p+2;
                                        }
                                     if(ch[j+12]!=' ')
                                     {
                                       j=j+24;
                                       p=p+24;
                                    }
                                    if(j==40)
                                    {
                                        while(a3==0&&j<=42)
                                        {
                                            if(ch[j]==' ')break;
                                            else if(ch[j+2]==' ')
                                            {
                                                j=j+2;
                                                p=p+2;
                                                break;
                                            }
                                            if(ch[j+2]!=' ')
                                            {
                                                j=j+2;
                                                p=p+2;
                                            }
                                            else
                                            {
                                                j=j+2;
                                                p=p+2;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        ch[j]=' ';
                                        j=j+12;
                                        p=p+12;
                                    }
                                    ch[j]='O';
                                    System.out.print("\f");
                                    System.out.print(ch);
                               }
                               else 
                               {
                                        char temp2=ch[j];
                                        if(ch[j+2]=='X'||ch[j+2]=='O')
                                      {
                                            if(j==10||j==26||j==42)
                                            {
                                                ch[j]=' ';
                                                if(ch[j+14]==' ')
                                                {
                                                    j=j+14;
                                                    p=p+14;
                                                    ch[j]=temp2;
                                                }
                                                else
                                                {
                                                    j=j+16;
                                                    p=p+16;
                                                    if(ch[j]==' ')ch[j]=temp2;
                                                    else
                                                    {
                                                        j=j+2;
                                                        p=p+2;
                                                        if(ch[j]==' ')ch[j]=temp2;
                                                        else
                                                        {
                                                            j=j+12;
                                                            p=p+12;
                                                            if(ch[j]==' ')ch[j]=temp2;
                                                            else
                                                            {
                                                                j=j+2;
                                                                p=p+2;
                                                                if(ch[j]==' ')ch[j]=temp2;
                                                                else
                                                                {
                                                                    j=j+2;
                                                                    p=p+2;
                                                                    if(ch[j]==' ')ch[j]=temp2;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                                if(j==14&&ch[j+14]!=' ')
                                                {
                                                    j=j+26;
                                                    p=p+26;
                                                    if(ch[j]==' ')ch[j]=temp2;
                                                    else
                                                    {
                                                        j=j+2;
                                                        p=p+2;
                                                        if(ch[j]==' ')ch[j]=temp2;
                                                        else
                                                        {
                                                            j=j+2;
                                                            p=p+2;
                                                            if(ch[j]==' ')ch[j]=temp2;
                                                        }
                                                    }
                                                }
                                                if(j==26&&ch[j]==' ')
                                                {
                                                    if(ch[j+2]==' ')
                                                    {
                                                        j=j+2;
                                                        p=p+2;
                                                        ch[j]=temp2;
                                                    }
                                                    else
                                                    {
                                                        j=j+14;
                                                        p=p+14;
                                                        if(ch[j]==' ')ch[j]=temp2;
                                                        else
                                                        {
                                                            j=j+2;
                                                            p=p+2;
                                                            if(ch[j]==' ')ch[j]=temp2;
                                                            else
                                                            {
                                                                j=j+2;
                                                                p=p+2;
                                                                if(ch[j]==' ')ch[j]=temp2;
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                          
                                         else if((j==8||j==24)&&ch[j+4]!=' ')
                                         {
                                             if(ch[j+4]!=' ')
                                             {
                                                ch[j]=' ';
                                                 j=j+16;
                                                 p=p+16;
                                                if(ch[j]==' ')ch[j]='O';
                                                 else
                                                 {
                                                     j=j+2;
                                                     p=p+2;
                                                     if(ch[j]==' ')ch[j]=temp2;
                                                     else
                                                     {
                                                         j=j+2;
                                                         p=p+2;
                                                         if(ch[j]==' ')ch[j]=temp2;
                                                         else
                                                         {
                                                             if(ch[j]!=' '&&j==28)
                                                             {
                                                                 j=j+12;
                                                                 p=p+12;
                                                                  if(ch[j]==' ')ch[j]=temp2;
                                                                  else
                                                                  {
                                                                      j=j+2;
                                                                      p=p+2;
                                                                      if(ch[j]==' ')ch[j]=temp2;
                                                                      else
                                                                      {
                                                                          j=j+2;
                                                                          p=p+2;
                                                                          if(ch[j]==' ')ch[j]=temp2;
                                                                      }
                                                                  }
                                                             }
                                                         }
                                                     }
                                                 }
                                            }
                                            }
                                               
                                         else
                                        {
                                           ch[j]=ch[j+4];
                                           ch[j+4]=temp2;
                                           j=j+4;
                                           p=p+4;
                                        }
                                        
                                    }
                                        else
                                        {
                                            ch[j]=ch[j+2];
                                            ch[j+2]=temp2;
                                            j=j+2;
                                            p=p+2;
                                        }
                                    System.out.print("\f");
                                    System.out.print(ch);
                                }
                           }
                           
                           else if(n2==6&&p==44)
                           {
                               System.out.print("\f");
                               System.out.print(ch);
                               break;
                            }
                           else if(n2==5)
                           {
                               System.out.println(i);
                               System.out.print("\f");
                               a=1;
                               m=8;
                               b=0;
                               p=8;
                               flag=1;
                               fill++;
                               if(check(ch,i)=='X'||check(ch,i)=='O')fill=10;
                               break;
                           }
                            else
                            {
                                System.out.print("\f");
                                System.out.print(ch);
                                }
                        }
                    }
                }
                else
                { 
                    System.out.print("\f");
                    System.out.print(ch);
                }
            }
     }  
        char smiley=9786;
        System.out.print("\f");
        System.out.print(ch);
        System.out.println("\t\t");
        if(check(ch,i)==('X'))
        System.out.println(s1+"(X) is the WINNER Of this GAME !!");
        else if(check(ch,i)==('O'))
        System.out.println(s2+"(O) is the WINNER Of this GAME !!");
        else
        System.out.println("THIS GAME IS A TIE ...Better LUCK next TIme :)  !!");
        System.out.println("\nTHANK YOU GUYS FOR PLAYING THIS GAME !! HOPE YOU LIKED IT  "+smiley);
    }
  }
/**It took me nearly 1 week to get this game into running coz i did this during my school working days 
 * where in i wasn't that free to sit in front of bluej and get this stuff done...This work consisted 
 * of many errors,glitches,bugs and other sorts of things which made me dig more into it to see how 
 * things can be done in different ways....
 * Externally this game is a piece of cake and can be done in simple words using differnt methods 
 * which were not taught in our school but to be franc one who does it knew exactly the internal pain
 * it made me feel happy and such kind of feeling is inexpressible :-) 
 * I just hope to come up with such works in future which can make my parents feel proud :))
 */
asked by MP Harsha (student58) 8 years ago
12
Random not-a-question passing through.....
asked by Yolomama69 (yolomama69) 8 years ago
1

+ 1 more questions by yolomama69  

pls answer this.
FRENCH.- replace captalized words with pronoms convenables.
Q: Je n'ai pas apercu MES AMIS au concert
can the answer be
A: je n' ai apercu eux au concert.

reponde rapidment s'il vous plait.
asked by Mahira Khan (secretgirl1234) 8 years ago
3
this keyword...only definition is enough right?
we never used it in programs...should we??
asked by Bhavana (mpc123) 8 years ago
2
can someone suggest how to study computers... need to start syallabus.
asked by Shmeguul Gwzwan Daimari (shmeguul) 8 years ago
0
fill in with relative pronouns
je connais un acteur ______ qui peut jouer ce role.
asked by Akhila (amazingaligators123) 8 years ago
4
Can someone upload all important comp Theory notes for me since I lose marks only in theory
asked by Chelsea Dcosta (che777) 8 years ago
1
ALL THE BEST EVERYONE APPEARING FOR THEIR LANGUAGE EXAMS.....GIVE UR BEST..:):)
asked by Diya Parmar (diyaparmar809) 8 years ago
2
anyone telugu here?
asked by Guy (devrath) 8 years ago
1
guys ...can anyone tell which essay can come .....chennai floods or paris attacks...
for french....
asked by rohit_k 8 years ago
1

<< Prev

    Page 414    

Next Page >>


© 2010 - 2024 ResPaper. Terms of ServiceContact Us Advertise with us