Click here to Skip to main content
15,887,350 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
import java.util.*;
class Game
{
Scanner sc = new Scanner(System.in);
int[] ar = new int[3];
int[] guess = new int[3];
int location()
{
for(int i=0;i<3;i++)
{
ar[i] = sc.nextInt() ;
}
}
int userGuess()
{
for(int j=0;j<3;j++)
{
guess[j] = sc.nextInt() ;
}
}
int Comparison()
{
for(int k=0;k<3;k++)
{
if(ar[k] == guess[k] )
{
System.out.println("hit");
}
else
{
System.out.println("miss");
}
}
}
public static void main(String... ar)
{
Game g = new Game();
g.location();
g.userGuess();
g.Comparison();
}
}
Posted
Updated 23-Mar-12 3:03am
v2

1 solution

What a mess.

please use an IDE like Eclipse or Netbeans to write your code. Both are free
and there is no excuse for not using them.

You will find out that most of what you posted here is not even working.
That code can never run like this. Nearly all functions are missing a return value and the main doesn't even have a proper argument. This code can not be compiled.

And please format your code:
- Intents and empty lines are helping to keep the code in a proper format.
- Variables are allowed to have a real meaning telling name. ar, i,j,k,g does not say something. But when you use oArray, iCount, jCount, kCount and oGame you'll directly know what that variable stands for. That makes it much easier to write and understand the code.
 
Share this answer
 
Comments
nikhil_kumar 2-Apr-12 16:50pm    
k try to follow ur instruction.........thnx........

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900