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 8029059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:19:30+00:00 2026-06-05T00:19:30+00:00

I have this assignment based on coin and card games which is very simplified.

  • 0

I have this assignment based on coin and card games which is very simplified. We are given some complete and some incomplete files. What I am trying to do is invoke a method (which is really a string) from one class (card.cs) in another (hand.cs).

Here is the string method from card.cs:

public string ToString(bool shortFormat, bool displaySuit)
    {
        string returnString;

        // Describe the FaceValue.
        FaceValue faceValue = GetFaceValue();
        string faceValueAsString = faceValue.ToString();
        if (shortFormat) {
            if (faceValue <= FaceValue.Ten) {
                faceValueAsString = (faceValue - FaceValue.Two + 2).ToString();
            } else {
                faceValueAsString = faceValueAsString.Substring(0, 1);
            }
        }

        returnString = faceValueAsString;

        // Describe the Suit.
        if (displaySuit) {
            string suit = GetSuit().ToString();
            if (shortFormat) {
                suit = suit.Substring(0, 1);
                returnString += suit;
            } else {
                returnString += " of " + suit;
            }
        }

        return returnString;
    }

and from hand.cs (the ToString string/method only, there are other functions in this file that deal with creating a hand (list named cards) and adding cards to it.)

/// <summary>
    /// Outputs the hand of cards.
    /// See the ToString method in the Card class for a description of 
    /// the two parameters: shortFormat and displaySuit.
    /// Pre: true
    /// Post: Displayed the hand of cards.
    /// </summary>
    public void DisplayHand(bool shortFormat, bool displaySuit) {

        //
        //**************** CODE NEEDS TO BE ADDED**********************
        // Should be able to call the ToString method in the Card class,
        // as part of this.
        //

    } // end DisplayHand

They are the unedited files I got for the assignment. What I want to know is how to use the TwoString(shortFormat, displaySuit) in DisplayHand(shortFormat, displaySuit). At one stage I had a separate list to put the string values in, but it since got deleted trying to revert the files back to the original. I am not quite sure how this is going to be used later in the game, but I figured if I could get it functioning with a list, then changing the list to a string or an array or whatever could be done quite easily later. Once I know how to call this string I should be able to modify the code for all the other strings and integers I have to call.

  • 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-05T00:19:33+00:00Added an answer on June 5, 2026 at 12:19 am

    You need a Card to call ToString on. I assume you would do it something like this:

    foreach (Card card in this.Cards) { ... } // Loop through cards in this hand.
    

    I can’t tell you exactly how without seing the code.

    Once you have a Card (in the card variable), call ToString like this:

    string str = card.ToString(true, true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is uni assignment and I have already done some stuff. Please go to
OK, I have this assignment and I have to prompt the user for data
so we're doing this assignment at Uni and i have a serious craving to
Can I optimize the class assignment here at all? I have to do this
(this is indirectly a part of a much larger homework assignment) I have something
I have a homework assignment to sort an array in ascending order. Obviously, this
having some issues with a networking assignment. End goal is to have a C
We have just started our new assignment - web-based project. Before I get directly
I have an assignment in college in which we are required to read in
Based on the answers from this question , I have created a grid from

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.