Skip to content

Commit

Permalink
Adding comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Levan Loria committed Sep 23, 2017
1 parent 8df61f1 commit 83952ed
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions cpp/include/shuffling.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ typedef struct Card Card;

struct Deck{
int size; // size of deck
Card *top_card; // card on the top of the deck
Card *bottom_card; // card on the bottom of the deck
Card* top_card; // card on the top of the deck
Card* bottom_card; // card on the bottom of the deck
Deck();
void addCardOnTop(Card*); // adding card on the top of the deck
Card* removeTopCard(); // removing card from top of the deck
Expand Down
2 changes: 2 additions & 0 deletions cpp/src/shuffle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ int main(int argc, const char **argv)

int numberOfCards;

/*-------------------------- checking command line arguments -------------------------*/
if(argc != 2){
cout<<"Program takes one integer argument!"<<endl;
exit(1);
Expand All @@ -31,6 +32,7 @@ int main(int argc, const char **argv)
}


/*-------------------------- shuffling cards -------------------------*/
Shuffling *shuffling = new Shuffling(numberOfCards);

shuffling->start();
Expand Down
7 changes: 5 additions & 2 deletions cpp/src/shuffling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Deck::Deck(){
bottom_card = NULL;
}

// adding card on the top of the deck
void Deck::addCardOnTop(Card* card){
size++;

Expand All @@ -33,6 +34,7 @@ void Deck::addCardOnTop(Card* card){
}
}

// removing top card of the deck
Card* Deck::removeTopCard(){

Card *card = top_card;
Expand All @@ -57,7 +59,7 @@ Card* Deck::removeTopCard(){
return card; //returns old top card
}


// putting top card on the bottom
void Deck::putBottom(){

// new bottom card
Expand All @@ -79,7 +81,7 @@ void Deck::putBottom(){

/* -------------------------------- Shuffling class ----------------------------------------- */


// initialization of Shuffling object
Shuffling::Shuffling(int numberOfCards){

nCards = numberOfCards;
Expand All @@ -89,6 +91,7 @@ Shuffling::Shuffling(int numberOfCards){
tableDeck = new Deck();

cards = new Card[numberOfCards];
// Initialization of cards with values [1 -- numberOfCards]
for(int i=0;i<numberOfCards;i++){
cards[i].value = (i+1);
cards[i].next = NULL;
Expand Down
4 changes: 2 additions & 2 deletions js/lib/shuffling.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ function Deck(){
// adding card on the top of the deck
Deck.prototype.add = function(card){

if(this._length){
if(this._length){ // length > 0 adding on the top
this.top_card.next = card;
card.previous = this.top_card;
this.top_card = card;
}else{
}else{ // length = 0
this.top_card = card;
this.bottom_card = card;
}
Expand Down

0 comments on commit 83952ed

Please sign in to comment.