diff --git a/cpp/include/shuffling.h b/cpp/include/shuffling.h index 0405bbb..ce314e0 100644 --- a/cpp/include/shuffling.h +++ b/cpp/include/shuffling.h @@ -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 diff --git a/cpp/src/shuffle.cpp b/cpp/src/shuffle.cpp index c51c17f..7302739 100644 --- a/cpp/src/shuffle.cpp +++ b/cpp/src/shuffle.cpp @@ -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!"<start(); diff --git a/cpp/src/shuffling.cpp b/cpp/src/shuffling.cpp index 3d496f4..86e9d40 100644 --- a/cpp/src/shuffling.cpp +++ b/cpp/src/shuffling.cpp @@ -19,6 +19,7 @@ Deck::Deck(){ bottom_card = NULL; } +// adding card on the top of the deck void Deck::addCardOnTop(Card* card){ size++; @@ -33,6 +34,7 @@ void Deck::addCardOnTop(Card* card){ } } +// removing top card of the deck Card* Deck::removeTopCard(){ Card *card = top_card; @@ -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 @@ -79,7 +81,7 @@ void Deck::putBottom(){ /* -------------------------------- Shuffling class ----------------------------------------- */ - +// initialization of Shuffling object Shuffling::Shuffling(int numberOfCards){ nCards = numberOfCards; @@ -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 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; }