//////////////////////////////////////////////////////////////

//Purpose: This class will setup the Arrays neccessary for

// cards to be displayed on the screen. These cards

// have no functionality, and just being able to see

// the cards will complete this lab

//

//Grade: 100/100

//////////////////////////////////////////////////////////////

class CardArraySetup

{

///////////////////////////////////////////////////////////////////////

//Singleton setup so that this class can be used throughout the

//project

private static var instance : CardArraySetup = new CardArraySetup();

public static function GetInstance() : CardArraySetup

{

return instance;

}

///////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////

//NOTE: You will be using the variables here for rows and column when

// you are creating the multi-dimensional array later in this lab

private var rows : int = GameScript.rows;

private var cols : int = GameScript.cols;

/////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////

//**** TODO **** (20 points)

//You are going to have to create 3 different types of arrays

//////////////////////////////////////////////////////////////////////////////////////

//Code Explanation:

//The first two are going to be Javascript arrays, while the last one

//will be an ArrayList.

//One of the Javascript arrays will be used for storing the total number of cards

//available in this game

//The second array will be used to form the multi-dimensional grid later on in this

//lab.

//The final variable, the ArrayList will be holding only two cards at a time,

//the cards that were actually flipped.

//////////////////////////////////////////////////////////////////////////////////////

//Declare two new Arrays and one new ArrayList here. Make sure you name them appropriate

//to what they will be used for. Make sure they are PRIVATE variable declarations, scope them

//in correctly, and create them as new empty declarations. This means you will need

//to set them equal to new empty Arrays.

//Type your 3 variable declarations right below here:

private var ArrayList = new int [2];

////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////

//Code Explanation

//Accessor function to this class

//In order to be used elsewhere in the code, and to follow with proper object oriented

//principles, we do not want the user to have direct access to the code. So instead, we use

//functions called Accessors to allow for other portions of the code to have access to the

//variables you have created.

//This means that you will be using functions that send your variable to be used elsewhere.

//One way to do this is to return data from a function. Next lab you will be going over functions

//and returns, but with your next todo you need to give access to the variables you created above

//using the return keyword, giving other code found in this project access to the arrays

////////////////////////////////////////////////////////////////////////////////////////////////

//Access to the arrays

function GetCardArray() : Array

{

//****TODO**** (5 points)

//You will need to return the Array that you declared above

//using the return keyword and then the name of the array representing

//the array holding the total number of cards

}

function GetGridArray() : Array

{

//****TODO**** (5 points)

//You will need to return the Array you declared above

//using the return keyword and then the name of the Array representing

//the multi-dimensional grid that will be created later

}

function GetCardsFlippedArray() : ArrayList

{

//****TODO**** (5 points)

//You will need to return the arraylist that you declared above

//using the return keyword and the name of the ArrayList representing

//the two cards that have been flipped over

}

function ResetCardsFlipped()

{

//****TODO**** (5 points)

//You are going to need to reset your arraylist that you declared above.

//In order to reset the arraylist, if you set the variable to a new ArrayList

//again, without needing to re-declare it, it will erase whatever data is found

//inside of the ArrayList. Remember, do not give it a type, or precede it with a

//var keyword for this part.

}

/////////////////////////////////////////////////////////////////////////////////////

//Code Explanation:

//This function is going to setup the grid array you created earlier to be

//multi-dimensional and will be using two for loops to create both rows and

//columns for the grid

//TIP: This is VERY similar to the lecture notes found for Arrays, and using those

//will be helpful in completing this lab!

function GridSetup()

{

//****TODO**** (20 points)

//Create a multi-dimensional array here to hold the cards for the grid. It should loop

//through the rows and columns sizes given to you at the top of the file. Use the array designated

//for the grid you declared above.

//HINT: Check the lecture notes to see a similar example of setting up a multi-dimensional

//array

//Now within the second nested for loop you need to perform a few other operations found below:

/////////////////////////////////////////////////////////////////////

//Uncomment this line of code, but replace the > with the array

// name for your total card array you created above.

//Make sure the dot operator (.) remain!!

//This line of code will store a random number into the variable someNum

//////////////////////////////////////////////////////////////////////

//Code Explanation:

//Still within this nested for loop, you need to perform two more

//actions using the random number created above that you

//commented back in. This random number creates an integer between

//0 and the total number of cards in your total card array

//

//****TODO**** (20 points)

//A) The first step is to set the current location of multi-dimensional array equal

//to the random index of your total card array using the someNum variable

//Use the counter created in both of the for loops to access the current location

//****TODO**** (20 points)

//B) The second step requires you to remove the information from your total

//card array at the same random location. The reason

//is so that we can get rid of the card that was set just before so it wont be used

//again.

//HINT: Use the API scripting reference for Unity 3D and search for Arrays to find

//the correct method to perform this action

}

}