By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,352 Members | 1,645 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,352 IT Pros & Developers. It's quick & easy.

Cards deck problem

P: n/a
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

Oct 26 '06 #1
Share this Question
Share on Google+
10 Replies


P: n/a
"Arun Nair" <na*******@gmail.comwrites:
Your urgent and quick reply help will be appreciated the most.
Do you have a specific question? What are you having trouble with?
Oct 26 '06 #2

P: n/a
"Arun Nair" <na*******@gmail.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

Oct 26 '06 #3

P: n/a
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.invalidwrote:
"Arun Nair" <nairar...@gmail.comwrites:
Your urgent and quick reply help will be appreciated the most.Do you have a specific question? What are you having trouble with?
Oct 26 '06 #4

P: n/a
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+hates-s...@benfinney.id.au>
wrote:
"Arun Nair" <nairar...@gmail.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
Oct 26 '06 #5

P: n/a
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
http://wiki.python.org/moin/BeginnersGuide

</F>

Oct 26 '06 #6

P: n/a
On 26 Oct 2006 02:27:16 -0700, Arun Nair <na*******@gmail.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.
Oct 27 '06 #7

P: n/a

Dennis Lee Bieber wrote:
On Fri, 27 Oct 2006 03:48:25 GMT, Michael Naunton
<mm*@news.bellatlantic.netdeclaimed the following in comp.lang.python:

This may seem pendantic, but CS is mostly about thinking about (and thus

<snickerSomeday 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?
--
Wulfraed Dennis Lee Bieber KD6MOG
wl*****@ix.netcom.com wu******@bestiaria.com
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: we******@bestiaria.com)
HTTP://www.bestiaria.com/
Oct 27 '06 #8

P: n/a
me********@aol.com wrote:
Dennis Lee Bieber wrote:
>On Fri, 27 Oct 2006 03:48:25 GMT, Michael Naunton
<mm*@news.bellatlantic.netdeclaimed the following in comp.lang.python:
>>This may seem pendantic, but CS is mostly about thinking about (and thus
<snickerSomeday 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?
>--
Wulfraed Dennis Lee Bieber KD6MOG
wl*****@ix.netcom.com wu******@bestiaria.com
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: we******@bestiaria.com)
HTTP://www.bestiaria.com/
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.
Oct 27 '06 #9

P: n/a
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
Oct 27 '06 #10

P: n/a
Gabriel Genellina <ga******@yahoo.com.arwrites:
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

Oct 28 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.