alright..
i print now the output that i wanted..
i have a question again..
i want to hide the values of the cards in my output.
here is my modified code:
import java.io.*;
public class Num2
{
public static void main(String[]args)throws IOException
{
BufferedReader a=new BufferedReader(new InputStreamReader(System.in));
int r1, c1, r2, c2;
int[][]cards;
cards=new int[4][4];
for(int r=0; r<4; r++)
{
for(int c=0; c<4; c++)
{
cards[r][c]=(int) (Math.random() * 8);
System.out.print(cards[r][c]);
}
System.out.print("\n");
}
for (int r=0; r<4; r++)
{
for (int c=0; c<4; c++)
{
System.out.print("*");
}
System.out.print("\n");
}
System.out.print("\nPlease insert the first card row: ");
r1=Integer.parseInt(a.readLine());
System.out.print("\nPlease insert the first card column: ");
c1=Integer.parseInt(a.readLine());
System.out.print("\nPlease insert the second card row: ");
r2=Integer.parseInt(a.readLine());
System.out.print("\nPlease insert the first card column: ");
c2=Integer.parseInt(a.readLine());
//reveal
for(int r=0; r<4; r++)
{
for (int c=0; c<4; c++)
{
if((r==r1)&&(c==c1))
{
System.out.print(cards[r][c]);
}
else if((r==r2)&&(c==c2))
{
System.out.print(cards[r][c]);
}
else
{
System.out.print("*");
}
}
//match?
if (cards[r1][c1]==cards[r2][c2])
{
}
else
{
System.out.println();
}
}
}
}
the output is:
5264
7021
1741
1556
****
****
****
****
Please insert the first card row: 1
Please insert the first card column: 2
Please insert the second card row: 3
Please insert the second card column: 3
****
**2*
****
***6
the values in my output are printed also..
before the 4x4 *;
what should i modify?
Last edited by beginner21; Dec 1st, 2008 at 1:19 am. Reason: code tags