1 /**
  2 * Hand is a class for holding an array of cards that represents a users hand
  3 * It contains adder, getter, remover methods for the private array which represents the cards
  4 */
  5 function Hand() {
  6 	
  7 	//PRIVATE INSTANCE VARIABLES
  8 	
  9 	/**
 10 	* cards is represented as an array of cards
 11 	*/
 12 	var myCards = new Array();
 13 	
 14 	
 15 	//PUBLIC FUNCTIONS
 16 	
 17 	/**
 18 	* adder method for single cards
 19 	* param Card card is the card to add
 20 	* return int currentLength, the current number of cards in the hand
 21 	*/
 22 	this.addCard = function (card) {
 23 		return myCards.push(card);
 24 	};
 25 	
 26 	/**
 27 	* adder method for an array of cards
 28 	* parm Card[] cards is an array of cards to add
 29 	* returns the current contents of the hand as an array
 30 	*/
 31 	this.addCards = function (cards) {
 32 		return myCards = myCards.concat(cards);
 33 	};
 34 	
 35 	/**
 36 	* getter method for the cards
 37 	* returns the current contents of the hand as an array
 38 	*/
 39 	this.getCards = function () {
 40 		return cards;
 41 	};
 42 	
 43 	/**
 44 	* remover method for the cards
 45 	* param Card card is the card to remove
 46 	* returns the removed card or null if the card was not found
 47 	*/
 48 	this.removeCard = function (card) {
 49 		for(var i=0; i < myCards.length; i++) {
 50 			if(myCards[i] == card) {
 51 				return myCards.splice(i,1)[0];
 52 			}
 53 		}
 54 		return null;
 55 	};
 56 }