440,352 Members | 1,645 Online
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
10 Replies

 P: n/a "Arun Nair"

 P: n/a "Arun Nair"

 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

 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 wrote: "Arun Nair"

 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 Oct 26 '06 #6

 P: n/a On 26 Oct 2006 02:27:16 -0700, Arun Nair

 P: n/a Dennis Lee Bieber wrote: On Fri, 27 Oct 2006 03:48:25 GMT, Michael Naunton 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>This may seem pendantic, but CS is mostly about thinking about (and thus 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. Switchto a new university now.As noted in the problem, a deck has 52 cards. cardsLeft(self) thereforealways returns 52.This may seem pendantic, but CS is mostly about thinking about (and thusnaming) 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