Any help would be greatful.
import java.util.Scanner;
public class Memory
{
int[][] initialValue = {{1, 2, 3, 4}, {5, 6 ,7 , 8},{1, 2, 3, 4}, {5, 6 ,7 , 8}};
boolean[][] displayed = new boolean[4][4];
Scanner scan;
Memory()
{
boolean gameIsOver = false;
scan = new Scanner(System.in);
while(!gameIsOver)
{
System.out.println("X represents the row which is downwards. Y represents the columns which is across. Example the" +
" coordinates for the top left is X = 0, Y = 0");
System.out.println();
displayCard();
System.out.print("Enter coordinates X to show: ");
int x = scan.nextInt();
System.out.print("Enter coordinates Y to show: ");
int y = scan.nextInt();
displayed[x][y] = true;
System.out.println();
}
}
void displayCard()
{
Random randomCards = new Random();
System.out.println("The Cards:");
for(int j = 0; j < 4; j++)
{
for(int i = 0; i < 4; i++)
{
if(displayed[i][j])
System.out.print(" " + initialValue[i][j] + " ");
else
System.out.print(" * ");
}
System.out.println();
}
}
public static void main(String[]args)
{
new Memory();
}
}

New Topic/Question
Reply



MultiQuote



|