Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8733697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:42:16+00:00 2026-06-13T09:42:16+00:00

My Professor Assigned us this homework, however I cant make sense on how to

  • 0

My Professor Assigned us this homework, however I cant make sense on how to do the first step.
I am not asking anybody to do the homework, just please someone help me with the first question

  1. Create a Deck dynamically

This question is based on two files (which he provieded)

“card.h”

//*********************************************************
//  CLASS DECLARATION
//*********************************************************
class Card
{   
    //*****************************************************
    //  Public Members         
    //*****************************************************
   public: 
    // Exception classes
    class NotInitalized {};

    // Enumeration for Suit
    enum Suit { Clubs, Diamonds, Hearts, Spades, 
               UNKNOWN };

    // Enumeration for Card Name
       enum CardName { Ace, Two, Three, Four, Five, Six,
                    Seven, Eight, Nine, Ten, Jack, 
                    Queen, King, UNKNOWN };

    // constructors
//*****************************************************
// Card
//  
// Create uninitialized card.  Must be initialized with 
//  'setCard()' before use.
//*****************************************************
    Card();    // card is not initialized
//*****************************************************
// Card
//  
// Create a card based its ordinal position.
//     cards are ordered by suit first in the order 
//     Clubs, Diamonds, Hearts and Spades, and within 
//     the suit they are ordered Act thru King.
//******************************************************
    Card(int); // number between 1-52

//******************************************************
// Card
//  
// Create a card with the given name and suit.
//*******************************************************
       Card(Suit, CardName);

    // methods
    //*******************************************************
    // setCard
    //  
    //  Set the Suit and Name of the card
    //*******************************************************
        void setCard(Suit, CardName);

    //*******************************************************
    // getSuit
    //  
    //  returns the element of the Suit enumeration 
    // representing the suit of the card
    //*******************************************************
    int      getSuit();

    //*******************************************************
    // getCardName
    //  
    //  returns the element of the CardName enumeration 
    //  representing the card
    //*******************************************************
    int    getCardName();

    //*******************************************************
    // getCardValue
    //  
    //  returns face value of card.  For Ace -1 is the value.
    //*******************************************************
    int         getCardValue();

     //*****************************************************
     // toString
     // 
     // return the string representation of the card. 
     //    e.g.,"Ace of Spades"
     //*****************************************************
       string      toString();

//************************************************
//  Private Members    
//************************************************
private:
    // the Card’s suit (uses Suit enum)
    Suit      suit = Suit::UNKNOWN; 

    // the Card’s name (uses CardName enum)
    CardName  name = CardName::UNKNOWN; 
};

The second class is the Deck class. This class represents the 52 cards in a standard poker deck. Internally the cards in the deck should be maintained in an array of Card objects. There should also be a parallel array of Card pointers where the order of the cards after each shuffle can be stored.

When a Deck object is created it creates the 52 cards and shuffles them. If the deck runs out of cards before it is reshuffled the dealCard() method should throw a DeckEmpty Exception.

Because this class creates card objects, it should have a destructor that deletes all the related card objects when the Deck is deleted.

Below is the class declaration for the Deck class.

//*********************************************************
//  CLASS DECLARATION
//*********************************************************
#include “Card.h”
class Deck
{
//*****************************************************
// Public Members         
//*****************************************************
public: 
    // Exception classes
    class DeckEmpty {};

    // Constructors/Destructors
    Deck(); // creates the cards and sorts them
   ~Deck(); // frees all the cards

    // Methods
    //****************************************************
    // dealCard
    //
    // return the next available card in the shuffled deck
    //****************************************************
    Card      dealCard();

    //****************************************************
    // shuffle
    //
    // shuffle the cards
    //****************************************************
    Void      shuffle();      // shuffle the deck


    //****************************************************
    // getCardCount
    //
    // return the number of unused cards in the shuffled 
    //     deck
    //****************************************************
       int       getCardCount(); // how many cards left

    //****************************************************
    // toString
    //
    // return a newline (\n) delimited list of the shuffled 
    //    cards 
    //*****************************************************
    string    toString();

//*****************************************************
// Private Members    
//*****************************************************
private:
    // array to hold unshuffled cards
       Card      cards[DECK_SIZE];

    // array to hold shuffled cards
    Card*     shuffledCards[DECK_SIZE];

    // index of next card to deal from shuffled cards
       int       nextCardIndex;    
};
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T09:42:17+00:00Added an answer on June 13, 2026 at 9:42 am

    It really makes no sense to me either. Particularly the bit about parallel array of shuffled cards is unclear. And the statement that it needs a destructor because it creates Card objects is just incorrect. Perhaps he means that it creates Card objects dynamically, but firstly that not what he said, and secondly I don’t see the need. I think you should have a talk with your professor.

    However the first step is very easy.

    ‘1. Create a Deck dynamically’

    Deck *my_deck = new Deck;
    

    Solved.

    Why you have to create a deck dynamically is another question, but that’s what he asked you do to.

    I’m not at all sure your professor knows what he’s talking about.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So to make a long story short. A professor asked this question in class
This is correct code from a classmate the professor bragged about and I cant
I'm a college student and this is a homework my algorithm analysis professor passed
Is my professor asking me to draw the stack? Does he want me to
I'm working on a homework assignment to modify code given by my professor using
My professor gave an example located on slide 3 of this pdf : can
Today in the class of Java the professor came up with this example but
My professor assigned my class with implementing mergesort in arrays with 3-part partitioning and
We were just assigned a new project in my data structures class -- Generating
My professor send out test code to run on our program. However, the test

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.