Coding: More About Objects And Classes

Hey so you heard about the card game I am working on. NO!!!!!!!!! okay here is a link to learn more about my card game.

I made a card class to make cards for my game.

var Card =function(number,suite) {
  this.number=number
  this.suite=suite
}

I also made a deck class to get the right cards and make a deck from those cards

var Deck = function(deckProperties) {
  this.cards=[]
  for(var suite in deckProperties) {
    var start=deckProperties[suite][0]
    var end=deckProperties[suite][1]
    while (start<end+1) {
      var card=new Card(start,suite)
      this.cards.push(card)
      start++
    }
  }
  
}

I am using deckProperties to get all the cards I need for the game and I use the card class to make the cards. Next, I pushed all the cards that I made into a list.

I made an object to get the right cards for my game

var dP={}
dP.H=[7,14]
dP.D=[8,14]
dP.C=[8,14]
dP.S=[7,14]


Create a new deck

var deck=new Deck(dP)

You can get the cards by writing  deck.cards

 

%d bloggers like this: