473,799 Members | 3,158 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Oct 26 '06 #1
10 4965
"Arun Nair" <na*******@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?
Oct 26 '06 #2
"Arun Nair" <na*******@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

Oct 26 '06 #3
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?
Oct 26 '06 #4
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
Oct 26 '06 #5
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
On 26 Oct 2006 02:27:16 -0700, Arun Nair <na*******@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.
Oct 27 '06 #7

Dennis Lee Bieber wrote:
On Fri, 27 Oct 2006 03:48:25 GMT, Michael Naunton
<mm*@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?
--
Wulfraed Dennis Lee Bieber KD6MOG
wl*****@ix.netc om.com wu******@bestia ria.com
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: we******@bestia ria.com)
HTTP://www.bestiaria.com/
Oct 27 '06 #8
me********@aol. com wrote:
Dennis Lee Bieber wrote:
>On Fri, 27 Oct 2006 03:48:25 GMT, Michael Naunton
<mm*@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?
>--
Wulfraed Dennis Lee Bieber KD6MOG
wl*****@ix.netc om.com wu******@bestia ria.com
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: we******@bestia ria.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
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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

26
1971
by: Radith | last post by:
Hi All, I have got this task which I cant get my head around: It asks how I would store information: I just want to get an opinion from the group: So here's the question: " You have been asked to write a program for a card playing friend. How would you store information about playing cards? For example how would
6
6220
by: CaseyB | last post by:
If I wanted to create a game like Solitaire that would first randomly shuffle a deck of cards, I figured out that all I had to use is the Random() class or rnd and make sure I use the Randomize function so as not to get the same card twice. BUT I noticed that some Solitaire games allow you to select one of the 4,294,967,296 possibilities in a 52 card deck. I want to do something similar, after I shuffle the deck I want to show the number...
11
7539
by: prince99 | last post by:
i am worlking on the cards class so it can do several things. My code is as before but need to change the things to solve given problem Create a new class Deck that represents a pack of 52 cards. The class should support 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...
4
9192
by: Pratik | last post by:
For the time being, I'm doing a simple swap method for my deck of cards using the random number generator in cstdlib. I've created a dynamic array of a type class Card. When I go to shuffle it and then later print the shuffled deck, some of the values overlap -- I can't figure out why. Here's my code: void shuffle() { for (counter = 0; counter < 120; counter++) {
11
14155
by: cazconv2007 | last post by:
hi i have homework due tomorrow been trying to do java homework all week and nothings happening really starting to stress out i dont understand what the program is meant to do or how to use three classes The program This week you are going to write three classes: Card.java, Deck.java and DeckTester.java. The specification for each class is given below. Card.Java This is a simple class that represents a playing card.
3
3061
by: JayP | last post by:
I'm trying to shuffle a deck of card in C ++, with out having the same card twice. And I'm supposed to give each player 5 cards. And if they want, they can replace 3 cards. Right now I can assign 5 cards to each player, but some of the cards repeat themselces (ex. I have 3 Ace of spades, or 2 king of clubs, etc). Can anyone help me fix this problem. Here is what I have so far. #include <iostream> #include <ctime> #include <cstdlib>...
8
29171
by: garyrowell | last post by:
I have been at this programme for hours trying to work out what is wrong. Any help would be very much appricated. Here is the breif I received. The program This week you are going to write three classes: Card.java, Deck.java and DeckTester.java. The specification for each class is given below. Card.Java This is a simple class that represents a playing card. Card has two attributes: • rank which is a String that represents the value...
1
2392
by: Vneha | last post by:
import java.util.*; public class Deck { public static int numSuits = 4; public static int numRanks = 13; public static int numCards = numSuits * numRanks; private Card cards;
0
9538
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10470
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10214
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10023
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6803
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5459
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5583
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4135
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2935
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.