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

  • SEARCH
  • Home
  • 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 1106035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:43:45+00:00 2026-05-17T01:43:45+00:00

Classes confuse me! For this particular assignment, we are to do the classic ‘Cards

  • 0

Classes confuse me! For this particular assignment, we are to do the classic ‘Cards in a Deck’ program. We are to make two classes, one called ‘Card’ and the other ‘Deck’. Now I’ve gotten a large chunk of this done so far but a concept seems to be escaping me.

When we call a default constructor for the Card class, all 52 cards are to be created so that the Deck class may use these objects and… well create a deck! Now I attended a session with our TA and he stressed the fact that the default constructor is to initialize the values while the Deck class takes these objects and loops through them to use a function that assigns real card values to the Card objects.

My question is this: what is the best approach for creating these objects so that Deck may reference them? My idea right now is to create a fixed array called ‘initialCard[4][13]’. From there, the Deck class will pick a value – say ‘initialCard[0][0]’ and assign it to an Ace of Spades solely from the row and column of the two-dimensional array. However, my TA keep saying ‘create an array of Card objects’. What could he mean by that? I have a slight grasp but I’m just unsure… anyone have any ideas? Thanks!

Maybe this will help; straight from the assignment page:

Your card class should have public getter and setter functions for
both of these variables (getValue, setValue, etc), as well as a
function that will return a c-string representation of the card. (You
can call it toCString if you want.) It should work something as
follows:

void toCString(char cardString[]) INPUT: A character array for storing
the output OUTPUT: NONE This function should return a character string
representing the card object. This string must have the following
form: two characters followed by a third null byte. The first
character represents suit; the second represents value. Suits should
be “S”, “H”, “C”, or “D” for spades, hearts,

clubs, diamonds. The second character represents value: “A” for Ace,
2-9 for numbered cards, “T” for 10, “J” for Jack, “Q” for Queen”, “K”
for King. Some examples: 2 of spades = ‘S2’ 10 of hearts = ‘HT’ Jack
of diamonds = ‘DJ’ Queen of clubs = ‘CQ’ Ace of spades = ‘SA’ etc.

In addition to these, you should have at least a default constructor to initialize the values. You are welcome to create other
constructors (perhaps one that initializes a card from it’s c-string
representation?) but it is not required.

Deck Class: In addition to your card class, you will need to create a
Deck class to encapsulate all of your card objects. In this object you
should have a private member multi-dimensional array (of size SUITS by
VALUES) of your Card objects. When a Deck object is created, you
should have it initialize the multi- dimensional array of Cards. Card
suits are represented by an enumerated type; card values are
represented by an integer from 1 to 13 (1 is an Ace, 2-10 are numbered
values, 11 is the Jack, 12 is the Queen, and 13 is the King).

Your constructor should loop over the multi-dimensional array and
initialize all values so that the complete deck of cards is
represented.

  • 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-05-17T01:43:46+00:00Added an answer on May 17, 2026 at 1:43 am

    There are always a hundred ways to do something. For me, when creating classes and the structure of my program, I always think how things are related to each other.

    In your problem, Cards in a Deck, the relationship is stated. Each Card object belongs to a Deck. I would start by creating the Card class as it has nothing lower than it then the Deck class. It sounds like you have gotten this far.

    I would design the Card class to describe just a card, nothing else. The value and the suit. The Deck class i would have a private variable holding an array of cards. In the Deck classes constructor i would create the 52 cards. If you want to get fancy use a List rather than an array so you can add as many cards as you like. Not all card games use 52 cards in a deck.

    Once the Deck is instantiated all of its methods will have access to the array of cards.

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

Sidebar

Related Questions

I have some classes layed out like this class A { public virtual void
I am a little confused as to the definition of classes as Models or
I am confused as to when to create object instances or Static Helper classes.
Im a little confused over how to use the .NET Trace and Debug classes.
Classes that use other classes (as members, or as arguments to methods) need instances
For classes that have a long list of setters that are used frequently, I
Many classes in Cocoa/Cocoa Touch have the NS prefix. What does it mean?
I have developed some classes with similar behavior, they all implement the same interface.
Mocking sealed classes can be quite a pain. I currently favor an Adapter pattern
When designing LINQ classes using the LINQ to SQL designer I've sometimes needed to

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.