/*
 * MyFirst solo Project Spring 2014
 * Matching Card Game
 */

package tests;

import java.awt.Color;
import java.awt.Dimension;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

import model.MatchingGame;

/**
 * test class for a GUI.
 * 
 * @author Brian Dennis
 * @version 3-22 2014
 */
@SuppressWarnings("serial")
public final class TestGUI extends JFrame {
    
    /** size of buttons. */
    private static final Dimension BUTTON_SIZE = new Dimension(50, 75);
    
    /** size of panels behind buttons. */
    private static final Dimension PANEL_SIZE = new Dimension(60, 85);
    
    /** size of JFrame. */
    private static final Dimension FRAME_SIZE = new Dimension(875, 402);
    
    /** length of arrays. */
    private static final int ARRAY_LENGTH = 52;
    
    /** an index to test my remove function. */
    private static final int TEST_INDEX = 26;
    
    /** the default values that will be made into cards. */
    private static final String[] DEFAULT_VALUES 
        = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King", "Ace"};
    
    /** Arraylist to put the card values into. */
    private static List<String> myValues = new ArrayList<String>();
    
    /** start method. */
    public void start() {
        
        for (final String value : DEFAULT_VALUES) {
            
            myValues.add(value);
        }
        
        final JButton[] buttArray = new JButton[ARRAY_LENGTH];
        final JPanel[] panArray = new JPanel[ARRAY_LENGTH];
        
        final JPanel flow = new JPanel();
        flow.setBackground(Color.GREEN);
        
        for (int i = 0; i < buttArray.length; i++) {
            
            buttArray[i] = new JButton();
            buttArray[i].setPreferredSize(BUTTON_SIZE);
            buttArray[i].setText(String.valueOf(i));
            
            panArray[i] = new JPanel();
            panArray[i].setBackground(Color.BLUE);
            panArray[i].setPreferredSize(PANEL_SIZE);
            
            flow.add(panArray[i]);
            panArray[i].add(buttArray[i]);   
        }
        
        panArray[TEST_INDEX].remove(buttArray[TEST_INDEX]); // testing at index 26
        add(flow);
        setSize(new Dimension(FRAME_SIZE));
        setVisible(true);  
    }
    
    /**
     * test method.
     * @param theArgs stuff
     */
    public static void main(final String[] theArgs) {
      
        final TestGUI test = new TestGUI();
        final MatchingGame game = new MatchingGame(myValues);
        System.out.println(game.toString());
        test.start();
    }
}