Cards deck problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Arun Nair

    #1

    Cards deck problem

    Can any one help me with this im not getting it even after reading
    books because there is not much of discussion anywhere

    a>
    Implement a calss that represents a playing card. The class should
    implement the following methods:
    _ _ init _ _ (self, rank, suit) Creates a card.
    rank is an integer in range of 1 to 13 (Ace:1, King 13), suit is a
    character in set {'h','d','c','s '}
    getRank(self) Returns the rank of the card
    getSuit(self) Returns the suit of the card
    BJValue(self) Returns the 'Blackjack Value' of the card (Ace:1, Face
    card:10)
    _ _ str _ _ (self) Returns a string naming the card. For example: 'Ace
    of Spades'

    Test your class by writing a 'test harness' that generates 'n' randomly
    generated cards, where 'n' is supplied by the user. Print out the
    string associated with each card and it's 'Blackjack value'


    b>
    Extend the card class to display in a graphics window. the new class
    should support the following method: draw(self, win, center) Draws a
    card in a window.
    Use the extended class to display a hand of five random cards.


    cWrite a program that creates a list of card objects as above and
    print out the cards grouped by suit and in rank order in each suit.
    the program should read the values for the list of cards from a file,
    where each line in the file specifies a single card with the rank and
    then the suit separated by a space. Hint: sort the list first by rank,
    and then by suit.


    dCreate a new class deck that represents a pack of 52 cards. Which
    supports the following methods:

    _ _init_ _ (self) - Creates a deck of cards in standard order.
    shuffle(self) - Randomizes the order of the cards
    dealCard(self) - Returns a single card from the top of the deck, and
    removes the card from the deck.
    cardsLeft(self) - Returns the number of cards left in the deck.
    Test your class by having it deal out a sequence of 'n' cards where 'n'
    is a number input by the user. The program should either print out the
    cards, or display them in a window.

    Your urgent and quick reply help will be appreciated the most.

    Arun Nair

  • Paul Rubin

    #2
    Re: Cards deck problem

    "Arun Nair" <nairarunv@gmai l.comwrites:
    Your urgent and quick reply help will be appreciated the most.
    Do you have a specific question? What are you having trouble with?

    Comment

    • Ben Finney

      #3
      Re: Cards deck problem

      "Arun Nair" <nairarunv@gmai l.comwrites:
      Can any one help me with this im not getting it even after reading
      books because there is not much of discussion anywhere
      Perhaps the discussion should be between yourself and your teacher, or
      the other students in your class. We're not here to do your homework
      assignments.

      --
      \ "It is seldom that liberty of any kind is lost all at once." |
      `\ -- David Hume |
      _o__) |
      Ben Finney

      Comment

      • Arun Nair

        #4
        Re: Cards deck problem

        Hey paul i dont know how to implement this stuff if you have any ebook
        or any notes which can halp me then i would like to try it and
        implement my and refer back to you for any errors comming out of it

        Regards,

        Arun

        On Oct 26, 7:39 pm, Paul Rubin <http://phr...@NOSPAM.i nvalidwrote:
        "Arun Nair" <nairar...@gmai l.comwrites:
        Your urgent and quick reply help will be appreciated the most.Do you have a specific question? What are you having trouble with?

        Comment

        • Arun Nair

          #5
          Re: Cards deck problem

          Im so sorry about that but the lecturer doesnt teaches anything so its
          become very difficult for me to do it if you guys have any notes on
          classes it will be very helpfull. and i can try on my own.

          regards,

          Arun

          On Oct 26, 7:47 pm, Ben Finney <bignose+hate s-s...@benfinney. id.au>
          wrote:
          "Arun Nair" <nairar...@gmai l.comwrites:
          Can any one help me with this im not getting it even after reading
          books because there is not much of discussion anywherePerhaps the discussion should be between yourself and your teacher, or
          the other students in your class. We're not here to do your homework
          assignments.
          >
          --
          \ "It is seldom that liberty of any kind is lost all at once." |
          `\ -- David Hume |
          _o__) |
          Ben Finney

          Comment

          • Fredrik Lundh

            #6
            Re: Cards deck problem

            Arun Nair wrote:
            Hey paul i dont know how to implement this stuff if you have any ebook
            or any notes which can halp me then i would like to try it and
            implement my and refer back to you for any errors comming out of it


            </F>



            Comment

            • Michael Naunton

              #7
              Re: Cards deck problem

              On 26 Oct 2006 02:27:16 -0700, Arun Nair <nairarunv@gmai l.comwrote:

              It is clear your professor does not understand computer science. Switch
              to a new university now.

              As noted in the problem, a deck has 52 cards. cardsLeft(self) therefore
              always returns 52.

              This may seem pendantic, but CS is mostly about thinking about (and thus
              naming) things clearly. Find someone who does.

              -- Michael
              dCreate a new class deck that represents a pack of 52 cards. Which
              supports the following methods:
              >
              _ _init_ _ (self) - Creates a deck of cards in standard order.
              shuffle(self) - Randomizes the order of the cards
              dealCard(self) - Returns a single card from the top of the deck, and
              removes the card from the deck.
              cardsLeft(self) - Returns the number of cards left in the deck.
              Test your class by having it deal out a sequence of 'n' cards where 'n'
              is a number input by the user. The program should either print out the
              cards, or display them in a window.
              >

              Comment

              • mensanator@aol.com

                #8
                Re: Cards deck problem


                Dennis Lee Bieber wrote:
                On Fri, 27 Oct 2006 03:48:25 GMT, Michael Naunton
                <mmn@news.bella tlantic.netdecl aimed the following in comp.lang.pytho n:
                >

                This may seem pendantic, but CS is mostly about thinking about (and thus
                >
                <snickerSomed ay I should arrange to do a lost-wax casting of a
                /pendant/ with the definition of /pedant/ on it <G>
                Why not a /pedant/ with a description of /pendant/ on it?

                Comment

                • Cameron Walsh

                  #9
                  Re: Cards deck problem

                  mensanator@aol. com wrote:
                  Dennis Lee Bieber wrote:
                  >On Fri, 27 Oct 2006 03:48:25 GMT, Michael Naunton
                  ><mmn@news.bell atlantic.netdec laimed the following in comp.lang.pytho n:
                  >>
                  >>This may seem pendantic, but CS is mostly about thinking about (and thus
                  > <snickerSomed ay I should arrange to do a lost-wax casting of a
                  >/pendant/ with the definition of /pedant/ on it <G>
                  >
                  Why not a /pedant/ with a description of /pendant/ on it?
                  >>
                  As fun as it would be, I haven't found too many /pedants/ who want to
                  have the definition of /pendant/ written on them.

                  You've just given me an idea for an online T-Shirt printing business.
                  Thank you, and your royalties will be in the post soon, just provide me
                  with your credit card details.

                  Comment

                  • Gabriel Genellina

                    #10
                    Re: Cards deck problem

                    At Friday 27/10/2006 00:48, Michael Naunton wrote:
                    >It is clear your professor does not understand computer science. Switch
                    >to a new university now.
                    >
                    >As noted in the problem, a deck has 52 cards. cardsLeft(self) therefore
                    >always returns 52.
                    >
                    >This may seem pendantic, but CS is mostly about thinking about (and thus
                    >naming) things clearly. Find someone who does.
                    Uhm, maybe it's a matter of language, but how do you name the pile of
                    cards remaining to be dealt once the game begins?
                    At least in Argentina, it's called the same ("mazo") as the full,
                    original, set of cards.
                    The "remaining cards" interpretation for "deck" would be consistent
                    with the required interfase: shuffle, dealCard, cardsLeft...
                    shuffle(self) - Randomizes the order of the cards
                    dealCard(self) - Returns a single card from the top of the deck, and
                    removes the card from the deck.
                    cardsLeft(self) - Returns the number of cards left in the deck.

                    --
                    Gabriel Genellina
                    Softlab SRL

                    _______________ _______________ _______________ _____
                    Correo Yahoo!
                    Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
                    ¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar

                    Comment

                    • Ben Finney

                      #11
                      Re: Cards deck problem

                      Gabriel Genellina <gagsl-py@yahoo.com.ar writes:
                      At Friday 27/10/2006 00:48, Michael Naunton wrote:
                      >
                      As noted in the problem, a deck has 52 cards. cardsLeft(self)
                      therefore always returns 52.
                      >
                      Uhm, maybe it's a matter of language, but how do you name the pile of
                      cards remaining to be dealt once the game begins?
                      In English? I'd call that a deck. However, that deck doesn't contain
                      52 cards any more, so a thing that behaves that way doesn't fit the
                      definition of "deck" in the problem.

                      Perhaps a better definition would have used language like "... begins
                      with 52 cards" or the like, and described the properties of a deck to
                      be modelled.

                      Is this merely pedantic? If we were describing the rules of a game to
                      be played by humans, yes. But in this case we're describing parameters
                      of a problem to be modelled in a computer, hopefully independently by
                      each student in a class. Getting the problem defined precisely is
                      essential, otherwise judging the result fairly is impossible.

                      (good sigmonster, have a cookie)

                      --
                      \ "We demand rigidly defined areas of doubt and uncertainty!" -- |
                      `\ Vroomfondel, _The Hitch-Hiker's Guide To The Galaxy_, Douglas |
                      _o__) Adams |
                      Ben Finney

                      Comment

                      Working...