
/*
Online Java - IDE, Code Editor, Compiler

Online Java is a quick and easy tool that helps you to build, compile, test your programs online.
*/

import java.util.*;

public class Main
{
    public static void main(String[] args) {
        System.out.println("Welcome to Online IDE!! Happy Coding :)");
        
        int numberPairs=0;
        
        System.out.println("*** WELCOME TO MEMORY GAME *** - Please select size of matrix:");
        
        
        Scanner scanner = new Scanner (System.in);
        System.out.println("Enter width:");
        int length = scanner.nextInt();
        
        System.out.println("Enter length:");
        int width =  scanner.nextInt();
        numberPairs = (length * width)/2;
        
        int [] test = new int []{1,2,3};
        
        ArrayList <Object[]> board = new ArrayList<>();
        
        
        playMemoryGame mg = new playMemoryGame(numberPairs, board, width, length);
        
    }
}

interface memoryGame
{
    void flipCard();
    void pairFound();
    void noPair();
    void timeLeft();   // not sure how this will be implemented
    
}

class playMemoryGame implements memoryGame
{
     
     // currently enum is not used.. was contemplated adding value of the enum into the set
     // however not sure if it serves any real value.....
     
     enum cards
{
    
    ZERO(0), ONE(1), TWO(2), THREE(3), FOUR(4), FIVE(5), SIX(6), SEVEN(7), EIGHT(8), NINE(9), TEN(10);
    
    final int value;
    
    cards (int value)
    {
        this.value=value;
    }
}
    
    
    public playMemoryGame(int numberPairs, ArrayList<Object[]> board, int width, int length)
    {
        int count=0;
        int number;
        int i=0;
        Object [] fillBoard = new Object [2];
        
        // it will do this process twice and then randomnly put the numbers in a position in the ArrayList
        
        Set<Integer> generatedNumbers = new HashSet<Integer>();
        
        do
        {
        count++;   // this is just test limit for now
        Random rnd = new Random();
        
        number=rnd.nextInt((numberPairs-1)+1);
        
        System.out.println("Following number will be added into memory games:" + number );
        System.out.println("This should process all numbers 0 to 10");
        
        generatedNumbers.add(number);
        
        
        }
        while (generatedNumbers.size()<=numberPairs);   
        
        Iterator it = generatedNumbers.iterator();
        
        System.out.println("All numbers should be present");
        while (it.hasNext())
        {
            
            // it has to preserve each row of random numbers and then add them onto arrayList 
            fillBoard[i] = it.next();
            i++;
            System.out.println(fillBoard[i]);
            
            if (i==width-1)  // this forces a newline of width
            {
                i=0;
            }
            board.add(fillBoard);
            
            
        }
        
        //Might be best to add generated numbers into a set to ensure same number is not stored twice.
        //Then it can be randomnly placed into the arrayList
        
        
        
        // need to check if all enum values can be accessed
        
        
        
        
        //this has to support even number of enum items
        ArrayList<Integer> matrix = new ArrayList<Integer>();
        
        cards c = cards.ONE;
        
    }
    
    public void timeLeft()
    {
    }
    
    public void noPair()
    {
    }
    
    public void pairFound()
    {
    }
    
    public void flipCard()
    {
    }
}
