Skip to content

Instantly share code, notes, and snippets.

@mrryanjohnston
Created September 25, 2011 21:29
Show Gist options
  • Save mrryanjohnston/1241178 to your computer and use it in GitHub Desktop.
Save mrryanjohnston/1241178 to your computer and use it in GitHub Desktop.
var Deck = exports.Deck = function(newSize, newUpper, newLower) {
this.size = newSize || 10;
this.cards = [];
this.cardIterator = 0;
this.upperBound = newUpper || 1;
this.lowerBound = newLower || 10;
this._generateCards();
}
Deck.prototype.getSize = function() {
return this.size;
}
Deck.prototype.getUpperBound = function() {
return this.upperBound;
}
Deck.prototype.getLowerBound = function() {
return this.lowerBound;
}
Deck.prototype.getCards = function() {
return this.cards;
}
Deck.prototype.currentCard = function() {
return this.cardIterator;
}
Deck.prototype._generateCards = function() {
for (var x=0; x<this.getSize(); x++) {
var term1 = Math.floor(Math.random() * (this.getUpperBound() - this.getLowerBound() + 1)) + this.getLowerBound();
var term2 = Math.floor(Math.random() * (this.getUpperBound() - this.getLowerBound() + 1)) + this.getLowerBound();
this.cards.push({terms:[term1,term2]});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment